Mercurial > hg
view tests/test-journal-share.t @ 36534:5faeabb07cf5
debugcommands: support for triggering push protocol
The mechanism for pushing to a remote is a bit more complicated
than other commands. On SSH, we wait for a positive reply from
the server before we start sending the bundle payload.
This commit adds a mechanism to the "command" action in
`hg debugwireproto` to trigger the "push protocol" and to
specify a file whose contents should be submitted as the command
payload.
With this new feature, we implement a handful of tests for the
"unbundle" command. We try to cover various server failures and
hook/output scenarios so protocol behavior is as comprehensively
tested as possible. Even with so much test output, we only cover
bundle1 with Python hooks. There's still a lot of test coverage
that needs to be implemented. But this is certainly a good start.
Because there are so many new tests, we split these tests into their
own test file.
In order to make output deterministic, we need to disable the
doublepipe primitive. We add an option to `hg debugwireproto`
to do that. Because something in the bowels of the peer does a
read of stderr, we still capture read I/O from stderr. So there
is test coverage of what the server emits.
The tests around I/O capture some wonkiness. For example,
interleaved ui.write() and ui.write_err() calls are emitted in
order. However, (presumably due to buffering), print() to
sys.stdout and sys.stderr aren't in order.
We currently only test bundle1 because bundle2 is substantially
harder to test because it is more complicated (the server responds
with a stream containing a bundle2 instead of a frame).
Differential Revision: https://phab.mercurial-scm.org/D2471
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 26 Feb 2018 18:01:13 -0800 |
parents | 9843e3d9f4b6 |
children | a8a902d7176e |
line wrap: on
line source
Journal extension test: tests the share extension support $ cat >> testmocks.py << EOF > # mock out util.getuser() and util.makedate() to supply testable values > import os > from mercurial import util > def mockgetuser(): > return 'foobar' > > def mockmakedate(): > filename = os.path.join(os.environ['TESTTMP'], 'testtime') > try: > with open(filename, 'rb') as timef: > time = float(timef.read()) + 1 > except IOError: > time = 0.0 > with open(filename, 'wb') as timef: > timef.write(str(time)) > return (time, 0) > > util.getuser = mockgetuser > util.makedate = mockmakedate > EOF $ cat >> $HGRCPATH << EOF > [extensions] > journal= > share= > testmocks=`pwd`/testmocks.py > [remotenames] > rename.default=remote > EOF $ hg init repo $ cd repo $ hg bookmark bm $ touch file0 $ hg commit -Am file0-added adding file0 $ hg journal --all previous locations of the working copy and bookmarks: 0fd3805711f9 . commit -Am file0-added 0fd3805711f9 bm commit -Am file0-added A shared working copy initially receives the same bookmarks and working copy $ cd .. $ hg share repo shared1 updating working directory 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd shared1 $ hg journal --all previous locations of the working copy and bookmarks: 0fd3805711f9 . share repo shared1 unless you explicitly share bookmarks $ cd .. $ hg share --bookmarks repo shared2 updating working directory 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd shared2 $ hg journal --all previous locations of the working copy and bookmarks: 0fd3805711f9 . share --bookmarks repo shared2 0fd3805711f9 bm commit -Am file0-added Moving the bookmark in the original repository is only shown in the repository that shares bookmarks $ cd ../repo $ touch file1 $ hg commit -Am file1-added adding file1 $ cd ../shared1 $ hg journal --all previous locations of the working copy and bookmarks: 0fd3805711f9 . share repo shared1 $ cd ../shared2 $ hg journal --all previous locations of the working copy and bookmarks: 4f354088b094 bm commit -Am file1-added 0fd3805711f9 . share --bookmarks repo shared2 0fd3805711f9 bm commit -Am file0-added But working copy changes are always 'local' $ cd ../repo $ hg up 0 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (leaving bookmark bm) $ hg journal --all previous locations of the working copy and bookmarks: 0fd3805711f9 . up 0 4f354088b094 . commit -Am file1-added 4f354088b094 bm commit -Am file1-added 0fd3805711f9 . commit -Am file0-added 0fd3805711f9 bm commit -Am file0-added $ cd ../shared2 $ hg journal --all previous locations of the working copy and bookmarks: 4f354088b094 bm commit -Am file1-added 0fd3805711f9 . share --bookmarks repo shared2 0fd3805711f9 bm commit -Am file0-added $ hg up tip 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg up 0 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg journal previous locations of '.': 0fd3805711f9 up 0 4f354088b094 up tip 0fd3805711f9 share --bookmarks repo shared2 Unsharing works as expected; the journal remains consistent $ cd ../shared1 $ hg unshare $ hg journal --all previous locations of the working copy and bookmarks: 0fd3805711f9 . share repo shared1 $ cd ../shared2 $ hg unshare $ hg journal --all previous locations of the working copy and bookmarks: 0fd3805711f9 . up 0 4f354088b094 . up tip 4f354088b094 bm commit -Am file1-added 0fd3805711f9 . share --bookmarks repo shared2 0fd3805711f9 bm commit -Am file0-added New journal entries in the source repo no longer show up in the other working copies $ cd ../repo $ hg bookmark newbm -r tip $ hg journal newbm previous locations of 'newbm': 4f354088b094 bookmark newbm -r tip $ cd ../shared2 $ hg journal newbm previous locations of 'newbm': no recorded locations This applies for both directions $ hg bookmark shared2bm -r tip $ hg journal shared2bm previous locations of 'shared2bm': 4f354088b094 bookmark shared2bm -r tip $ cd ../repo $ hg journal shared2bm previous locations of 'shared2bm': no recorded locations