Mercurial > hg
comparison tests/test-share-bookmarks.t @ 42313:81ece800576a
tests: separate out bookmarks tests from test-share.t
Differential Revision: https://phab.mercurial-scm.org/D6384
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 15 May 2019 11:38:45 -0700 |
parents | tests/test-share.t@e4ac7e63c213 |
children | 314056e438a9 |
comparison
equal
deleted
inserted
replaced
42312:2b77183ac477 | 42313:81ece800576a |
---|---|
1 $ echo "[extensions]" >> $HGRCPATH | |
2 $ echo "share = " >> $HGRCPATH | |
3 | |
4 prepare repo1 | |
5 | |
6 $ hg init repo1 | |
7 $ cd repo1 | |
8 $ echo a > a | |
9 $ hg commit -A -m'init' | |
10 adding a | |
11 $ echo a >> a | |
12 $ hg commit -m'change in shared clone' | |
13 $ echo b > b | |
14 $ hg commit -A -m'another file' | |
15 adding b | |
16 | |
17 share it | |
18 | |
19 $ cd .. | |
20 $ hg share repo1 repo2 | |
21 updating working directory | |
22 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
23 | |
24 unshare it | |
25 | |
26 $ cd repo2 | |
27 $ hg unshare | |
28 | |
29 check that a change does not propagate | |
30 | |
31 $ echo b >> b | |
32 $ hg commit -m'change in unshared' | |
33 $ cd ../repo1 | |
34 $ hg id -r tip | |
35 c2e0ac586386 tip | |
36 | |
37 $ cd .. | |
38 | |
39 test sharing bookmarks | |
40 | |
41 $ hg share -B repo1 repo3 | |
42 updating working directory | |
43 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
44 $ cd repo1 | |
45 $ hg bookmark bm1 | |
46 $ hg bookmarks | |
47 * bm1 2:c2e0ac586386 | |
48 $ cd ../repo2 | |
49 $ hg book bm2 | |
50 $ hg bookmarks | |
51 * bm2 3:0e6e70d1d5f1 | |
52 $ cd ../repo3 | |
53 $ hg bookmarks | |
54 bm1 2:c2e0ac586386 | |
55 $ hg book bm3 | |
56 $ hg bookmarks | |
57 bm1 2:c2e0ac586386 | |
58 * bm3 2:c2e0ac586386 | |
59 $ cd ../repo1 | |
60 $ hg bookmarks | |
61 * bm1 2:c2e0ac586386 | |
62 bm3 2:c2e0ac586386 | |
63 | |
64 check whether HG_PENDING makes pending changes only in relatd | |
65 repositories visible to an external hook. | |
66 | |
67 In "hg share" case, another transaction can't run in other | |
68 repositories sharing same source repository, because starting | |
69 transaction requires locking store of source repository. | |
70 | |
71 Therefore, this test scenario ignores checking visibility of | |
72 .hg/bookmakrs.pending in repo2, which shares repo1 without bookmarks. | |
73 | |
74 $ cat > $TESTTMP/checkbookmarks.sh <<EOF | |
75 > echo "@repo1" | |
76 > hg -R "$TESTTMP/repo1" bookmarks | |
77 > echo "@repo2" | |
78 > hg -R "$TESTTMP/repo2" bookmarks | |
79 > echo "@repo3" | |
80 > hg -R "$TESTTMP/repo3" bookmarks | |
81 > exit 1 # to avoid adding new bookmark for subsequent tests | |
82 > EOF | |
83 | |
84 $ cd ../repo1 | |
85 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkbookmarks.sh" -q book bmX | |
86 @repo1 | |
87 bm1 2:c2e0ac586386 | |
88 bm3 2:c2e0ac586386 | |
89 * bmX 2:c2e0ac586386 | |
90 @repo2 | |
91 * bm2 3:0e6e70d1d5f1 | |
92 @repo3 | |
93 bm1 2:c2e0ac586386 | |
94 * bm3 2:c2e0ac586386 | |
95 bmX 2:c2e0ac586386 | |
96 transaction abort! | |
97 rollback completed | |
98 abort: pretxnclose hook exited with status 1 | |
99 [255] | |
100 $ hg book bm1 | |
101 | |
102 FYI, in contrast to above test, bmX is invisible in repo1 (= shared | |
103 src), because (1) HG_PENDING refers only repo3 and (2) | |
104 "bookmarks.pending" is written only into repo3. | |
105 | |
106 $ cd ../repo3 | |
107 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkbookmarks.sh" -q book bmX | |
108 @repo1 | |
109 * bm1 2:c2e0ac586386 | |
110 bm3 2:c2e0ac586386 | |
111 @repo2 | |
112 * bm2 3:0e6e70d1d5f1 | |
113 @repo3 | |
114 bm1 2:c2e0ac586386 | |
115 bm3 2:c2e0ac586386 | |
116 * bmX 2:c2e0ac586386 | |
117 transaction abort! | |
118 rollback completed | |
119 abort: pretxnclose hook exited with status 1 | |
120 [255] | |
121 $ hg book bm3 | |
122 | |
123 $ cd ../repo1 | |
124 | |
125 test that commits work | |
126 | |
127 $ echo 'shared bookmarks' > a | |
128 $ hg commit -m 'testing shared bookmarks' | |
129 $ hg bookmarks | |
130 * bm1 3:b87954705719 | |
131 bm3 2:c2e0ac586386 | |
132 $ cd ../repo3 | |
133 $ hg bookmarks | |
134 bm1 3:b87954705719 | |
135 * bm3 2:c2e0ac586386 | |
136 $ echo 'more shared bookmarks' > a | |
137 $ hg commit -m 'testing shared bookmarks' | |
138 created new head | |
139 $ hg bookmarks | |
140 bm1 3:b87954705719 | |
141 * bm3 4:62f4ded848e4 | |
142 $ cd ../repo1 | |
143 $ hg bookmarks | |
144 * bm1 3:b87954705719 | |
145 bm3 4:62f4ded848e4 | |
146 $ cd .. | |
147 | |
148 test pushing bookmarks works | |
149 | |
150 $ hg clone repo3 repo4 | |
151 updating to branch default | |
152 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
153 $ cd repo4 | |
154 $ hg boo bm4 | |
155 $ echo foo > b | |
156 $ hg commit -m 'foo in b' | |
157 $ hg boo | |
158 bm1 3:b87954705719 | |
159 bm3 4:62f4ded848e4 | |
160 * bm4 5:92793bfc8cad | |
161 $ hg push -B bm4 | |
162 pushing to $TESTTMP/repo3 | |
163 searching for changes | |
164 adding changesets | |
165 adding manifests | |
166 adding file changes | |
167 added 1 changesets with 1 changes to 1 files | |
168 exporting bookmark bm4 | |
169 $ cd ../repo1 | |
170 $ hg bookmarks | |
171 * bm1 3:b87954705719 | |
172 bm3 4:62f4ded848e4 | |
173 bm4 5:92793bfc8cad | |
174 $ cd ../repo3 | |
175 $ hg bookmarks | |
176 bm1 3:b87954705719 | |
177 * bm3 4:62f4ded848e4 | |
178 bm4 5:92793bfc8cad | |
179 $ cd .. | |
180 | |
181 test behavior when sharing a shared repo | |
182 | |
183 $ hg share -B repo3 missingdir/repo5 | |
184 updating working directory | |
185 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
186 $ cd missingdir/repo5 | |
187 $ hg book | |
188 bm1 3:b87954705719 | |
189 bm3 4:62f4ded848e4 | |
190 bm4 5:92793bfc8cad | |
191 $ cd ../.. | |
192 | |
193 test what happens when an active bookmark is deleted | |
194 | |
195 $ cd repo1 | |
196 $ hg boo -d bm3 | |
197 $ hg boo | |
198 * bm1 3:b87954705719 | |
199 bm4 5:92793bfc8cad | |
200 $ cd ../repo3 | |
201 $ hg boo | |
202 bm1 3:b87954705719 | |
203 bm4 5:92793bfc8cad | |
204 $ cd .. | |
205 | |
206 verify that bookmarks are not written on failed transaction | |
207 | |
208 $ cat > failpullbookmarks.py << EOF | |
209 > """A small extension that makes bookmark pulls fail, for testing""" | |
210 > from __future__ import absolute_import | |
211 > from mercurial import ( | |
212 > error, | |
213 > exchange, | |
214 > extensions, | |
215 > ) | |
216 > def _pullbookmarks(orig, pullop): | |
217 > orig(pullop) | |
218 > raise error.HookAbort('forced failure by extension') | |
219 > def extsetup(ui): | |
220 > extensions.wrapfunction(exchange, '_pullbookmarks', _pullbookmarks) | |
221 > EOF | |
222 $ cd repo4 | |
223 $ hg boo | |
224 bm1 3:b87954705719 | |
225 bm3 4:62f4ded848e4 | |
226 * bm4 5:92793bfc8cad | |
227 $ cd ../repo3 | |
228 $ hg boo | |
229 bm1 3:b87954705719 | |
230 bm4 5:92793bfc8cad | |
231 $ hg --config "extensions.failpullbookmarks=$TESTTMP/failpullbookmarks.py" pull $TESTTMP/repo4 | |
232 pulling from $TESTTMP/repo4 | |
233 searching for changes | |
234 no changes found | |
235 adding remote bookmark bm3 | |
236 abort: forced failure by extension | |
237 [255] | |
238 $ hg boo | |
239 bm1 3:b87954705719 | |
240 bm4 5:92793bfc8cad | |
241 $ hg pull $TESTTMP/repo4 | |
242 pulling from $TESTTMP/repo4 | |
243 searching for changes | |
244 no changes found | |
245 adding remote bookmark bm3 | |
246 1 local changesets published | |
247 $ hg boo | |
248 bm1 3:b87954705719 | |
249 * bm3 4:62f4ded848e4 | |
250 bm4 5:92793bfc8cad | |
251 $ cd .. | |
252 | |
253 verify bookmark behavior after unshare | |
254 | |
255 $ cd repo3 | |
256 $ hg unshare | |
257 $ hg boo | |
258 bm1 3:b87954705719 | |
259 * bm3 4:62f4ded848e4 | |
260 bm4 5:92793bfc8cad | |
261 $ hg boo -d bm4 | |
262 $ hg boo bm5 | |
263 $ hg boo | |
264 bm1 3:b87954705719 | |
265 bm3 4:62f4ded848e4 | |
266 * bm5 4:62f4ded848e4 | |
267 $ cd ../repo1 | |
268 $ hg boo | |
269 * bm1 3:b87954705719 | |
270 bm3 4:62f4ded848e4 | |
271 bm4 5:92793bfc8cad | |
272 $ cd .. |