| 1 |
#testcases safe normal |
| 2 |
|
| 3 |
#if safe |
| 4 |
$ echo "[format]" >> $HGRCPATH |
| 5 |
$ echo "exp-share-safe = True" >> $HGRCPATH |
| 6 |
#endif |
| 7 |
|
| 8 |
Journal extension test: tests the share extension support |
| 9 |
|
| 10 |
$ cat >> testmocks.py << EOF |
| 11 |
> # mock out procutil.getuser() and util.makedate() to supply testable values |
| 12 |
> import os |
| 13 |
> from mercurial import util |
| 14 |
> from mercurial.utils import procutil |
| 15 |
> def mockgetuser(): |
| 16 |
> return b'foobar' |
| 17 |
> |
| 18 |
> def mockmakedate(): |
| 19 |
> filename = os.path.join(os.environ['TESTTMP'], 'testtime') |
| 20 |
> try: |
| 21 |
> with open(filename, 'rb') as timef: |
| 22 |
> time = float(timef.read()) + 1 |
| 23 |
> except IOError: |
| 24 |
> time = 0.0 |
| 25 |
> with open(filename, 'wb') as timef: |
| 26 |
> timef.write(str(time)) |
| 27 |
> return (time, 0) |
| 28 |
> |
| 29 |
> procutil.getuser = mockgetuser |
| 30 |
> util.makedate = mockmakedate |
| 31 |
> EOF |
| 32 |
|
| 33 |
$ cat >> $HGRCPATH << EOF |
| 34 |
> [extensions] |
| 35 |
> journal= |
| 36 |
> share= |
| 37 |
> testmocks=`pwd`/testmocks.py |
| 38 |
> [remotenames] |
| 39 |
> rename.default=remote |
| 40 |
> EOF |
| 41 |
|
| 42 |
$ hg init repo |
| 43 |
$ cd repo |
| 44 |
$ hg bookmark bm |
| 45 |
$ touch file0 |
| 46 |
$ hg commit -Am file0-added |
| 47 |
adding file0 |
| 48 |
$ hg journal --all |
| 49 |
previous locations of the working copy and bookmarks: |
| 50 |
0fd3805711f9 . commit -Am file0-added |
| 51 |
0fd3805711f9 bm commit -Am file0-added |
| 52 |
|
| 53 |
A shared working copy initially receives the same bookmarks and working copy |
| 54 |
|
| 55 |
$ cd .. |
| 56 |
$ hg share repo shared1 |
| 57 |
updating working directory |
| 58 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 59 |
$ cd shared1 |
| 60 |
$ hg journal --all |
| 61 |
previous locations of the working copy and bookmarks: |
| 62 |
0fd3805711f9 . share repo shared1 |
| 63 |
|
| 64 |
unless you explicitly share bookmarks |
| 65 |
|
| 66 |
$ cd .. |
| 67 |
$ hg share --bookmarks repo shared2 |
| 68 |
updating working directory |
| 69 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 70 |
$ cd shared2 |
| 71 |
$ hg journal --all |
| 72 |
previous locations of the working copy and bookmarks: |
| 73 |
0fd3805711f9 . share --bookmarks repo shared2 |
| 74 |
0fd3805711f9 bm commit -Am file0-added |
| 75 |
|
| 76 |
Moving the bookmark in the original repository is only shown in the repository |
| 77 |
that shares bookmarks |
| 78 |
|
| 79 |
$ cd ../repo |
| 80 |
$ touch file1 |
| 81 |
$ hg commit -Am file1-added |
| 82 |
adding file1 |
| 83 |
$ cd ../shared1 |
| 84 |
$ hg journal --all |
| 85 |
previous locations of the working copy and bookmarks: |
| 86 |
0fd3805711f9 . share repo shared1 |
| 87 |
$ cd ../shared2 |
| 88 |
$ hg journal --all |
| 89 |
previous locations of the working copy and bookmarks: |
| 90 |
4f354088b094 bm commit -Am file1-added |
| 91 |
0fd3805711f9 . share --bookmarks repo shared2 |
| 92 |
0fd3805711f9 bm commit -Am file0-added |
| 93 |
|
| 94 |
But working copy changes are always 'local' |
| 95 |
|
| 96 |
$ cd ../repo |
| 97 |
$ hg up 0 |
| 98 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 99 |
(leaving bookmark bm) |
| 100 |
$ hg journal --all |
| 101 |
previous locations of the working copy and bookmarks: |
| 102 |
0fd3805711f9 . up 0 |
| 103 |
4f354088b094 . commit -Am file1-added |
| 104 |
4f354088b094 bm commit -Am file1-added |
| 105 |
0fd3805711f9 . commit -Am file0-added |
| 106 |
0fd3805711f9 bm commit -Am file0-added |
| 107 |
$ cd ../shared2 |
| 108 |
$ hg journal --all |
| 109 |
previous locations of the working copy and bookmarks: |
| 110 |
4f354088b094 bm commit -Am file1-added |
| 111 |
0fd3805711f9 . share --bookmarks repo shared2 |
| 112 |
0fd3805711f9 bm commit -Am file0-added |
| 113 |
$ hg up tip |
| 114 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 115 |
$ hg up 0 |
| 116 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 117 |
$ hg journal |
| 118 |
previous locations of '.': |
| 119 |
0fd3805711f9 up 0 |
| 120 |
4f354088b094 up tip |
| 121 |
0fd3805711f9 share --bookmarks repo shared2 |
| 122 |
|
| 123 |
Unsharing works as expected; the journal remains consistent |
| 124 |
|
| 125 |
$ cd ../shared1 |
| 126 |
$ hg unshare |
| 127 |
$ hg journal --all |
| 128 |
previous locations of the working copy and bookmarks: |
| 129 |
0fd3805711f9 . share repo shared1 |
| 130 |
$ cd ../shared2 |
| 131 |
$ hg unshare |
| 132 |
$ hg journal --all |
| 133 |
previous locations of the working copy and bookmarks: |
| 134 |
0fd3805711f9 . up 0 |
| 135 |
4f354088b094 . up tip |
| 136 |
4f354088b094 bm commit -Am file1-added |
| 137 |
0fd3805711f9 . share --bookmarks repo shared2 |
| 138 |
0fd3805711f9 bm commit -Am file0-added |
| 139 |
|
| 140 |
New journal entries in the source repo no longer show up in the other working copies |
| 141 |
|
| 142 |
$ cd ../repo |
| 143 |
$ hg bookmark newbm -r tip |
| 144 |
$ hg journal newbm |
| 145 |
previous locations of 'newbm': |
| 146 |
4f354088b094 bookmark newbm -r tip |
| 147 |
$ cd ../shared2 |
| 148 |
$ hg journal newbm |
| 149 |
previous locations of 'newbm': |
| 150 |
no recorded locations |
| 151 |
|
| 152 |
This applies for both directions |
| 153 |
|
| 154 |
$ hg bookmark shared2bm -r tip |
| 155 |
$ hg journal shared2bm |
| 156 |
previous locations of 'shared2bm': |
| 157 |
4f354088b094 bookmark shared2bm -r tip |
| 158 |
$ cd ../repo |
| 159 |
$ hg journal shared2bm |
| 160 |
previous locations of 'shared2bm': |
| 161 |
no recorded locations |