##// END OF EJS Templates
py3: use b'%d' to convert int to bytes instead of str()...
py3: use b'%d' to convert int to bytes instead of str() Differential Revision: https://phab.mercurial-scm.org/D3280

File last commit:

r37401:cb70be32 default
r37599:5b836a4c default
Show More
test-journal-share.t
154 lines | 4.5 KiB | text/troff | Tads3Lexer
/ tests / test-journal-share.t
Martijn Pieters
journal: add share extension support...
r29503 Journal extension test: tests the share extension support
$ cat >> testmocks.py << EOF
Yuya Nishihara
procutil: bulk-replace function calls to point to new module
r37138 > # mock out procutil.getuser() and util.makedate() to supply testable values
Martijn Pieters
journal: add share extension support...
r29503 > import os
> from mercurial import util
Yuya Nishihara
procutil: bulk-replace function calls to point to new module
r37138 > from mercurial.utils import procutil
Martijn Pieters
journal: add share extension support...
r29503 > def mockgetuser():
Pulkit Goyal
py3: convert user value to bytes by b'' prefix...
r37401 > return b'foobar'
Martijn Pieters
journal: add share extension support...
r29503 >
> 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)
>
Yuya Nishihara
procutil: bulk-replace function calls to point to new module
r37138 > procutil.getuser = mockgetuser
Martijn Pieters
journal: add share extension support...
r29503 > 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
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 $ hg commit -Am file0-added
Martijn Pieters
journal: add share extension support...
r29503 adding file0
$ hg journal --all
previous locations of the working copy and bookmarks:
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 0fd3805711f9 . commit -Am file0-added
0fd3805711f9 bm commit -Am file0-added
Martijn Pieters
journal: add share extension support...
r29503
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:
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 0fd3805711f9 . share repo shared1
Martijn Pieters
journal: add share extension support...
r29503
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:
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 0fd3805711f9 . share --bookmarks repo shared2
0fd3805711f9 bm commit -Am file0-added
Martijn Pieters
journal: add share extension support...
r29503
Moving the bookmark in the original repository is only shown in the repository
that shares bookmarks
$ cd ../repo
$ touch file1
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 $ hg commit -Am file1-added
Martijn Pieters
journal: add share extension support...
r29503 adding file1
$ cd ../shared1
$ hg journal --all
previous locations of the working copy and bookmarks:
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 0fd3805711f9 . share repo shared1
Martijn Pieters
journal: add share extension support...
r29503 $ cd ../shared2
$ hg journal --all
previous locations of the working copy and bookmarks:
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 4f354088b094 bm commit -Am file1-added
0fd3805711f9 . share --bookmarks repo shared2
0fd3805711f9 bm commit -Am file0-added
Martijn Pieters
journal: add share extension support...
r29503
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:
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 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
Martijn Pieters
journal: add share extension support...
r29503 $ cd ../shared2
$ hg journal --all
previous locations of the working copy and bookmarks:
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 4f354088b094 bm commit -Am file1-added
0fd3805711f9 . share --bookmarks repo shared2
0fd3805711f9 bm commit -Am file0-added
Martijn Pieters
journal: add share extension support...
r29503 $ 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 '.':
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 0fd3805711f9 up 0
4f354088b094 up tip
0fd3805711f9 share --bookmarks repo shared2
Martijn Pieters
journal: add share extension support...
r29503
Unsharing works as expected; the journal remains consistent
$ cd ../shared1
$ hg unshare
$ hg journal --all
previous locations of the working copy and bookmarks:
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 0fd3805711f9 . share repo shared1
Martijn Pieters
journal: add share extension support...
r29503 $ cd ../shared2
$ hg unshare
$ hg journal --all
previous locations of the working copy and bookmarks:
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 0fd3805711f9 . up 0
4f354088b094 . up tip
4f354088b094 bm commit -Am file1-added
0fd3805711f9 . share --bookmarks repo shared2
0fd3805711f9 bm commit -Am file0-added
Martijn Pieters
journal: add share extension support...
r29503
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':
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 4f354088b094 bookmark newbm -r tip
Martijn Pieters
journal: add share extension support...
r29503 $ 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':
FUJIWARA Katsunori
tests: avoid quoting of commit messages for test portability...
r30238 4f354088b094 bookmark shared2bm -r tip
Martijn Pieters
journal: add share extension support...
r29503 $ cd ../repo
$ hg journal shared2bm
previous locations of 'shared2bm':
no recorded locations