##// END OF EJS Templates
tests: demonstrate failure when cloning from a share via bundle2...
mitchell plamann -
r41957:a62ad1be default
parent child Browse files
Show More
@@ -1,472 +1,482 b''
1 1 $ echo "[extensions]" >> $HGRCPATH
2 2 $ echo "share = " >> $HGRCPATH
3 3
4 4 prepare repo1
5 5
6 6 $ hg init repo1
7 7 $ cd repo1
8 8 $ echo a > a
9 9 $ hg commit -A -m'init'
10 10 adding a
11 11
12 12 share it
13 13
14 14 $ cd ..
15 15 $ hg share repo1 repo2
16 16 updating working directory
17 17 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
18 18
19 19 share shouldn't have a store dir
20 20
21 21 $ cd repo2
22 22 $ test -d .hg/store
23 23 [1]
24 24
25 25 share shouldn't have a full cache dir, original repo should
26 26
27 27 $ hg branches
28 28 default 0:d3873e73d99e
29 29 $ hg tags
30 30 tip 0:d3873e73d99e
31 31 $ test -d .hg/cache
32 32 [1]
33 33 $ ls -1 .hg/wcache || true
34 34 checkisexec (execbit !)
35 35 checklink (symlink !)
36 36 checklink-target (symlink !)
37 37 $ ls -1 ../repo1/.hg/cache
38 38 branch2-served
39 39 manifestfulltextcache (reporevlogstore !)
40 40 rbc-names-v1
41 41 rbc-revs-v1
42 42 tags2-visible
43 43
44 44 Some sed versions appends newline, some don't, and some just fails
45 45
46 46 $ cat .hg/sharedpath; echo
47 47 $TESTTMP/repo1/.hg
48 48
49 49 trailing newline on .hg/sharedpath is ok
50 50 $ hg tip -q
51 51 0:d3873e73d99e
52 52 $ echo '' >> .hg/sharedpath
53 53 $ cat .hg/sharedpath
54 54 $TESTTMP/repo1/.hg
55 55 $ hg tip -q
56 56 0:d3873e73d99e
57 57
58 58 commit in shared clone
59 59
60 60 $ echo a >> a
61 61 $ hg commit -m'change in shared clone'
62 62
63 63 check original
64 64
65 65 $ cd ../repo1
66 66 $ hg log
67 67 changeset: 1:8af4dc49db9e
68 68 tag: tip
69 69 user: test
70 70 date: Thu Jan 01 00:00:00 1970 +0000
71 71 summary: change in shared clone
72 72
73 73 changeset: 0:d3873e73d99e
74 74 user: test
75 75 date: Thu Jan 01 00:00:00 1970 +0000
76 76 summary: init
77 77
78 78 $ hg update
79 79 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
80 80 $ cat a # should be two lines of "a"
81 81 a
82 82 a
83 83
84 84 commit in original
85 85
86 86 $ echo b > b
87 87 $ hg commit -A -m'another file'
88 88 adding b
89 89
90 90 check in shared clone
91 91
92 92 $ cd ../repo2
93 93 $ hg log
94 94 changeset: 2:c2e0ac586386
95 95 tag: tip
96 96 user: test
97 97 date: Thu Jan 01 00:00:00 1970 +0000
98 98 summary: another file
99 99
100 100 changeset: 1:8af4dc49db9e
101 101 user: test
102 102 date: Thu Jan 01 00:00:00 1970 +0000
103 103 summary: change in shared clone
104 104
105 105 changeset: 0:d3873e73d99e
106 106 user: test
107 107 date: Thu Jan 01 00:00:00 1970 +0000
108 108 summary: init
109 109
110 110 $ hg update
111 111 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
112 112 $ cat b # should exist with one "b"
113 113 b
114 114
115 115 hg serve shared clone
116 116
117 117 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid
118 118 $ cat hg.pid >> $DAEMON_PIDS
119 119 $ get-with-headers.py localhost:$HGPORT 'raw-file/'
120 120 200 Script output follows
121 121
122 122
123 123 -rw-r--r-- 4 a
124 124 -rw-r--r-- 2 b
125 125
126 126
127 Cloning a shared repo via bundle2 wrongly adds "shared" to the clone's requirements
128
129 $ cd ..
130 $ hg clone -q --stream --config ui.ssh="$PYTHON \"$TESTDIR/dummyssh\"" ssh://user@dummy/`pwd`/repo2 cloned-via-bundle2
131 $ cat ./cloned-via-bundle2/.hg/requires | grep "shared"
132 shared
133 $ hg id --cwd cloned-via-bundle2 -r tip
134 abort: $ENOENT$: '$TESTTMP/cloned-via-bundle2/.hg/sharedpath'
135 [255]
136 $ cd repo2
127 137
128 138 test unshare command
129 139
130 140 $ hg unshare
131 141 $ test -d .hg/store
132 142 $ test -f .hg/sharedpath
133 143 [1]
134 144 $ grep shared .hg/requires
135 145 [1]
136 146 $ hg unshare
137 147 abort: this is not a shared repo
138 148 [255]
139 149
140 150 check that a change does not propagate
141 151
142 152 $ echo b >> b
143 153 $ hg commit -m'change in unshared'
144 154 $ cd ../repo1
145 155 $ hg id -r tip
146 156 c2e0ac586386 tip
147 157
148 158 $ cd ..
149 159
150 160
151 161 test sharing bookmarks
152 162
153 163 $ hg share -B repo1 repo3
154 164 updating working directory
155 165 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
156 166 $ cd repo1
157 167 $ hg bookmark bm1
158 168 $ hg bookmarks
159 169 * bm1 2:c2e0ac586386
160 170 $ cd ../repo2
161 171 $ hg book bm2
162 172 $ hg bookmarks
163 173 * bm2 3:0e6e70d1d5f1
164 174 $ cd ../repo3
165 175 $ hg bookmarks
166 176 bm1 2:c2e0ac586386
167 177 $ hg book bm3
168 178 $ hg bookmarks
169 179 bm1 2:c2e0ac586386
170 180 * bm3 2:c2e0ac586386
171 181 $ cd ../repo1
172 182 $ hg bookmarks
173 183 * bm1 2:c2e0ac586386
174 184 bm3 2:c2e0ac586386
175 185
176 186 check whether HG_PENDING makes pending changes only in relatd
177 187 repositories visible to an external hook.
178 188
179 189 In "hg share" case, another transaction can't run in other
180 190 repositories sharing same source repository, because starting
181 191 transaction requires locking store of source repository.
182 192
183 193 Therefore, this test scenario ignores checking visibility of
184 194 .hg/bookmakrs.pending in repo2, which shares repo1 without bookmarks.
185 195
186 196 $ cat > $TESTTMP/checkbookmarks.sh <<EOF
187 197 > echo "@repo1"
188 198 > hg -R "$TESTTMP/repo1" bookmarks
189 199 > echo "@repo2"
190 200 > hg -R "$TESTTMP/repo2" bookmarks
191 201 > echo "@repo3"
192 202 > hg -R "$TESTTMP/repo3" bookmarks
193 203 > exit 1 # to avoid adding new bookmark for subsequent tests
194 204 > EOF
195 205
196 206 $ cd ../repo1
197 207 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkbookmarks.sh" -q book bmX
198 208 @repo1
199 209 bm1 2:c2e0ac586386
200 210 bm3 2:c2e0ac586386
201 211 * bmX 2:c2e0ac586386
202 212 @repo2
203 213 * bm2 3:0e6e70d1d5f1
204 214 @repo3
205 215 bm1 2:c2e0ac586386
206 216 * bm3 2:c2e0ac586386
207 217 bmX 2:c2e0ac586386
208 218 transaction abort!
209 219 rollback completed
210 220 abort: pretxnclose hook exited with status 1
211 221 [255]
212 222 $ hg book bm1
213 223
214 224 FYI, in contrast to above test, bmX is invisible in repo1 (= shared
215 225 src), because (1) HG_PENDING refers only repo3 and (2)
216 226 "bookmarks.pending" is written only into repo3.
217 227
218 228 $ cd ../repo3
219 229 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkbookmarks.sh" -q book bmX
220 230 @repo1
221 231 * bm1 2:c2e0ac586386
222 232 bm3 2:c2e0ac586386
223 233 @repo2
224 234 * bm2 3:0e6e70d1d5f1
225 235 @repo3
226 236 bm1 2:c2e0ac586386
227 237 bm3 2:c2e0ac586386
228 238 * bmX 2:c2e0ac586386
229 239 transaction abort!
230 240 rollback completed
231 241 abort: pretxnclose hook exited with status 1
232 242 [255]
233 243 $ hg book bm3
234 244
235 245 $ cd ../repo1
236 246
237 247 test that commits work
238 248
239 249 $ echo 'shared bookmarks' > a
240 250 $ hg commit -m 'testing shared bookmarks'
241 251 $ hg bookmarks
242 252 * bm1 3:b87954705719
243 253 bm3 2:c2e0ac586386
244 254 $ cd ../repo3
245 255 $ hg bookmarks
246 256 bm1 3:b87954705719
247 257 * bm3 2:c2e0ac586386
248 258 $ echo 'more shared bookmarks' > a
249 259 $ hg commit -m 'testing shared bookmarks'
250 260 created new head
251 261 $ hg bookmarks
252 262 bm1 3:b87954705719
253 263 * bm3 4:62f4ded848e4
254 264 $ cd ../repo1
255 265 $ hg bookmarks
256 266 * bm1 3:b87954705719
257 267 bm3 4:62f4ded848e4
258 268 $ cd ..
259 269
260 270 non largefiles repos won't enable largefiles
261 271
262 272 $ hg share --config extensions.largefiles= repo3 sharedrepo
263 273 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
264 274 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
265 275 updating working directory
266 276 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
267 277 $ [ -f sharedrepo/.hg/hgrc ]
268 278 [1]
269 279
270 280 test pushing bookmarks works
271 281
272 282 $ hg clone repo3 repo4
273 283 updating to branch default
274 284 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
275 285 $ cd repo4
276 286 $ hg boo bm4
277 287 $ echo foo > b
278 288 $ hg commit -m 'foo in b'
279 289 $ hg boo
280 290 bm1 3:b87954705719
281 291 bm3 4:62f4ded848e4
282 292 * bm4 5:92793bfc8cad
283 293 $ hg push -B bm4
284 294 pushing to $TESTTMP/repo3
285 295 searching for changes
286 296 adding changesets
287 297 adding manifests
288 298 adding file changes
289 299 added 1 changesets with 1 changes to 1 files
290 300 exporting bookmark bm4
291 301 $ cd ../repo1
292 302 $ hg bookmarks
293 303 * bm1 3:b87954705719
294 304 bm3 4:62f4ded848e4
295 305 bm4 5:92793bfc8cad
296 306 $ cd ../repo3
297 307 $ hg bookmarks
298 308 bm1 3:b87954705719
299 309 * bm3 4:62f4ded848e4
300 310 bm4 5:92793bfc8cad
301 311 $ cd ..
302 312
303 313 test behavior when sharing a shared repo
304 314
305 315 $ hg share -B repo3 missingdir/repo5
306 316 updating working directory
307 317 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
308 318 $ cd missingdir/repo5
309 319 $ hg book
310 320 bm1 3:b87954705719
311 321 bm3 4:62f4ded848e4
312 322 bm4 5:92793bfc8cad
313 323 $ cd ../..
314 324
315 325 test what happens when an active bookmark is deleted
316 326
317 327 $ cd repo1
318 328 $ hg boo -d bm3
319 329 $ hg boo
320 330 * bm1 3:b87954705719
321 331 bm4 5:92793bfc8cad
322 332 $ cd ../repo3
323 333 $ hg boo
324 334 bm1 3:b87954705719
325 335 bm4 5:92793bfc8cad
326 336 $ cd ..
327 337
328 338 verify that bookmarks are not written on failed transaction
329 339
330 340 $ cat > failpullbookmarks.py << EOF
331 341 > """A small extension that makes bookmark pulls fail, for testing"""
332 342 > from __future__ import absolute_import
333 343 > from mercurial import (
334 344 > error,
335 345 > exchange,
336 346 > extensions,
337 347 > )
338 348 > def _pullbookmarks(orig, pullop):
339 349 > orig(pullop)
340 350 > raise error.HookAbort('forced failure by extension')
341 351 > def extsetup(ui):
342 352 > extensions.wrapfunction(exchange, '_pullbookmarks', _pullbookmarks)
343 353 > EOF
344 354 $ cd repo4
345 355 $ hg boo
346 356 bm1 3:b87954705719
347 357 bm3 4:62f4ded848e4
348 358 * bm4 5:92793bfc8cad
349 359 $ cd ../repo3
350 360 $ hg boo
351 361 bm1 3:b87954705719
352 362 bm4 5:92793bfc8cad
353 363 $ hg --config "extensions.failpullbookmarks=$TESTTMP/failpullbookmarks.py" pull $TESTTMP/repo4
354 364 pulling from $TESTTMP/repo4
355 365 searching for changes
356 366 no changes found
357 367 adding remote bookmark bm3
358 368 abort: forced failure by extension
359 369 [255]
360 370 $ hg boo
361 371 bm1 3:b87954705719
362 372 bm4 5:92793bfc8cad
363 373 $ hg pull $TESTTMP/repo4
364 374 pulling from $TESTTMP/repo4
365 375 searching for changes
366 376 no changes found
367 377 adding remote bookmark bm3
368 378 1 local changesets published
369 379 $ hg boo
370 380 bm1 3:b87954705719
371 381 * bm3 4:62f4ded848e4
372 382 bm4 5:92793bfc8cad
373 383 $ cd ..
374 384
375 385 verify bookmark behavior after unshare
376 386
377 387 $ cd repo3
378 388 $ hg unshare
379 389 $ hg boo
380 390 bm1 3:b87954705719
381 391 * bm3 4:62f4ded848e4
382 392 bm4 5:92793bfc8cad
383 393 $ hg boo -d bm4
384 394 $ hg boo bm5
385 395 $ hg boo
386 396 bm1 3:b87954705719
387 397 bm3 4:62f4ded848e4
388 398 * bm5 4:62f4ded848e4
389 399 $ cd ../repo1
390 400 $ hg boo
391 401 * bm1 3:b87954705719
392 402 bm3 4:62f4ded848e4
393 403 bm4 5:92793bfc8cad
394 404 $ cd ..
395 405
396 406 test shared clones using relative paths work
397 407
398 408 $ mkdir thisdir
399 409 $ hg init thisdir/orig
400 410 $ hg share -U thisdir/orig thisdir/abs
401 411 $ hg share -U --relative thisdir/abs thisdir/rel
402 412 $ cat thisdir/rel/.hg/sharedpath
403 413 ../../orig/.hg (no-eol)
404 414 $ grep shared thisdir/*/.hg/requires
405 415 thisdir/abs/.hg/requires:shared
406 416 thisdir/rel/.hg/requires:relshared
407 417 thisdir/rel/.hg/requires:shared
408 418
409 419 test that relative shared paths aren't relative to $PWD
410 420
411 421 $ cd thisdir
412 422 $ hg -R rel root
413 423 $TESTTMP/thisdir/rel
414 424 $ cd ..
415 425
416 426 now test that relative paths really are relative, survive across
417 427 renames and changes of PWD
418 428
419 429 $ hg -R thisdir/abs root
420 430 $TESTTMP/thisdir/abs
421 431 $ hg -R thisdir/rel root
422 432 $TESTTMP/thisdir/rel
423 433 $ mv thisdir thatdir
424 434 $ hg -R thatdir/abs root
425 435 abort: .hg/sharedpath points to nonexistent directory $TESTTMP/thisdir/orig/.hg!
426 436 [255]
427 437 $ hg -R thatdir/rel root
428 438 $TESTTMP/thatdir/rel
429 439
430 440 test unshare relshared repo
431 441
432 442 $ cd thatdir/rel
433 443 $ hg unshare
434 444 $ test -d .hg/store
435 445 $ test -f .hg/sharedpath
436 446 [1]
437 447 $ grep shared .hg/requires
438 448 [1]
439 449 $ hg unshare
440 450 abort: this is not a shared repo
441 451 [255]
442 452 $ cd ../..
443 453
444 454 $ rm -r thatdir
445 455
446 456 Demonstrate buggy behavior around requirements validation
447 457 See comment in localrepo.py:makelocalrepository() for more.
448 458
449 459 $ hg init sharenewrequires
450 460 $ hg share sharenewrequires shareoldrequires
451 461 updating working directory
452 462 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
453 463
454 464 $ cat >> sharenewrequires/.hg/requires << EOF
455 465 > missing-requirement
456 466 > EOF
457 467
458 468 We cannot open the repo with the unknown requirement
459 469
460 470 $ hg -R sharenewrequires status
461 471 abort: repository requires features unknown to this Mercurial: missing-requirement!
462 472 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
463 473 [255]
464 474
465 475 BUG: we don't get the same error when opening the shared repo pointing to it
466 476
467 477 $ hg -R shareoldrequires status
468 478
469 479 Explicitly kill daemons to let the test exit on Windows
470 480
471 481 $ killdaemons.py
472 482
General Comments 0
You need to be logged in to leave comments. Login now