##// END OF EJS Templates
tests: quote paths in shell script hooks...
Matt Harbison -
r31767:6c800688 default
parent child Browse files
Show More
@@ -1,953 +1,953 b''
1 1 $ hg init repo
2 2 $ cd repo
3 3
4 4 no bookmarks
5 5
6 6 $ hg bookmarks
7 7 no bookmarks set
8 8
9 9 $ hg bookmarks -Tjson
10 10 [
11 11 ]
12 12
13 13 bookmark rev -1
14 14
15 15 $ hg bookmark X
16 16
17 17 list bookmarks
18 18
19 19 $ hg bookmarks
20 20 * X -1:000000000000
21 21
22 22 list bookmarks with color
23 23
24 24 $ hg --config extensions.color= --config color.mode=ansi \
25 25 > bookmarks --color=always
26 26 \x1b[0;32m * \x1b[0m\x1b[0;32mX\x1b[0m\x1b[0;32m -1:000000000000\x1b[0m (esc)
27 27
28 28 $ echo a > a
29 29 $ hg add a
30 30 $ hg commit -m 0
31 31
32 32 bookmark X moved to rev 0
33 33
34 34 $ hg bookmarks
35 35 * X 0:f7b1eb17ad24
36 36
37 37 look up bookmark
38 38
39 39 $ hg log -r X
40 40 changeset: 0:f7b1eb17ad24
41 41 bookmark: X
42 42 tag: tip
43 43 user: test
44 44 date: Thu Jan 01 00:00:00 1970 +0000
45 45 summary: 0
46 46
47 47
48 48 second bookmark for rev 0, command should work even with ui.strict on
49 49
50 50 $ hg --config ui.strict=1 bookmark X2
51 51
52 52 bookmark rev -1 again
53 53
54 54 $ hg bookmark -r null Y
55 55
56 56 list bookmarks
57 57
58 58 $ hg bookmarks
59 59 X 0:f7b1eb17ad24
60 60 * X2 0:f7b1eb17ad24
61 61 Y -1:000000000000
62 62
63 63 $ echo b > b
64 64 $ hg add b
65 65 $ hg commit -m 1
66 66
67 67 $ hg bookmarks -Tjson
68 68 [
69 69 {
70 70 "active": false,
71 71 "bookmark": "X",
72 72 "node": "f7b1eb17ad24730a1651fccd46c43826d1bbc2ac",
73 73 "rev": 0
74 74 },
75 75 {
76 76 "active": true,
77 77 "bookmark": "X2",
78 78 "node": "925d80f479bb026b0fb3deb27503780b13f74123",
79 79 "rev": 1
80 80 },
81 81 {
82 82 "active": false,
83 83 "bookmark": "Y",
84 84 "node": "0000000000000000000000000000000000000000",
85 85 "rev": -1
86 86 }
87 87 ]
88 88
89 89 bookmarks revset
90 90
91 91 $ hg log -r 'bookmark()'
92 92 changeset: 0:f7b1eb17ad24
93 93 bookmark: X
94 94 user: test
95 95 date: Thu Jan 01 00:00:00 1970 +0000
96 96 summary: 0
97 97
98 98 changeset: 1:925d80f479bb
99 99 bookmark: X2
100 100 tag: tip
101 101 user: test
102 102 date: Thu Jan 01 00:00:00 1970 +0000
103 103 summary: 1
104 104
105 105 $ hg log -r 'bookmark(Y)'
106 106 $ hg log -r 'bookmark(X2)'
107 107 changeset: 1:925d80f479bb
108 108 bookmark: X2
109 109 tag: tip
110 110 user: test
111 111 date: Thu Jan 01 00:00:00 1970 +0000
112 112 summary: 1
113 113
114 114 $ hg log -r 'bookmark("re:X")'
115 115 changeset: 0:f7b1eb17ad24
116 116 bookmark: X
117 117 user: test
118 118 date: Thu Jan 01 00:00:00 1970 +0000
119 119 summary: 0
120 120
121 121 changeset: 1:925d80f479bb
122 122 bookmark: X2
123 123 tag: tip
124 124 user: test
125 125 date: Thu Jan 01 00:00:00 1970 +0000
126 126 summary: 1
127 127
128 128 $ hg log -r 'bookmark("literal:X")'
129 129 changeset: 0:f7b1eb17ad24
130 130 bookmark: X
131 131 user: test
132 132 date: Thu Jan 01 00:00:00 1970 +0000
133 133 summary: 0
134 134
135 135
136 136 $ hg log -r 'bookmark(unknown)'
137 137 abort: bookmark 'unknown' does not exist!
138 138 [255]
139 139 $ hg log -r 'bookmark("literal:unknown")'
140 140 abort: bookmark 'unknown' does not exist!
141 141 [255]
142 142 $ hg log -r 'bookmark("re:unknown")'
143 143 abort: no bookmarks exist that match 'unknown'!
144 144 [255]
145 145 $ hg log -r 'present(bookmark("literal:unknown"))'
146 146 $ hg log -r 'present(bookmark("re:unknown"))'
147 147
148 148 $ hg help revsets | grep 'bookmark('
149 149 "bookmark([name])"
150 150
151 151 bookmarks X and X2 moved to rev 1, Y at rev -1
152 152
153 153 $ hg bookmarks
154 154 X 0:f7b1eb17ad24
155 155 * X2 1:925d80f479bb
156 156 Y -1:000000000000
157 157
158 158 bookmark rev 0 again
159 159
160 160 $ hg bookmark -r 0 Z
161 161
162 162 $ hg update X
163 163 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
164 164 (activating bookmark X)
165 165 $ echo c > c
166 166 $ hg add c
167 167 $ hg commit -m 2
168 168 created new head
169 169
170 170 bookmarks X moved to rev 2, Y at rev -1, Z at rev 0
171 171
172 172 $ hg bookmarks
173 173 * X 2:db815d6d32e6
174 174 X2 1:925d80f479bb
175 175 Y -1:000000000000
176 176 Z 0:f7b1eb17ad24
177 177
178 178 rename nonexistent bookmark
179 179
180 180 $ hg bookmark -m A B
181 181 abort: bookmark 'A' does not exist
182 182 [255]
183 183
184 184 rename to existent bookmark
185 185
186 186 $ hg bookmark -m X Y
187 187 abort: bookmark 'Y' already exists (use -f to force)
188 188 [255]
189 189
190 190 force rename to existent bookmark
191 191
192 192 $ hg bookmark -f -m X Y
193 193
194 194 list bookmarks
195 195
196 196 $ hg bookmark
197 197 X2 1:925d80f479bb
198 198 * Y 2:db815d6d32e6
199 199 Z 0:f7b1eb17ad24
200 200
201 201 bookmarks from a revset
202 202 $ hg bookmark -r '.^1' REVSET
203 203 $ hg bookmark -r ':tip' TIP
204 204 $ hg up -q TIP
205 205 $ hg bookmarks
206 206 REVSET 0:f7b1eb17ad24
207 207 * TIP 2:db815d6d32e6
208 208 X2 1:925d80f479bb
209 209 Y 2:db815d6d32e6
210 210 Z 0:f7b1eb17ad24
211 211
212 212 $ hg bookmark -d REVSET
213 213 $ hg bookmark -d TIP
214 214
215 215 rename without new name or multiple names
216 216
217 217 $ hg bookmark -m Y
218 218 abort: new bookmark name required
219 219 [255]
220 220 $ hg bookmark -m Y Y2 Y3
221 221 abort: only one new bookmark name allowed
222 222 [255]
223 223
224 224 delete without name
225 225
226 226 $ hg bookmark -d
227 227 abort: bookmark name required
228 228 [255]
229 229
230 230 delete nonexistent bookmark
231 231
232 232 $ hg bookmark -d A
233 233 abort: bookmark 'A' does not exist
234 234 [255]
235 235
236 236 bookmark name with spaces should be stripped
237 237
238 238 $ hg bookmark ' x y '
239 239
240 240 list bookmarks
241 241
242 242 $ hg bookmarks
243 243 X2 1:925d80f479bb
244 244 Y 2:db815d6d32e6
245 245 Z 0:f7b1eb17ad24
246 246 * x y 2:db815d6d32e6
247 247
248 248 look up stripped bookmark name
249 249
250 250 $ hg log -r '"x y"'
251 251 changeset: 2:db815d6d32e6
252 252 bookmark: Y
253 253 bookmark: x y
254 254 tag: tip
255 255 parent: 0:f7b1eb17ad24
256 256 user: test
257 257 date: Thu Jan 01 00:00:00 1970 +0000
258 258 summary: 2
259 259
260 260
261 261 reject bookmark name with newline
262 262
263 263 $ hg bookmark '
264 264 > '
265 265 abort: bookmark names cannot consist entirely of whitespace
266 266 [255]
267 267
268 268 $ hg bookmark -m Z '
269 269 > '
270 270 abort: bookmark names cannot consist entirely of whitespace
271 271 [255]
272 272
273 273 bookmark with reserved name
274 274
275 275 $ hg bookmark tip
276 276 abort: the name 'tip' is reserved
277 277 [255]
278 278
279 279 $ hg bookmark .
280 280 abort: the name '.' is reserved
281 281 [255]
282 282
283 283 $ hg bookmark null
284 284 abort: the name 'null' is reserved
285 285 [255]
286 286
287 287
288 288 bookmark with existing name
289 289
290 290 $ hg bookmark X2
291 291 abort: bookmark 'X2' already exists (use -f to force)
292 292 [255]
293 293
294 294 $ hg bookmark -m Y Z
295 295 abort: bookmark 'Z' already exists (use -f to force)
296 296 [255]
297 297
298 298 bookmark with name of branch
299 299
300 300 $ hg bookmark default
301 301 abort: a bookmark cannot have the name of an existing branch
302 302 [255]
303 303
304 304 $ hg bookmark -m Y default
305 305 abort: a bookmark cannot have the name of an existing branch
306 306 [255]
307 307
308 308 bookmark with integer name
309 309
310 310 $ hg bookmark 10
311 311 abort: cannot use an integer as a name
312 312 [255]
313 313
314 314 incompatible options
315 315
316 316 $ hg bookmark -m Y -d Z
317 317 abort: --delete and --rename are incompatible
318 318 [255]
319 319
320 320 $ hg bookmark -r 1 -d Z
321 321 abort: --rev is incompatible with --delete
322 322 [255]
323 323
324 324 $ hg bookmark -r 1 -m Z Y
325 325 abort: --rev is incompatible with --rename
326 326 [255]
327 327
328 328 force bookmark with existing name
329 329
330 330 $ hg bookmark -f X2
331 331
332 332 force bookmark back to where it was, should deactivate it
333 333
334 334 $ hg bookmark -fr1 X2
335 335 $ hg bookmarks
336 336 X2 1:925d80f479bb
337 337 Y 2:db815d6d32e6
338 338 Z 0:f7b1eb17ad24
339 339 x y 2:db815d6d32e6
340 340
341 341 forward bookmark to descendant without --force
342 342
343 343 $ hg bookmark Z
344 344 moving bookmark 'Z' forward from f7b1eb17ad24
345 345
346 346 list bookmarks
347 347
348 348 $ hg bookmark
349 349 X2 1:925d80f479bb
350 350 Y 2:db815d6d32e6
351 351 * Z 2:db815d6d32e6
352 352 x y 2:db815d6d32e6
353 353
354 354 revision but no bookmark name
355 355
356 356 $ hg bookmark -r .
357 357 abort: bookmark name required
358 358 [255]
359 359
360 360 bookmark name with whitespace only
361 361
362 362 $ hg bookmark ' '
363 363 abort: bookmark names cannot consist entirely of whitespace
364 364 [255]
365 365
366 366 $ hg bookmark -m Y ' '
367 367 abort: bookmark names cannot consist entirely of whitespace
368 368 [255]
369 369
370 370 invalid bookmark
371 371
372 372 $ hg bookmark 'foo:bar'
373 373 abort: ':' cannot be used in a name
374 374 [255]
375 375
376 376 $ hg bookmark 'foo
377 377 > bar'
378 378 abort: '\n' cannot be used in a name
379 379 [255]
380 380
381 381 the bookmark extension should be ignored now that it is part of core
382 382
383 383 $ echo "[extensions]" >> $HGRCPATH
384 384 $ echo "bookmarks=" >> $HGRCPATH
385 385 $ hg bookmarks
386 386 X2 1:925d80f479bb
387 387 Y 2:db815d6d32e6
388 388 * Z 2:db815d6d32e6
389 389 x y 2:db815d6d32e6
390 390
391 391 test summary
392 392
393 393 $ hg summary
394 394 parent: 2:db815d6d32e6 tip
395 395 2
396 396 branch: default
397 397 bookmarks: *Z Y x y
398 398 commit: (clean)
399 399 update: 1 new changesets, 2 branch heads (merge)
400 400 phases: 3 draft
401 401
402 402 test id
403 403
404 404 $ hg id
405 405 db815d6d32e6 tip Y/Z/x y
406 406
407 407 test rollback
408 408
409 409 $ echo foo > f1
410 410 $ hg bookmark tmp-rollback
411 411 $ hg ci -Amr
412 412 adding f1
413 413 $ hg bookmarks
414 414 X2 1:925d80f479bb
415 415 Y 2:db815d6d32e6
416 416 Z 2:db815d6d32e6
417 417 * tmp-rollback 3:2bf5cfec5864
418 418 x y 2:db815d6d32e6
419 419 $ hg rollback
420 420 repository tip rolled back to revision 2 (undo commit)
421 421 working directory now based on revision 2
422 422 $ hg bookmarks
423 423 X2 1:925d80f479bb
424 424 Y 2:db815d6d32e6
425 425 Z 2:db815d6d32e6
426 426 * tmp-rollback 2:db815d6d32e6
427 427 x y 2:db815d6d32e6
428 428 $ hg bookmark -f Z -r 1
429 429 $ hg rollback
430 430 repository tip rolled back to revision 2 (undo bookmark)
431 431 $ hg bookmarks
432 432 X2 1:925d80f479bb
433 433 Y 2:db815d6d32e6
434 434 Z 2:db815d6d32e6
435 435 * tmp-rollback 2:db815d6d32e6
436 436 x y 2:db815d6d32e6
437 437 $ hg bookmark -d tmp-rollback
438 438
439 439 activate bookmark on working dir parent without --force
440 440
441 441 $ hg bookmark --inactive Z
442 442 $ hg bookmark Z
443 443
444 444 test clone
445 445
446 446 $ hg bookmark -r 2 -i @
447 447 $ hg bookmark -r 2 -i a@
448 448 $ hg bookmarks
449 449 @ 2:db815d6d32e6
450 450 X2 1:925d80f479bb
451 451 Y 2:db815d6d32e6
452 452 * Z 2:db815d6d32e6
453 453 a@ 2:db815d6d32e6
454 454 x y 2:db815d6d32e6
455 455 $ hg clone . cloned-bookmarks
456 456 updating to bookmark @
457 457 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
458 458 $ hg -R cloned-bookmarks bookmarks
459 459 * @ 2:db815d6d32e6
460 460 X2 1:925d80f479bb
461 461 Y 2:db815d6d32e6
462 462 Z 2:db815d6d32e6
463 463 a@ 2:db815d6d32e6
464 464 x y 2:db815d6d32e6
465 465
466 466 test clone with pull protocol
467 467
468 468 $ hg clone --pull . cloned-bookmarks-pull
469 469 requesting all changes
470 470 adding changesets
471 471 adding manifests
472 472 adding file changes
473 473 added 3 changesets with 3 changes to 3 files (+1 heads)
474 474 updating to bookmark @
475 475 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
476 476 $ hg -R cloned-bookmarks-pull bookmarks
477 477 * @ 2:db815d6d32e6
478 478 X2 1:925d80f479bb
479 479 Y 2:db815d6d32e6
480 480 Z 2:db815d6d32e6
481 481 a@ 2:db815d6d32e6
482 482 x y 2:db815d6d32e6
483 483
484 484 delete multiple bookmarks at once
485 485
486 486 $ hg bookmark -d @ a@
487 487
488 488 test clone with a bookmark named "default" (issue3677)
489 489
490 490 $ hg bookmark -r 1 -f -i default
491 491 $ hg clone . cloned-bookmark-default
492 492 updating to branch default
493 493 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
494 494 $ hg -R cloned-bookmark-default bookmarks
495 495 X2 1:925d80f479bb
496 496 Y 2:db815d6d32e6
497 497 Z 2:db815d6d32e6
498 498 default 1:925d80f479bb
499 499 x y 2:db815d6d32e6
500 500 $ hg -R cloned-bookmark-default parents -q
501 501 2:db815d6d32e6
502 502 $ hg bookmark -d default
503 503
504 504 test clone with a specific revision
505 505
506 506 $ hg clone -r 925d80 . cloned-bookmarks-rev
507 507 adding changesets
508 508 adding manifests
509 509 adding file changes
510 510 added 2 changesets with 2 changes to 2 files
511 511 updating to branch default
512 512 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
513 513 $ hg -R cloned-bookmarks-rev bookmarks
514 514 X2 1:925d80f479bb
515 515
516 516 test clone with update to a bookmark
517 517
518 518 $ hg clone -u Z . ../cloned-bookmarks-update
519 519 updating to branch default
520 520 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
521 521 $ hg -R ../cloned-bookmarks-update bookmarks
522 522 X2 1:925d80f479bb
523 523 Y 2:db815d6d32e6
524 524 * Z 2:db815d6d32e6
525 525 x y 2:db815d6d32e6
526 526
527 527 create bundle with two heads
528 528
529 529 $ hg clone . tobundle
530 530 updating to branch default
531 531 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
532 532 $ echo x > tobundle/x
533 533 $ hg -R tobundle add tobundle/x
534 534 $ hg -R tobundle commit -m'x'
535 535 $ hg -R tobundle update -r -2
536 536 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
537 537 $ echo y > tobundle/y
538 538 $ hg -R tobundle branch test
539 539 marked working directory as branch test
540 540 (branches are permanent and global, did you want a bookmark?)
541 541 $ hg -R tobundle add tobundle/y
542 542 $ hg -R tobundle commit -m'y'
543 543 $ hg -R tobundle bundle tobundle.hg
544 544 searching for changes
545 545 2 changesets found
546 546 $ hg unbundle tobundle.hg
547 547 adding changesets
548 548 adding manifests
549 549 adding file changes
550 550 added 2 changesets with 2 changes to 2 files (+1 heads)
551 551 (run 'hg heads' to see heads, 'hg merge' to merge)
552 552
553 553 update to active bookmark if it's not the parent
554 554
555 555 $ hg summary
556 556 parent: 2:db815d6d32e6
557 557 2
558 558 branch: default
559 559 bookmarks: *Z Y x y
560 560 commit: 1 added, 1 unknown (new branch head)
561 561 update: 2 new changesets (update)
562 562 phases: 5 draft
563 563 $ hg update
564 564 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
565 565 updating bookmark Z
566 566 $ hg bookmarks
567 567 X2 1:925d80f479bb
568 568 Y 2:db815d6d32e6
569 569 * Z 3:125c9a1d6df6
570 570 x y 2:db815d6d32e6
571 571
572 572 pull --update works the same as pull && update
573 573
574 574 $ hg bookmark -r3 Y
575 575 moving bookmark 'Y' forward from db815d6d32e6
576 576 $ cp -R ../cloned-bookmarks-update ../cloned-bookmarks-manual-update
577 577 $ cp -R ../cloned-bookmarks-update ../cloned-bookmarks-manual-update-with-divergence
578 578
579 579 (manual version)
580 580
581 581 $ hg -R ../cloned-bookmarks-manual-update update Y
582 582 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
583 583 (activating bookmark Y)
584 584 $ hg -R ../cloned-bookmarks-manual-update pull .
585 585 pulling from .
586 586 searching for changes
587 587 adding changesets
588 588 adding manifests
589 589 adding file changes
590 590 added 2 changesets with 2 changes to 2 files (+1 heads)
591 591 updating bookmark Y
592 592 updating bookmark Z
593 593 (run 'hg heads' to see heads, 'hg merge' to merge)
594 594
595 595 (# tests strange but with --date crashing when bookmark have to move)
596 596
597 597 $ hg -R ../cloned-bookmarks-manual-update update -d 1986
598 598 abort: revision matching date not found
599 599 [255]
600 600 $ hg -R ../cloned-bookmarks-manual-update update
601 601 updating to active bookmark Y
602 602 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
603 603
604 604 (all in one version)
605 605
606 606 $ hg -R ../cloned-bookmarks-update update Y
607 607 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
608 608 (activating bookmark Y)
609 609 $ hg -R ../cloned-bookmarks-update pull --update .
610 610 pulling from .
611 611 searching for changes
612 612 adding changesets
613 613 adding manifests
614 614 adding file changes
615 615 added 2 changesets with 2 changes to 2 files (+1 heads)
616 616 updating bookmark Y
617 617 updating bookmark Z
618 618 updating to active bookmark Y
619 619 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
620 620
621 621 We warn about divergent during bare update to the active bookmark
622 622
623 623 $ hg -R ../cloned-bookmarks-manual-update-with-divergence update Y
624 624 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
625 625 (activating bookmark Y)
626 626 $ hg -R ../cloned-bookmarks-manual-update-with-divergence bookmarks -r X2 Y@1
627 627 $ hg -R ../cloned-bookmarks-manual-update-with-divergence bookmarks
628 628 X2 1:925d80f479bb
629 629 * Y 2:db815d6d32e6
630 630 Y@1 1:925d80f479bb
631 631 Z 2:db815d6d32e6
632 632 x y 2:db815d6d32e6
633 633 $ hg -R ../cloned-bookmarks-manual-update-with-divergence pull
634 634 pulling from $TESTTMP/repo (glob)
635 635 searching for changes
636 636 adding changesets
637 637 adding manifests
638 638 adding file changes
639 639 added 2 changesets with 2 changes to 2 files (+1 heads)
640 640 updating bookmark Y
641 641 updating bookmark Z
642 642 (run 'hg heads' to see heads, 'hg merge' to merge)
643 643 $ hg -R ../cloned-bookmarks-manual-update-with-divergence update
644 644 updating to active bookmark Y
645 645 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
646 646 1 other divergent bookmarks for "Y"
647 647
648 648 test wrongly formated bookmark
649 649
650 650 $ echo '' >> .hg/bookmarks
651 651 $ hg bookmarks
652 652 X2 1:925d80f479bb
653 653 Y 3:125c9a1d6df6
654 654 * Z 3:125c9a1d6df6
655 655 x y 2:db815d6d32e6
656 656 $ echo "Ican'thasformatedlines" >> .hg/bookmarks
657 657 $ hg bookmarks
658 658 malformed line in .hg/bookmarks: "Ican'thasformatedlines"
659 659 X2 1:925d80f479bb
660 660 Y 3:125c9a1d6df6
661 661 * Z 3:125c9a1d6df6
662 662 x y 2:db815d6d32e6
663 663
664 664 test missing revisions
665 665
666 666 $ echo "925d80f479bc z" > .hg/bookmarks
667 667 $ hg book
668 668 no bookmarks set
669 669
670 670 test stripping a non-checked-out but bookmarked revision
671 671
672 672 $ hg log --graph
673 673 o changeset: 4:9ba5f110a0b3
674 674 | branch: test
675 675 | tag: tip
676 676 | parent: 2:db815d6d32e6
677 677 | user: test
678 678 | date: Thu Jan 01 00:00:00 1970 +0000
679 679 | summary: y
680 680 |
681 681 | @ changeset: 3:125c9a1d6df6
682 682 |/ user: test
683 683 | date: Thu Jan 01 00:00:00 1970 +0000
684 684 | summary: x
685 685 |
686 686 o changeset: 2:db815d6d32e6
687 687 | parent: 0:f7b1eb17ad24
688 688 | user: test
689 689 | date: Thu Jan 01 00:00:00 1970 +0000
690 690 | summary: 2
691 691 |
692 692 | o changeset: 1:925d80f479bb
693 693 |/ user: test
694 694 | date: Thu Jan 01 00:00:00 1970 +0000
695 695 | summary: 1
696 696 |
697 697 o changeset: 0:f7b1eb17ad24
698 698 user: test
699 699 date: Thu Jan 01 00:00:00 1970 +0000
700 700 summary: 0
701 701
702 702 $ hg book should-end-on-two
703 703 $ hg co --clean 4
704 704 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
705 705 (leaving bookmark should-end-on-two)
706 706 $ hg book four
707 707 $ hg --config extensions.mq= strip 3
708 708 saved backup bundle to * (glob)
709 709 should-end-on-two should end up pointing to revision 2, as that's the
710 710 tipmost surviving ancestor of the stripped revision.
711 711 $ hg log --graph
712 712 @ changeset: 3:9ba5f110a0b3
713 713 | branch: test
714 714 | bookmark: four
715 715 | tag: tip
716 716 | user: test
717 717 | date: Thu Jan 01 00:00:00 1970 +0000
718 718 | summary: y
719 719 |
720 720 o changeset: 2:db815d6d32e6
721 721 | bookmark: should-end-on-two
722 722 | parent: 0:f7b1eb17ad24
723 723 | user: test
724 724 | date: Thu Jan 01 00:00:00 1970 +0000
725 725 | summary: 2
726 726 |
727 727 | o changeset: 1:925d80f479bb
728 728 |/ user: test
729 729 | date: Thu Jan 01 00:00:00 1970 +0000
730 730 | summary: 1
731 731 |
732 732 o changeset: 0:f7b1eb17ad24
733 733 user: test
734 734 date: Thu Jan 01 00:00:00 1970 +0000
735 735 summary: 0
736 736
737 737
738 738 no-op update doesn't deactivate bookmarks
739 739
740 740 $ hg bookmarks
741 741 * four 3:9ba5f110a0b3
742 742 should-end-on-two 2:db815d6d32e6
743 743 $ hg up four
744 744 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
745 745 $ hg up
746 746 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
747 747 $ hg sum
748 748 parent: 3:9ba5f110a0b3 tip
749 749 y
750 750 branch: test
751 751 bookmarks: *four
752 752 commit: 2 unknown (clean)
753 753 update: (current)
754 754 phases: 4 draft
755 755
756 756 test clearing divergent bookmarks of linear ancestors
757 757
758 758 $ hg bookmark Z -r 0
759 759 $ hg bookmark Z@1 -r 1
760 760 $ hg bookmark Z@2 -r 2
761 761 $ hg bookmark Z@3 -r 3
762 762 $ hg book
763 763 Z 0:f7b1eb17ad24
764 764 Z@1 1:925d80f479bb
765 765 Z@2 2:db815d6d32e6
766 766 Z@3 3:9ba5f110a0b3
767 767 * four 3:9ba5f110a0b3
768 768 should-end-on-two 2:db815d6d32e6
769 769 $ hg bookmark Z
770 770 moving bookmark 'Z' forward from f7b1eb17ad24
771 771 $ hg book
772 772 * Z 3:9ba5f110a0b3
773 773 Z@1 1:925d80f479bb
774 774 four 3:9ba5f110a0b3
775 775 should-end-on-two 2:db815d6d32e6
776 776
777 777 test clearing only a single divergent bookmark across branches
778 778
779 779 $ hg book foo -r 1
780 780 $ hg book foo@1 -r 0
781 781 $ hg book foo@2 -r 2
782 782 $ hg book foo@3 -r 3
783 783 $ hg book foo -r foo@3
784 784 $ hg book
785 785 * Z 3:9ba5f110a0b3
786 786 Z@1 1:925d80f479bb
787 787 foo 3:9ba5f110a0b3
788 788 foo@1 0:f7b1eb17ad24
789 789 foo@2 2:db815d6d32e6
790 790 four 3:9ba5f110a0b3
791 791 should-end-on-two 2:db815d6d32e6
792 792
793 793 pull --update works the same as pull && update (case #2)
794 794
795 795 It is assumed that "hg pull" itself doesn't update current active
796 796 bookmark ('Y' in tests below).
797 797
798 798 $ hg pull -q ../cloned-bookmarks-update
799 799 divergent bookmark Z stored as Z@2
800 800
801 801 (pulling revision on another named branch with --update updates
802 802 neither the working directory nor current active bookmark: "no-op"
803 803 case)
804 804
805 805 $ echo yy >> y
806 806 $ hg commit -m yy
807 807
808 808 $ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y '
809 809 * Y 3:125c9a1d6df6
810 810 $ hg -R ../cloned-bookmarks-update pull . --update
811 811 pulling from .
812 812 searching for changes
813 813 adding changesets
814 814 adding manifests
815 815 adding file changes
816 816 added 1 changesets with 1 changes to 1 files
817 817 divergent bookmark Z stored as Z@default
818 818 adding remote bookmark foo
819 819 adding remote bookmark four
820 820 adding remote bookmark should-end-on-two
821 821 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
822 822 $ hg -R ../cloned-bookmarks-update parents -T "{rev}:{node|short}\n"
823 823 3:125c9a1d6df6
824 824 $ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y '
825 825 * Y 3:125c9a1d6df6
826 826
827 827 (pulling revision on current named/topological branch with --update
828 828 updates the working directory and current active bookmark)
829 829
830 830 $ hg update -C -q 125c9a1d6df6
831 831 $ echo xx >> x
832 832 $ hg commit -m xx
833 833
834 834 $ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y '
835 835 * Y 3:125c9a1d6df6
836 836 $ hg -R ../cloned-bookmarks-update pull . --update
837 837 pulling from .
838 838 searching for changes
839 839 adding changesets
840 840 adding manifests
841 841 adding file changes
842 842 added 1 changesets with 1 changes to 1 files
843 843 divergent bookmark Z stored as Z@default
844 844 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
845 845 updating bookmark Y
846 846 $ hg -R ../cloned-bookmarks-update parents -T "{rev}:{node|short}\n"
847 847 6:81dcce76aa0b
848 848 $ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y '
849 849 * Y 6:81dcce76aa0b
850 850
851 851 $ cd ..
852 852
853 853 ensure changelog is written before bookmarks
854 854 $ hg init orderrepo
855 855 $ cd orderrepo
856 856 $ touch a
857 857 $ hg commit -Aqm one
858 858 $ hg book mybook
859 859 $ echo a > a
860 860
861 861 $ cat > $TESTTMP/pausefinalize.py <<EOF
862 862 > from mercurial import extensions, localrepo
863 863 > import os, time
864 864 > def transaction(orig, self, desc, report=None):
865 865 > tr = orig(self, desc, report)
866 866 > def sleep(*args, **kwargs):
867 867 > retry = 20
868 868 > while retry > 0 and not os.path.exists("$TESTTMP/unpause"):
869 869 > retry -= 1
870 870 > time.sleep(0.5)
871 871 > if os.path.exists("$TESTTMP/unpause"):
872 872 > os.remove("$TESTTMP/unpause")
873 873 > # It is important that this finalizer start with 'a', so it runs before
874 874 > # the changelog finalizer appends to the changelog.
875 875 > tr.addfinalize('a-sleep', sleep)
876 876 > return tr
877 877 >
878 878 > def extsetup(ui):
879 879 > # This extension inserts an artifical pause during the transaction
880 880 > # finalizer, so we can run commands mid-transaction-close.
881 881 > extensions.wrapfunction(localrepo.localrepository, 'transaction',
882 882 > transaction)
883 883 > EOF
884 884 $ hg commit -qm two --config extensions.pausefinalize=$TESTTMP/pausefinalize.py &
885 885 $ sleep 2
886 886 $ hg log -r .
887 887 changeset: 0:867bc5792c8c
888 888 bookmark: mybook
889 889 tag: tip
890 890 user: test
891 891 date: Thu Jan 01 00:00:00 1970 +0000
892 892 summary: one
893 893
894 894 $ hg bookmarks
895 895 * mybook 0:867bc5792c8c
896 896 $ touch $TESTTMP/unpause
897 897
898 898 $ cd ..
899 899
900 900 check whether HG_PENDING makes pending changes only in related
901 901 repositories visible to an external hook.
902 902
903 903 (emulate a transaction running concurrently by copied
904 904 .hg/bookmarks.pending in subsequent test)
905 905
906 906 $ cat > $TESTTMP/savepending.sh <<EOF
907 907 > cp .hg/bookmarks.pending .hg/bookmarks.pending.saved
908 908 > exit 1 # to avoid adding new bookmark for subsequent tests
909 909 > EOF
910 910
911 911 $ hg init unrelated
912 912 $ cd unrelated
913 913 $ echo a > a
914 914 $ hg add a
915 915 $ hg commit -m '#0'
916 916 $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" bookmarks INVISIBLE
917 917 transaction abort!
918 918 rollback completed
919 919 abort: pretxnclose hook exited with status 1
920 920 [255]
921 921 $ cp .hg/bookmarks.pending.saved .hg/bookmarks.pending
922 922
923 923 (check visible bookmarks while transaction running in repo)
924 924
925 925 $ cat > $TESTTMP/checkpending.sh <<EOF
926 926 > echo "@repo"
927 > hg -R $TESTTMP/repo bookmarks
927 > hg -R "$TESTTMP/repo" bookmarks
928 928 > echo "@unrelated"
929 > hg -R $TESTTMP/unrelated bookmarks
929 > hg -R "$TESTTMP/unrelated" bookmarks
930 930 > exit 1 # to avoid adding new bookmark for subsequent tests
931 931 > EOF
932 932
933 933 $ cd ../repo
934 934 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" bookmarks NEW
935 935 @repo
936 936 * NEW 6:81dcce76aa0b
937 937 X2 1:925d80f479bb
938 938 Y 4:125c9a1d6df6
939 939 Z 5:5fb12f0f2d51
940 940 Z@1 1:925d80f479bb
941 941 Z@2 4:125c9a1d6df6
942 942 foo 3:9ba5f110a0b3
943 943 foo@1 0:f7b1eb17ad24
944 944 foo@2 2:db815d6d32e6
945 945 four 3:9ba5f110a0b3
946 946 should-end-on-two 2:db815d6d32e6
947 947 x y 2:db815d6d32e6
948 948 @unrelated
949 949 no bookmarks set
950 950 transaction abort!
951 951 rollback completed
952 952 abort: pretxnclose hook exited with status 1
953 953 [255]
@@ -1,935 +1,935 b''
1 1 commit hooks can see env vars
2 2 (and post-transaction one are run unlocked)
3 3
4 4
5 5 $ cat > $TESTTMP/txnabort.checkargs.py <<EOF
6 6 > def showargs(ui, repo, hooktype, **kwargs):
7 7 > ui.write('%s python hook: %s\n' % (hooktype, ','.join(sorted(kwargs))))
8 8 > EOF
9 9
10 10 $ hg init a
11 11 $ cd a
12 12 $ cat > .hg/hgrc <<EOF
13 13 > [hooks]
14 14 > commit = sh -c "HG_LOCAL= HG_TAG= printenv.py commit"
15 15 > commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py commit.b"
16 16 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py precommit"
17 17 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxncommit"
18 18 > pretxncommit.tip = hg -q tip
19 19 > pre-identify = sh -c "printenv.py pre-identify 1"
20 20 > pre-cat = sh -c "printenv.py pre-cat"
21 21 > post-cat = sh -c "printenv.py post-cat"
22 22 > pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnopen"
23 23 > pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnclose"
24 24 > txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py txnclose"
25 25 > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
26 26 > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py txnabort"
27 27 > txnclose.checklock = sh -c "hg debuglock > /dev/null"
28 28 > EOF
29 29 $ echo a > a
30 30 $ hg add a
31 31 $ hg commit -m a
32 32 precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=0000000000000000000000000000000000000000
33 33 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
34 34 pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
35 35 0:cb9a9f314b8b
36 36 pretxnclose hook: HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
37 37 txnclose hook: HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_PHASES_MOVED=1 HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
38 38 commit hook: HG_HOOKNAME=commit HG_HOOKTYPE=commit HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
39 39 commit.b hook: HG_HOOKNAME=commit.b HG_HOOKTYPE=commit HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
40 40
41 41 $ hg clone . ../b
42 42 updating to branch default
43 43 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
44 44 $ cd ../b
45 45
46 46 changegroup hooks can see env vars
47 47
48 48 $ cat > .hg/hgrc <<EOF
49 49 > [hooks]
50 50 > prechangegroup = sh -c "printenv.py prechangegroup"
51 51 > changegroup = sh -c "printenv.py changegroup"
52 52 > incoming = sh -c "printenv.py incoming"
53 53 > EOF
54 54
55 55 pretxncommit and commit hooks can see both parents of merge
56 56
57 57 $ cd ../a
58 58 $ echo b >> a
59 59 $ hg commit -m a1 -d "1 0"
60 60 precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
61 61 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
62 62 pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
63 63 1:ab228980c14d
64 64 pretxnclose hook: HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
65 65 txnclose hook: HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
66 66 commit hook: HG_HOOKNAME=commit HG_HOOKTYPE=commit HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
67 67 commit.b hook: HG_HOOKNAME=commit.b HG_HOOKTYPE=commit HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
68 68 $ hg update -C 0
69 69 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
70 70 $ echo b > b
71 71 $ hg add b
72 72 $ hg commit -m b -d '1 0'
73 73 precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
74 74 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
75 75 pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
76 76 2:ee9deb46ab31
77 77 pretxnclose hook: HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
78 78 created new head
79 79 txnclose hook: HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
80 80 commit hook: HG_HOOKNAME=commit HG_HOOKTYPE=commit HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
81 81 commit.b hook: HG_HOOKNAME=commit.b HG_HOOKTYPE=commit HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
82 82 $ hg merge 1
83 83 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
84 84 (branch merge, don't forget to commit)
85 85 $ hg commit -m merge -d '2 0'
86 86 precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
87 87 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
88 88 pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
89 89 3:07f3376c1e65
90 90 pretxnclose hook: HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
91 91 txnclose hook: HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
92 92 commit hook: HG_HOOKNAME=commit HG_HOOKTYPE=commit HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
93 93 commit.b hook: HG_HOOKNAME=commit.b HG_HOOKTYPE=commit HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
94 94
95 95 test generic hooks
96 96
97 97 $ hg id
98 98 pre-identify hook: HG_ARGS=id HG_HOOKNAME=pre-identify HG_HOOKTYPE=pre-identify HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None} HG_PATS=[]
99 99 abort: pre-identify hook exited with status 1
100 100 [255]
101 101 $ hg cat b
102 102 pre-cat hook: HG_ARGS=cat b HG_HOOKNAME=pre-cat HG_HOOKTYPE=pre-cat HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b']
103 103 b
104 104 post-cat hook: HG_ARGS=cat b HG_HOOKNAME=post-cat HG_HOOKTYPE=post-cat HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0
105 105
106 106 $ cd ../b
107 107 $ hg pull ../a
108 108 pulling from ../a
109 109 searching for changes
110 110 prechangegroup hook: HG_HOOKNAME=prechangegroup HG_HOOKTYPE=prechangegroup HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
111 111 adding changesets
112 112 adding manifests
113 113 adding file changes
114 114 added 3 changesets with 2 changes to 2 files
115 115 changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_NODE_LAST=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
116 116 incoming hook: HG_HOOKNAME=incoming HG_HOOKTYPE=incoming HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
117 117 incoming hook: HG_HOOKNAME=incoming HG_HOOKTYPE=incoming HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
118 118 incoming hook: HG_HOOKNAME=incoming HG_HOOKTYPE=incoming HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
119 119 (run 'hg update' to get a working copy)
120 120
121 121 tag hooks can see env vars
122 122
123 123 $ cd ../a
124 124 $ cat >> .hg/hgrc <<EOF
125 125 > pretag = sh -c "printenv.py pretag"
126 126 > tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py tag"
127 127 > EOF
128 128 $ hg tag -d '3 0' a
129 129 pretag hook: HG_HOOKNAME=pretag HG_HOOKTYPE=pretag HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
130 130 precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
131 131 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
132 132 pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
133 133 4:539e4b31b6dc
134 134 pretxnclose hook: HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
135 135 tag hook: HG_HOOKNAME=tag HG_HOOKTYPE=tag HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
136 136 txnclose hook: HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
137 137 commit hook: HG_HOOKNAME=commit HG_HOOKTYPE=commit HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
138 138 commit.b hook: HG_HOOKNAME=commit.b HG_HOOKTYPE=commit HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
139 139 $ hg tag -l la
140 140 pretag hook: HG_HOOKNAME=pretag HG_HOOKTYPE=pretag HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
141 141 tag hook: HG_HOOKNAME=tag HG_HOOKTYPE=tag HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
142 142
143 143 pretag hook can forbid tagging
144 144
145 145 $ cat >> .hg/hgrc <<EOF
146 146 > pretag.forbid = sh -c "printenv.py pretag.forbid 1"
147 147 > EOF
148 148 $ hg tag -d '4 0' fa
149 149 pretag hook: HG_HOOKNAME=pretag HG_HOOKTYPE=pretag HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
150 150 pretag.forbid hook: HG_HOOKNAME=pretag.forbid HG_HOOKTYPE=pretag HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
151 151 abort: pretag.forbid hook exited with status 1
152 152 [255]
153 153 $ hg tag -l fla
154 154 pretag hook: HG_HOOKNAME=pretag HG_HOOKTYPE=pretag HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
155 155 pretag.forbid hook: HG_HOOKNAME=pretag.forbid HG_HOOKTYPE=pretag HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
156 156 abort: pretag.forbid hook exited with status 1
157 157 [255]
158 158
159 159 pretxncommit hook can see changeset, can roll back txn, changeset no
160 160 more there after
161 161
162 162 $ cat >> .hg/hgrc <<EOF
163 163 > pretxncommit.forbid0 = sh -c "hg tip -q"
164 164 > pretxncommit.forbid1 = sh -c "printenv.py pretxncommit.forbid 1"
165 165 > EOF
166 166 $ echo z > z
167 167 $ hg add z
168 168 $ hg -q tip
169 169 4:539e4b31b6dc
170 170 $ hg commit -m 'fail' -d '4 0'
171 171 precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
172 172 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
173 173 pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
174 174 5:6f611f8018c1
175 175 5:6f611f8018c1
176 176 pretxncommit.forbid hook: HG_HOOKNAME=pretxncommit.forbid1 HG_HOOKTYPE=pretxncommit HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
177 177 transaction abort!
178 178 txnabort python hook: txnid,txnname
179 179 txnabort hook: HG_HOOKNAME=txnabort.1 HG_HOOKTYPE=txnabort HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
180 180 rollback completed
181 181 abort: pretxncommit.forbid1 hook exited with status 1
182 182 [255]
183 183 $ hg -q tip
184 184 4:539e4b31b6dc
185 185
186 186 (Check that no 'changelog.i.a' file were left behind)
187 187
188 188 $ ls -1 .hg/store/
189 189 00changelog.i
190 190 00manifest.i
191 191 data
192 192 fncache
193 193 journal.phaseroots
194 194 phaseroots
195 195 undo
196 196 undo.backup.fncache
197 197 undo.backupfiles
198 198 undo.phaseroots
199 199
200 200
201 201 precommit hook can prevent commit
202 202
203 203 $ cat >> .hg/hgrc <<EOF
204 204 > precommit.forbid = sh -c "printenv.py precommit.forbid 1"
205 205 > EOF
206 206 $ hg commit -m 'fail' -d '4 0'
207 207 precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
208 208 precommit.forbid hook: HG_HOOKNAME=precommit.forbid HG_HOOKTYPE=precommit HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
209 209 abort: precommit.forbid hook exited with status 1
210 210 [255]
211 211 $ hg -q tip
212 212 4:539e4b31b6dc
213 213
214 214 preupdate hook can prevent update
215 215
216 216 $ cat >> .hg/hgrc <<EOF
217 217 > preupdate = sh -c "printenv.py preupdate"
218 218 > EOF
219 219 $ hg update 1
220 220 preupdate hook: HG_HOOKNAME=preupdate HG_HOOKTYPE=preupdate HG_PARENT1=ab228980c14d
221 221 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
222 222
223 223 update hook
224 224
225 225 $ cat >> .hg/hgrc <<EOF
226 226 > update = sh -c "printenv.py update"
227 227 > EOF
228 228 $ hg update
229 229 preupdate hook: HG_HOOKNAME=preupdate HG_HOOKTYPE=preupdate HG_PARENT1=539e4b31b6dc
230 230 update hook: HG_ERROR=0 HG_HOOKNAME=update HG_HOOKTYPE=update HG_PARENT1=539e4b31b6dc
231 231 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
232 232
233 233 pushkey hook
234 234
235 235 $ cat >> .hg/hgrc <<EOF
236 236 > pushkey = sh -c "printenv.py pushkey"
237 237 > EOF
238 238 $ cd ../b
239 239 $ hg bookmark -r null foo
240 240 $ hg push -B foo ../a
241 241 pushing to ../a
242 242 searching for changes
243 243 no changes found
244 244 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=push
245 245 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/a
246 246 pushkey hook: HG_HOOKNAME=pushkey HG_HOOKTYPE=pushkey HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
247 247 txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/a
248 248 exporting bookmark foo
249 249 [1]
250 250 $ cd ../a
251 251
252 252 listkeys hook
253 253
254 254 $ cat >> .hg/hgrc <<EOF
255 255 > listkeys = sh -c "printenv.py listkeys"
256 256 > EOF
257 257 $ hg bookmark -r null bar
258 258 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
259 259 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
260 260 txnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
261 261 $ cd ../b
262 262 $ hg pull -B bar ../a
263 263 pulling from ../a
264 264 listkeys hook: HG_HOOKNAME=listkeys HG_HOOKTYPE=listkeys HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
265 265 no changes found
266 266 listkeys hook: HG_HOOKNAME=listkeys HG_HOOKTYPE=listkeys HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
267 267 adding remote bookmark bar
268 268 $ cd ../a
269 269
270 270 test that prepushkey can prevent incoming keys
271 271
272 272 $ cat >> .hg/hgrc <<EOF
273 273 > prepushkey = sh -c "printenv.py prepushkey.forbid 1"
274 274 > EOF
275 275 $ cd ../b
276 276 $ hg bookmark -r null baz
277 277 $ hg push -B baz ../a
278 278 pushing to ../a
279 279 searching for changes
280 280 listkeys hook: HG_HOOKNAME=listkeys HG_HOOKTYPE=listkeys HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
281 281 listkeys hook: HG_HOOKNAME=listkeys HG_HOOKTYPE=listkeys HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
282 282 no changes found
283 283 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=push
284 284 prepushkey.forbid hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
285 285 pushkey-abort: prepushkey hook exited with status 1
286 286 abort: exporting bookmark baz failed!
287 287 [255]
288 288 $ cd ../a
289 289
290 290 test that prelistkeys can prevent listing keys
291 291
292 292 $ cat >> .hg/hgrc <<EOF
293 293 > prelistkeys = sh -c "printenv.py prelistkeys.forbid 1"
294 294 > EOF
295 295 $ hg bookmark -r null quux
296 296 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
297 297 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
298 298 txnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
299 299 $ cd ../b
300 300 $ hg pull -B quux ../a
301 301 pulling from ../a
302 302 prelistkeys.forbid hook: HG_HOOKNAME=prelistkeys HG_HOOKTYPE=prelistkeys HG_NAMESPACE=bookmarks
303 303 abort: prelistkeys hook exited with status 1
304 304 [255]
305 305 $ cd ../a
306 306 $ rm .hg/hgrc
307 307
308 308 prechangegroup hook can prevent incoming changes
309 309
310 310 $ cd ../b
311 311 $ hg -q tip
312 312 3:07f3376c1e65
313 313 $ cat > .hg/hgrc <<EOF
314 314 > [hooks]
315 315 > prechangegroup.forbid = sh -c "printenv.py prechangegroup.forbid 1"
316 316 > EOF
317 317 $ hg pull ../a
318 318 pulling from ../a
319 319 searching for changes
320 320 prechangegroup.forbid hook: HG_HOOKNAME=prechangegroup.forbid HG_HOOKTYPE=prechangegroup HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
321 321 abort: prechangegroup.forbid hook exited with status 1
322 322 [255]
323 323
324 324 pretxnchangegroup hook can see incoming changes, can roll back txn,
325 325 incoming changes no longer there after
326 326
327 327 $ cat > .hg/hgrc <<EOF
328 328 > [hooks]
329 329 > pretxnchangegroup.forbid0 = hg tip -q
330 330 > pretxnchangegroup.forbid1 = sh -c "printenv.py pretxnchangegroup.forbid 1"
331 331 > EOF
332 332 $ hg pull ../a
333 333 pulling from ../a
334 334 searching for changes
335 335 adding changesets
336 336 adding manifests
337 337 adding file changes
338 338 added 1 changesets with 1 changes to 1 files
339 339 4:539e4b31b6dc
340 340 pretxnchangegroup.forbid hook: HG_HOOKNAME=pretxnchangegroup.forbid1 HG_HOOKTYPE=pretxnchangegroup HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_NODE_LAST=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
341 341 transaction abort!
342 342 rollback completed
343 343 abort: pretxnchangegroup.forbid1 hook exited with status 1
344 344 [255]
345 345 $ hg -q tip
346 346 3:07f3376c1e65
347 347
348 348 outgoing hooks can see env vars
349 349
350 350 $ rm .hg/hgrc
351 351 $ cat > ../a/.hg/hgrc <<EOF
352 352 > [hooks]
353 353 > preoutgoing = sh -c "printenv.py preoutgoing"
354 354 > outgoing = sh -c "printenv.py outgoing"
355 355 > EOF
356 356 $ hg pull ../a
357 357 pulling from ../a
358 358 searching for changes
359 359 preoutgoing hook: HG_HOOKNAME=preoutgoing HG_HOOKTYPE=preoutgoing HG_SOURCE=pull
360 360 outgoing hook: HG_HOOKNAME=outgoing HG_HOOKTYPE=outgoing HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull
361 361 adding changesets
362 362 adding manifests
363 363 adding file changes
364 364 added 1 changesets with 1 changes to 1 files
365 365 adding remote bookmark quux
366 366 (run 'hg update' to get a working copy)
367 367 $ hg rollback
368 368 repository tip rolled back to revision 3 (undo pull)
369 369
370 370 preoutgoing hook can prevent outgoing changes
371 371
372 372 $ cat >> ../a/.hg/hgrc <<EOF
373 373 > preoutgoing.forbid = sh -c "printenv.py preoutgoing.forbid 1"
374 374 > EOF
375 375 $ hg pull ../a
376 376 pulling from ../a
377 377 searching for changes
378 378 preoutgoing hook: HG_HOOKNAME=preoutgoing HG_HOOKTYPE=preoutgoing HG_SOURCE=pull
379 379 preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid HG_HOOKTYPE=preoutgoing HG_SOURCE=pull
380 380 abort: preoutgoing.forbid hook exited with status 1
381 381 [255]
382 382
383 383 outgoing hooks work for local clones
384 384
385 385 $ cd ..
386 386 $ cat > a/.hg/hgrc <<EOF
387 387 > [hooks]
388 388 > preoutgoing = sh -c "printenv.py preoutgoing"
389 389 > outgoing = sh -c "printenv.py outgoing"
390 390 > EOF
391 391 $ hg clone a c
392 392 preoutgoing hook: HG_HOOKNAME=preoutgoing HG_HOOKTYPE=preoutgoing HG_SOURCE=clone
393 393 outgoing hook: HG_HOOKNAME=outgoing HG_HOOKTYPE=outgoing HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone
394 394 updating to branch default
395 395 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
396 396 $ rm -rf c
397 397
398 398 preoutgoing hook can prevent outgoing changes for local clones
399 399
400 400 $ cat >> a/.hg/hgrc <<EOF
401 401 > preoutgoing.forbid = sh -c "printenv.py preoutgoing.forbid 1"
402 402 > EOF
403 403 $ hg clone a zzz
404 404 preoutgoing hook: HG_HOOKNAME=preoutgoing HG_HOOKTYPE=preoutgoing HG_SOURCE=clone
405 405 preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid HG_HOOKTYPE=preoutgoing HG_SOURCE=clone
406 406 abort: preoutgoing.forbid hook exited with status 1
407 407 [255]
408 408
409 409 $ cd "$TESTTMP/b"
410 410
411 411 $ cat > hooktests.py <<EOF
412 412 > from mercurial import error
413 413 >
414 414 > uncallable = 0
415 415 >
416 416 > def printargs(args):
417 417 > args.pop('ui', None)
418 418 > args.pop('repo', None)
419 419 > a = list(args.items())
420 420 > a.sort()
421 421 > print 'hook args:'
422 422 > for k, v in a:
423 423 > print ' ', k, v
424 424 >
425 425 > def passhook(**args):
426 426 > printargs(args)
427 427 >
428 428 > def failhook(**args):
429 429 > printargs(args)
430 430 > return True
431 431 >
432 432 > class LocalException(Exception):
433 433 > pass
434 434 >
435 435 > def raisehook(**args):
436 436 > raise LocalException('exception from hook')
437 437 >
438 438 > def aborthook(**args):
439 439 > raise error.Abort('raise abort from hook')
440 440 >
441 441 > def brokenhook(**args):
442 442 > return 1 + {}
443 443 >
444 444 > def verbosehook(ui, **args):
445 445 > ui.note('verbose output from hook\n')
446 446 >
447 447 > def printtags(ui, repo, **args):
448 448 > print sorted(repo.tags())
449 449 >
450 450 > class container:
451 451 > unreachable = 1
452 452 > EOF
453 453
454 454 $ cat > syntaxerror.py << EOF
455 455 > (foo
456 456 > EOF
457 457
458 458 test python hooks
459 459
460 460 #if windows
461 461 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
462 462 #else
463 463 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
464 464 #endif
465 465 $ export PYTHONPATH
466 466
467 467 $ echo '[hooks]' > ../a/.hg/hgrc
468 468 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
469 469 $ hg pull ../a 2>&1 | grep 'raised an exception'
470 470 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
471 471
472 472 $ echo '[hooks]' > ../a/.hg/hgrc
473 473 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
474 474 $ hg pull ../a 2>&1 | grep 'raised an exception'
475 475 error: preoutgoing.raise hook raised an exception: exception from hook
476 476
477 477 $ echo '[hooks]' > ../a/.hg/hgrc
478 478 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
479 479 $ hg pull ../a
480 480 pulling from ../a
481 481 searching for changes
482 482 error: preoutgoing.abort hook failed: raise abort from hook
483 483 abort: raise abort from hook
484 484 [255]
485 485
486 486 $ echo '[hooks]' > ../a/.hg/hgrc
487 487 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
488 488 $ hg pull ../a
489 489 pulling from ../a
490 490 searching for changes
491 491 hook args:
492 492 hooktype preoutgoing
493 493 source pull
494 494 abort: preoutgoing.fail hook failed
495 495 [255]
496 496
497 497 $ echo '[hooks]' > ../a/.hg/hgrc
498 498 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
499 499 $ hg pull ../a
500 500 pulling from ../a
501 501 searching for changes
502 502 abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable
503 503 [255]
504 504
505 505 $ echo '[hooks]' > ../a/.hg/hgrc
506 506 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
507 507 $ hg pull ../a
508 508 pulling from ../a
509 509 searching for changes
510 510 abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined
511 511 [255]
512 512
513 513 $ echo '[hooks]' > ../a/.hg/hgrc
514 514 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
515 515 $ hg pull ../a
516 516 pulling from ../a
517 517 searching for changes
518 518 abort: preoutgoing.nomodule hook is invalid: "nomodule" not in a module
519 519 [255]
520 520
521 521 $ echo '[hooks]' > ../a/.hg/hgrc
522 522 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
523 523 $ hg pull ../a
524 524 pulling from ../a
525 525 searching for changes
526 526 abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed
527 527 (run with --traceback for stack trace)
528 528 [255]
529 529
530 530 $ echo '[hooks]' > ../a/.hg/hgrc
531 531 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
532 532 $ hg pull ../a
533 533 pulling from ../a
534 534 searching for changes
535 535 abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed
536 536 (run with --traceback for stack trace)
537 537 [255]
538 538
539 539 $ echo '[hooks]' > ../a/.hg/hgrc
540 540 $ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc
541 541 $ hg pull ../a
542 542 pulling from ../a
543 543 searching for changes
544 544 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
545 545 (run with --traceback for stack trace)
546 546 [255]
547 547
548 548 The second egrep is to filter out lines like ' ^', which are slightly
549 549 different between Python 2.6 and Python 2.7.
550 550 $ hg pull ../a --traceback 2>&1 | egrep -v '^( +File| [_a-zA-Z*(])' | egrep -v '^( )+(\^)?$'
551 551 pulling from ../a
552 552 searching for changes
553 553 exception from first failed import attempt:
554 554 Traceback (most recent call last):
555 555 SyntaxError: * (glob)
556 556 exception from second failed import attempt:
557 557 Traceback (most recent call last):
558 558 ImportError: No module named hgext_syntaxerror
559 559 Traceback (most recent call last):
560 560 HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
561 561 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
562 562
563 563 $ echo '[hooks]' > ../a/.hg/hgrc
564 564 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
565 565 $ hg pull ../a
566 566 pulling from ../a
567 567 searching for changes
568 568 hook args:
569 569 hooktype preoutgoing
570 570 source pull
571 571 adding changesets
572 572 adding manifests
573 573 adding file changes
574 574 added 1 changesets with 1 changes to 1 files
575 575 adding remote bookmark quux
576 576 (run 'hg update' to get a working copy)
577 577
578 578 post- python hooks that fail to *run* don't cause an abort
579 579 $ rm ../a/.hg/hgrc
580 580 $ echo '[hooks]' > .hg/hgrc
581 581 $ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc
582 582 $ hg pull ../a
583 583 pulling from ../a
584 584 searching for changes
585 585 no changes found
586 586 error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
587 587 (run with --traceback for stack trace)
588 588
589 589 but post- python hooks that fail to *load* do
590 590 $ echo '[hooks]' > .hg/hgrc
591 591 $ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc
592 592 $ hg pull ../a
593 593 pulling from ../a
594 594 searching for changes
595 595 no changes found
596 596 abort: post-pull.nomodule hook is invalid: "nomodule" not in a module
597 597 [255]
598 598
599 599 $ echo '[hooks]' > .hg/hgrc
600 600 $ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc
601 601 $ hg pull ../a
602 602 pulling from ../a
603 603 searching for changes
604 604 no changes found
605 605 abort: post-pull.badmodule hook is invalid: import of "nomodule" failed
606 606 (run with --traceback for stack trace)
607 607 [255]
608 608
609 609 $ echo '[hooks]' > .hg/hgrc
610 610 $ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc
611 611 $ hg pull ../a
612 612 pulling from ../a
613 613 searching for changes
614 614 no changes found
615 615 abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined
616 616 [255]
617 617
618 618 make sure --traceback works
619 619
620 620 $ echo '[hooks]' > .hg/hgrc
621 621 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
622 622
623 623 $ echo aa > a
624 624 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
625 625 Traceback (most recent call last):
626 626
627 627 $ cd ..
628 628 $ hg init c
629 629 $ cd c
630 630
631 631 $ cat > hookext.py <<EOF
632 632 > def autohook(**args):
633 633 > print "Automatically installed hook"
634 634 >
635 635 > def reposetup(ui, repo):
636 636 > repo.ui.setconfig("hooks", "commit.auto", autohook)
637 637 > EOF
638 638 $ echo '[extensions]' >> .hg/hgrc
639 639 $ echo 'hookext = hookext.py' >> .hg/hgrc
640 640
641 641 $ touch foo
642 642 $ hg add foo
643 643 $ hg ci -d '0 0' -m 'add foo'
644 644 Automatically installed hook
645 645 $ echo >> foo
646 646 $ hg ci --debug -d '0 0' -m 'change foo'
647 647 committing files:
648 648 foo
649 649 committing manifest
650 650 committing changelog
651 651 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
652 652 calling hook commit.auto: hgext_hookext.autohook
653 653 Automatically installed hook
654 654
655 655 $ hg showconfig hooks
656 656 hooks.commit.auto=<function autohook at *> (glob)
657 657
658 658 test python hook configured with python:[file]:[hook] syntax
659 659
660 660 $ cd ..
661 661 $ mkdir d
662 662 $ cd d
663 663 $ hg init repo
664 664 $ mkdir hooks
665 665
666 666 $ cd hooks
667 667 $ cat > testhooks.py <<EOF
668 668 > def testhook(**args):
669 669 > print 'hook works'
670 670 > EOF
671 671 $ echo '[hooks]' > ../repo/.hg/hgrc
672 672 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
673 673
674 674 $ cd ../repo
675 675 $ hg commit -d '0 0'
676 676 hook works
677 677 nothing changed
678 678 [1]
679 679
680 680 $ echo '[hooks]' > .hg/hgrc
681 681 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
682 682 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
683 683
684 684 $ hg up null
685 685 loading update.ne hook failed:
686 686 abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py
687 687 [255]
688 688
689 689 $ hg id
690 690 loading pre-identify.npmd hook failed:
691 691 abort: No module named repo!
692 692 [255]
693 693
694 694 $ cd ../../b
695 695
696 696 make sure --traceback works on hook import failure
697 697
698 698 $ cat > importfail.py <<EOF
699 699 > import somebogusmodule
700 700 > # dereference something in the module to force demandimport to load it
701 701 > somebogusmodule.whatever
702 702 > EOF
703 703
704 704 $ echo '[hooks]' > .hg/hgrc
705 705 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
706 706
707 707 $ echo a >> a
708 708 $ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])'
709 709 exception from first failed import attempt:
710 710 Traceback (most recent call last):
711 711 ImportError: No module named somebogusmodule
712 712 exception from second failed import attempt:
713 713 Traceback (most recent call last):
714 714 ImportError: No module named hgext_importfail
715 715 Traceback (most recent call last):
716 716 HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed
717 717 abort: precommit.importfail hook is invalid: import of "importfail" failed
718 718
719 719 Issue1827: Hooks Update & Commit not completely post operation
720 720
721 721 commit and update hooks should run after command completion. The largefiles
722 722 use demonstrates a recursive wlock, showing the hook doesn't run until the
723 723 final release (and dirstate flush).
724 724
725 725 $ echo '[hooks]' > .hg/hgrc
726 726 $ echo 'commit = hg id' >> .hg/hgrc
727 727 $ echo 'update = hg id' >> .hg/hgrc
728 728 $ echo bb > a
729 729 $ hg ci -ma
730 730 223eafe2750c tip
731 731 $ hg up 0 --config extensions.largefiles=
732 732 cb9a9f314b8b
733 733 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
734 734
735 735 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
736 736 that is passed to pre/post hooks
737 737
738 738 $ echo '[hooks]' > .hg/hgrc
739 739 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
740 740 $ hg id
741 741 cb9a9f314b8b
742 742 $ hg id --verbose
743 743 calling hook pre-identify: hooktests.verbosehook
744 744 verbose output from hook
745 745 cb9a9f314b8b
746 746
747 747 Ensure hooks can be prioritized
748 748
749 749 $ echo '[hooks]' > .hg/hgrc
750 750 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
751 751 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
752 752 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
753 753 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
754 754 $ hg id --verbose
755 755 calling hook pre-identify.b: hooktests.verbosehook
756 756 verbose output from hook
757 757 calling hook pre-identify.a: hooktests.verbosehook
758 758 verbose output from hook
759 759 calling hook pre-identify.c: hooktests.verbosehook
760 760 verbose output from hook
761 761 cb9a9f314b8b
762 762
763 763 new tags must be visible in pretxncommit (issue3210)
764 764
765 765 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
766 766 $ hg tag -f foo
767 767 ['a', 'foo', 'tip']
768 768
769 769 post-init hooks must not crash (issue4983)
770 770 This also creates the `to` repo for the next test block.
771 771
772 772 $ cd ..
773 773 $ cat << EOF >> hgrc-with-post-init-hook
774 774 > [hooks]
775 775 > post-init = sh -c "printenv.py post-init"
776 776 > EOF
777 777 $ HGRCPATH=hgrc-with-post-init-hook hg init to
778 778 post-init hook: HG_ARGS=init to HG_HOOKNAME=post-init HG_HOOKTYPE=post-init HG_OPTS={'insecure': None, 'remotecmd': '', 'ssh': ''} HG_PATS=['to'] HG_RESULT=0
779 779
780 780 new commits must be visible in pretxnchangegroup (issue3428)
781 781
782 782 $ echo '[hooks]' >> to/.hg/hgrc
783 783 $ echo 'prechangegroup = hg --traceback tip' >> to/.hg/hgrc
784 784 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
785 785 $ echo a >> to/a
786 786 $ hg --cwd to ci -Ama
787 787 adding a
788 788 $ hg clone to from
789 789 updating to branch default
790 790 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
791 791 $ echo aa >> from/a
792 792 $ hg --cwd from ci -mb
793 793 $ hg --cwd from push
794 794 pushing to $TESTTMP/to (glob)
795 795 searching for changes
796 796 changeset: 0:cb9a9f314b8b
797 797 tag: tip
798 798 user: test
799 799 date: Thu Jan 01 00:00:00 1970 +0000
800 800 summary: a
801 801
802 802 adding changesets
803 803 adding manifests
804 804 adding file changes
805 805 added 1 changesets with 1 changes to 1 files
806 806 changeset: 1:9836a07b9b9d
807 807 tag: tip
808 808 user: test
809 809 date: Thu Jan 01 00:00:00 1970 +0000
810 810 summary: b
811 811
812 812
813 813 pretxnclose hook failure should abort the transaction
814 814
815 815 $ hg init txnfailure
816 816 $ cd txnfailure
817 817 $ touch a && hg commit -Aqm a
818 818 $ cat >> .hg/hgrc <<EOF
819 819 > [hooks]
820 820 > pretxnclose.error = exit 1
821 821 > EOF
822 822 $ hg strip -r 0 --config extensions.strip=
823 823 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
824 824 saved backup bundle to * (glob)
825 825 transaction abort!
826 826 rollback completed
827 827 strip failed, backup bundle stored in * (glob)
828 828 abort: pretxnclose.error hook exited with status 1
829 829 [255]
830 830 $ hg recover
831 831 no interrupted transaction available
832 832 [1]
833 833 $ cd ..
834 834
835 835 check whether HG_PENDING makes pending changes only in related
836 836 repositories visible to an external hook.
837 837
838 838 (emulate a transaction running concurrently by copied
839 839 .hg/store/00changelog.i.a in subsequent test)
840 840
841 841 $ cat > $TESTTMP/savepending.sh <<EOF
842 842 > cp .hg/store/00changelog.i.a .hg/store/00changelog.i.a.saved
843 843 > exit 1 # to avoid adding new revision for subsequent tests
844 844 > EOF
845 845 $ cd a
846 846 $ hg tip -q
847 847 4:539e4b31b6dc
848 848 $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" commit -m "invisible"
849 849 transaction abort!
850 850 rollback completed
851 851 abort: pretxnclose hook exited with status 1
852 852 [255]
853 853 $ cp .hg/store/00changelog.i.a.saved .hg/store/00changelog.i.a
854 854
855 855 (check (in)visibility of new changeset while transaction running in
856 856 repo)
857 857
858 858 $ cat > $TESTTMP/checkpending.sh <<EOF
859 859 > echo '@a'
860 > hg -R $TESTTMP/a tip -q
860 > hg -R "$TESTTMP/a" tip -q
861 861 > echo '@a/nested'
862 > hg -R $TESTTMP/a/nested tip -q
862 > hg -R "$TESTTMP/a/nested" tip -q
863 863 > exit 1 # to avoid adding new revision for subsequent tests
864 864 > EOF
865 865 $ hg init nested
866 866 $ cd nested
867 867 $ echo a > a
868 868 $ hg add a
869 869 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" commit -m '#0'
870 870 @a
871 871 4:539e4b31b6dc
872 872 @a/nested
873 873 0:bf5e395ced2c
874 874 transaction abort!
875 875 rollback completed
876 876 abort: pretxnclose hook exited with status 1
877 877 [255]
878 878
879 879 Hook from untrusted hgrc are reported as failure
880 880 ================================================
881 881
882 882 $ cat << EOF > $TESTTMP/untrusted.py
883 883 > from mercurial import scmutil, util
884 884 > def uisetup(ui):
885 885 > class untrustedui(ui.__class__):
886 886 > def _trusted(self, fp, f):
887 887 > if util.normpath(fp.name).endswith('untrusted/.hg/hgrc'):
888 888 > return False
889 889 > return super(untrustedui, self)._trusted(fp, f)
890 890 > ui.__class__ = untrustedui
891 891 > EOF
892 892 $ cat << EOF >> $HGRCPATH
893 893 > [extensions]
894 894 > untrusted=$TESTTMP/untrusted.py
895 895 > EOF
896 896 $ hg init untrusted
897 897 $ cd untrusted
898 898
899 899 Non-blocking hook
900 900 -----------------
901 901
902 902 $ cat << EOF >> .hg/hgrc
903 903 > [hooks]
904 904 > txnclose.testing=echo txnclose hook called
905 905 > EOF
906 906 $ touch a && hg commit -Aqm a
907 907 warning: untrusted hook txnclose.testing not executed
908 908 $ hg log
909 909 changeset: 0:3903775176ed
910 910 tag: tip
911 911 user: test
912 912 date: Thu Jan 01 00:00:00 1970 +0000
913 913 summary: a
914 914
915 915
916 916 Non-blocking hook
917 917 -----------------
918 918
919 919 $ cat << EOF >> .hg/hgrc
920 920 > [hooks]
921 921 > pretxnclose.testing=echo pre-txnclose hook called
922 922 > EOF
923 923 $ touch b && hg commit -Aqm a
924 924 transaction abort!
925 925 rollback completed
926 926 abort: untrusted hook pretxnclose.testing not executed
927 927 (see 'hg help config.trusted')
928 928 [255]
929 929 $ hg log
930 930 changeset: 0:3903775176ed
931 931 tag: tip
932 932 user: test
933 933 date: Thu Jan 01 00:00:00 1970 +0000
934 934 summary: a
935 935
@@ -1,628 +1,628 b''
1 1 $ hglog() { hg log --template "{rev} {phaseidx} {desc}\n" $*; }
2 2 $ mkcommit() {
3 3 > echo "$1" > "$1"
4 4 > hg add "$1"
5 5 > message="$1"
6 6 > shift
7 7 > hg ci -m "$message" $*
8 8 > }
9 9
10 10 $ hg init initialrepo
11 11 $ cd initialrepo
12 12
13 13 Cannot change null revision phase
14 14
15 15 $ hg phase --force --secret null
16 16 abort: cannot change null revision phase
17 17 [255]
18 18 $ hg phase null
19 19 -1: public
20 20
21 21 $ mkcommit A
22 22
23 23 New commit are draft by default
24 24
25 25 $ hglog
26 26 0 1 A
27 27
28 28 Following commit are draft too
29 29
30 30 $ mkcommit B
31 31
32 32 $ hglog
33 33 1 1 B
34 34 0 1 A
35 35
36 36 Draft commit are properly created over public one:
37 37
38 38 $ hg phase --public .
39 39 $ hg phase
40 40 1: public
41 41 $ hglog
42 42 1 0 B
43 43 0 0 A
44 44
45 45 $ mkcommit C
46 46 $ mkcommit D
47 47
48 48 $ hglog
49 49 3 1 D
50 50 2 1 C
51 51 1 0 B
52 52 0 0 A
53 53
54 54 Test creating changeset as secret
55 55
56 56 $ mkcommit E --config phases.new-commit='secret'
57 57 $ hglog
58 58 4 2 E
59 59 3 1 D
60 60 2 1 C
61 61 1 0 B
62 62 0 0 A
63 63
64 64 Test the secret property is inherited
65 65
66 66 $ mkcommit H
67 67 $ hglog
68 68 5 2 H
69 69 4 2 E
70 70 3 1 D
71 71 2 1 C
72 72 1 0 B
73 73 0 0 A
74 74
75 75 Even on merge
76 76
77 77 $ hg up -q 1
78 78 $ mkcommit "B'"
79 79 created new head
80 80 $ hglog
81 81 6 1 B'
82 82 5 2 H
83 83 4 2 E
84 84 3 1 D
85 85 2 1 C
86 86 1 0 B
87 87 0 0 A
88 88 $ hg merge 4 # E
89 89 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
90 90 (branch merge, don't forget to commit)
91 91 $ hg phase
92 92 6: draft
93 93 4: secret
94 94 $ hg ci -m "merge B' and E"
95 95 $ hglog
96 96 7 2 merge B' and E
97 97 6 1 B'
98 98 5 2 H
99 99 4 2 E
100 100 3 1 D
101 101 2 1 C
102 102 1 0 B
103 103 0 0 A
104 104
105 105 Test secret changeset are not pushed
106 106
107 107 $ hg init ../push-dest
108 108 $ cat > ../push-dest/.hg/hgrc << EOF
109 109 > [phases]
110 110 > publish=False
111 111 > EOF
112 112 $ hg outgoing ../push-dest --template='{rev} {phase} {desc|firstline}\n'
113 113 comparing with ../push-dest
114 114 searching for changes
115 115 0 public A
116 116 1 public B
117 117 2 draft C
118 118 3 draft D
119 119 6 draft B'
120 120 $ hg outgoing -r 'branch(default)' ../push-dest --template='{rev} {phase} {desc|firstline}\n'
121 121 comparing with ../push-dest
122 122 searching for changes
123 123 0 public A
124 124 1 public B
125 125 2 draft C
126 126 3 draft D
127 127 6 draft B'
128 128
129 129 $ hg push ../push-dest -f # force because we push multiple heads
130 130 pushing to ../push-dest
131 131 searching for changes
132 132 adding changesets
133 133 adding manifests
134 134 adding file changes
135 135 added 5 changesets with 5 changes to 5 files (+1 heads)
136 136 $ hglog
137 137 7 2 merge B' and E
138 138 6 1 B'
139 139 5 2 H
140 140 4 2 E
141 141 3 1 D
142 142 2 1 C
143 143 1 0 B
144 144 0 0 A
145 145 $ cd ../push-dest
146 146 $ hglog
147 147 4 1 B'
148 148 3 1 D
149 149 2 1 C
150 150 1 0 B
151 151 0 0 A
152 152
153 153 (Issue3303)
154 154 Check that remote secret changeset are ignore when checking creation of remote heads
155 155
156 156 We add a secret head into the push destination. This secret head shadows a
157 157 visible shared between the initial repo and the push destination.
158 158
159 159 $ hg up -q 4 # B'
160 160 $ mkcommit Z --config phases.new-commit=secret
161 161 $ hg phase .
162 162 5: secret
163 163
164 164 We now try to push a new public changeset that descend from the common public
165 165 head shadowed by the remote secret head.
166 166
167 167 $ cd ../initialrepo
168 168 $ hg up -q 6 #B'
169 169 $ mkcommit I
170 170 created new head
171 171 $ hg push ../push-dest
172 172 pushing to ../push-dest
173 173 searching for changes
174 174 adding changesets
175 175 adding manifests
176 176 adding file changes
177 177 added 1 changesets with 1 changes to 1 files (+1 heads)
178 178
179 179 :note: The "(+1 heads)" is wrong as we do not had any visible head
180 180
181 181 check that branch cache with "served" filter are properly computed and stored
182 182
183 183 $ ls ../push-dest/.hg/cache/branch2*
184 184 ../push-dest/.hg/cache/branch2-served
185 185 $ cat ../push-dest/.hg/cache/branch2-served
186 186 6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722
187 187 b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default
188 188 6d6770faffce199f1fddd1cf87f6f026138cf061 o default
189 189 $ hg heads -R ../push-dest --template '{rev}:{node} {phase}\n' #update visible cache too
190 190 6:6d6770faffce199f1fddd1cf87f6f026138cf061 draft
191 191 5:2713879da13d6eea1ff22b442a5a87cb31a7ce6a secret
192 192 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e draft
193 193 $ ls ../push-dest/.hg/cache/branch2*
194 194 ../push-dest/.hg/cache/branch2-served
195 195 ../push-dest/.hg/cache/branch2-visible
196 196 $ cat ../push-dest/.hg/cache/branch2-served
197 197 6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722
198 198 b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default
199 199 6d6770faffce199f1fddd1cf87f6f026138cf061 o default
200 200 $ cat ../push-dest/.hg/cache/branch2-visible
201 201 6d6770faffce199f1fddd1cf87f6f026138cf061 6
202 202 b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default
203 203 2713879da13d6eea1ff22b442a5a87cb31a7ce6a o default
204 204 6d6770faffce199f1fddd1cf87f6f026138cf061 o default
205 205
206 206
207 207 Restore condition prior extra insertion.
208 208 $ hg -q --config extensions.mq= strip .
209 209 $ hg up -q 7
210 210 $ cd ..
211 211
212 212 Test secret changeset are not pull
213 213
214 214 $ hg init pull-dest
215 215 $ cd pull-dest
216 216 $ hg pull ../initialrepo
217 217 pulling from ../initialrepo
218 218 requesting all changes
219 219 adding changesets
220 220 adding manifests
221 221 adding file changes
222 222 added 5 changesets with 5 changes to 5 files (+1 heads)
223 223 (run 'hg heads' to see heads, 'hg merge' to merge)
224 224 $ hglog
225 225 4 0 B'
226 226 3 0 D
227 227 2 0 C
228 228 1 0 B
229 229 0 0 A
230 230 $ cd ..
231 231
232 232 But secret can still be bundled explicitly
233 233
234 234 $ cd initialrepo
235 235 $ hg bundle --base '4^' -r 'children(4)' ../secret-bundle.hg
236 236 4 changesets found
237 237 $ cd ..
238 238
239 239 Test secret changeset are not cloned
240 240 (during local clone)
241 241
242 242 $ hg clone -qU initialrepo clone-dest
243 243 $ hglog -R clone-dest
244 244 4 0 B'
245 245 3 0 D
246 246 2 0 C
247 247 1 0 B
248 248 0 0 A
249 249
250 250 Test summary
251 251
252 252 $ hg summary -R clone-dest --verbose
253 253 parent: -1:000000000000 (no revision checked out)
254 254 branch: default
255 255 commit: (clean)
256 256 update: 5 new changesets (update)
257 257 $ hg summary -R initialrepo
258 258 parent: 7:17a481b3bccb tip
259 259 merge B' and E
260 260 branch: default
261 261 commit: (clean) (secret)
262 262 update: 1 new changesets, 2 branch heads (merge)
263 263 phases: 3 draft, 3 secret
264 264 $ hg summary -R initialrepo --quiet
265 265 parent: 7:17a481b3bccb tip
266 266 update: 1 new changesets, 2 branch heads (merge)
267 267
268 268 Test revset
269 269
270 270 $ cd initialrepo
271 271 $ hglog -r 'public()'
272 272 0 0 A
273 273 1 0 B
274 274 $ hglog -r 'draft()'
275 275 2 1 C
276 276 3 1 D
277 277 6 1 B'
278 278 $ hglog -r 'secret()'
279 279 4 2 E
280 280 5 2 H
281 281 7 2 merge B' and E
282 282
283 283 test that phase are displayed in log at debug level
284 284
285 285 $ hg log --debug
286 286 changeset: 7:17a481b3bccb796c0521ae97903d81c52bfee4af
287 287 tag: tip
288 288 phase: secret
289 289 parent: 6:cf9fe039dfd67e829edf6522a45de057b5c86519
290 290 parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde
291 291 manifest: 7:5e724ffacba267b2ab726c91fc8b650710deaaa8
292 292 user: test
293 293 date: Thu Jan 01 00:00:00 1970 +0000
294 294 files+: C D E
295 295 extra: branch=default
296 296 description:
297 297 merge B' and E
298 298
299 299
300 300 changeset: 6:cf9fe039dfd67e829edf6522a45de057b5c86519
301 301 phase: draft
302 302 parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56
303 303 parent: -1:0000000000000000000000000000000000000000
304 304 manifest: 6:ab8bfef2392903058bf4ebb9e7746e8d7026b27a
305 305 user: test
306 306 date: Thu Jan 01 00:00:00 1970 +0000
307 307 files+: B'
308 308 extra: branch=default
309 309 description:
310 310 B'
311 311
312 312
313 313 changeset: 5:a030c6be5127abc010fcbff1851536552e6951a8
314 314 phase: secret
315 315 parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde
316 316 parent: -1:0000000000000000000000000000000000000000
317 317 manifest: 5:5c710aa854874fe3d5fa7192e77bdb314cc08b5a
318 318 user: test
319 319 date: Thu Jan 01 00:00:00 1970 +0000
320 320 files+: H
321 321 extra: branch=default
322 322 description:
323 323 H
324 324
325 325
326 326 changeset: 4:a603bfb5a83e312131cebcd05353c217d4d21dde
327 327 phase: secret
328 328 parent: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e
329 329 parent: -1:0000000000000000000000000000000000000000
330 330 manifest: 4:7173fd1c27119750b959e3a0f47ed78abe75d6dc
331 331 user: test
332 332 date: Thu Jan 01 00:00:00 1970 +0000
333 333 files+: E
334 334 extra: branch=default
335 335 description:
336 336 E
337 337
338 338
339 339 changeset: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e
340 340 phase: draft
341 341 parent: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757
342 342 parent: -1:0000000000000000000000000000000000000000
343 343 manifest: 3:6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c
344 344 user: test
345 345 date: Thu Jan 01 00:00:00 1970 +0000
346 346 files+: D
347 347 extra: branch=default
348 348 description:
349 349 D
350 350
351 351
352 352 changeset: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757
353 353 phase: draft
354 354 parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56
355 355 parent: -1:0000000000000000000000000000000000000000
356 356 manifest: 2:66a5a01817fdf5239c273802b5b7618d051c89e4
357 357 user: test
358 358 date: Thu Jan 01 00:00:00 1970 +0000
359 359 files+: C
360 360 extra: branch=default
361 361 description:
362 362 C
363 363
364 364
365 365 changeset: 1:27547f69f25460a52fff66ad004e58da7ad3fb56
366 366 phase: public
367 367 parent: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256
368 368 parent: -1:0000000000000000000000000000000000000000
369 369 manifest: 1:cb5cbbc1bfbf24cc34b9e8c16914e9caa2d2a7fd
370 370 user: test
371 371 date: Thu Jan 01 00:00:00 1970 +0000
372 372 files+: B
373 373 extra: branch=default
374 374 description:
375 375 B
376 376
377 377
378 378 changeset: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256
379 379 phase: public
380 380 parent: -1:0000000000000000000000000000000000000000
381 381 parent: -1:0000000000000000000000000000000000000000
382 382 manifest: 0:007d8c9d88841325f5c6b06371b35b4e8a2b1a83
383 383 user: test
384 384 date: Thu Jan 01 00:00:00 1970 +0000
385 385 files+: A
386 386 extra: branch=default
387 387 description:
388 388 A
389 389
390 390
391 391
392 392
393 393 (Issue3707)
394 394 test invalid phase name
395 395
396 396 $ mkcommit I --config phases.new-commit='babar'
397 397 transaction abort!
398 398 rollback completed
399 399 abort: phases.new-commit: not a valid phase name ('babar')
400 400 [255]
401 401 Test phase command
402 402 ===================
403 403
404 404 initial picture
405 405
406 406 $ hg log -G --template "{rev} {phase} {desc}\n"
407 407 @ 7 secret merge B' and E
408 408 |\
409 409 | o 6 draft B'
410 410 | |
411 411 +---o 5 secret H
412 412 | |
413 413 o | 4 secret E
414 414 | |
415 415 o | 3 draft D
416 416 | |
417 417 o | 2 draft C
418 418 |/
419 419 o 1 public B
420 420 |
421 421 o 0 public A
422 422
423 423
424 424 display changesets phase
425 425
426 426 (mixing -r and plain rev specification)
427 427
428 428 $ hg phase 1::4 -r 7
429 429 1: public
430 430 2: draft
431 431 3: draft
432 432 4: secret
433 433 7: secret
434 434
435 435
436 436 move changeset forward
437 437
438 438 (with -r option)
439 439
440 440 $ hg phase --public -r 2
441 441 $ hg log -G --template "{rev} {phase} {desc}\n"
442 442 @ 7 secret merge B' and E
443 443 |\
444 444 | o 6 draft B'
445 445 | |
446 446 +---o 5 secret H
447 447 | |
448 448 o | 4 secret E
449 449 | |
450 450 o | 3 draft D
451 451 | |
452 452 o | 2 public C
453 453 |/
454 454 o 1 public B
455 455 |
456 456 o 0 public A
457 457
458 458
459 459 move changeset backward
460 460
461 461 (without -r option)
462 462
463 463 $ hg phase --draft --force 2
464 464 $ hg log -G --template "{rev} {phase} {desc}\n"
465 465 @ 7 secret merge B' and E
466 466 |\
467 467 | o 6 draft B'
468 468 | |
469 469 +---o 5 secret H
470 470 | |
471 471 o | 4 secret E
472 472 | |
473 473 o | 3 draft D
474 474 | |
475 475 o | 2 draft C
476 476 |/
477 477 o 1 public B
478 478 |
479 479 o 0 public A
480 480
481 481
482 482 move changeset forward and backward
483 483
484 484 $ hg phase --draft --force 1::4
485 485 $ hg log -G --template "{rev} {phase} {desc}\n"
486 486 @ 7 secret merge B' and E
487 487 |\
488 488 | o 6 draft B'
489 489 | |
490 490 +---o 5 secret H
491 491 | |
492 492 o | 4 draft E
493 493 | |
494 494 o | 3 draft D
495 495 | |
496 496 o | 2 draft C
497 497 |/
498 498 o 1 draft B
499 499 |
500 500 o 0 public A
501 501
502 502 test partial failure
503 503
504 504 $ hg phase --public 7
505 505 $ hg phase --draft '5 or 7'
506 506 cannot move 1 changesets to a higher phase, use --force
507 507 phase changed for 1 changesets
508 508 [1]
509 509 $ hg log -G --template "{rev} {phase} {desc}\n"
510 510 @ 7 public merge B' and E
511 511 |\
512 512 | o 6 public B'
513 513 | |
514 514 +---o 5 draft H
515 515 | |
516 516 o | 4 public E
517 517 | |
518 518 o | 3 public D
519 519 | |
520 520 o | 2 public C
521 521 |/
522 522 o 1 public B
523 523 |
524 524 o 0 public A
525 525
526 526
527 527 test complete failure
528 528
529 529 $ hg phase --draft 7
530 530 cannot move 1 changesets to a higher phase, use --force
531 531 no phases changed
532 532 [1]
533 533
534 534 $ cd ..
535 535
536 536 test hidden changeset are not cloned as public (issue3935)
537 537
538 538 $ cd initialrepo
539 539
540 540 (enabling evolution)
541 541 $ cat >> $HGRCPATH << EOF
542 542 > [experimental]
543 543 > evolution=createmarkers
544 544 > EOF
545 545
546 546 (making a changeset hidden; H in that case)
547 547 $ hg debugobsolete `hg id --debug -r 5`
548 548
549 549 $ cd ..
550 550 $ hg clone initialrepo clonewithobs
551 551 requesting all changes
552 552 adding changesets
553 553 adding manifests
554 554 adding file changes
555 555 added 7 changesets with 6 changes to 6 files
556 556 updating to branch default
557 557 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
558 558 $ cd clonewithobs
559 559 $ hg log -G --template "{rev} {phase} {desc}\n"
560 560 @ 6 public merge B' and E
561 561 |\
562 562 | o 5 public B'
563 563 | |
564 564 o | 4 public E
565 565 | |
566 566 o | 3 public D
567 567 | |
568 568 o | 2 public C
569 569 |/
570 570 o 1 public B
571 571 |
572 572 o 0 public A
573 573
574 574
575 575 test verify repo containing hidden changesets, which should not abort just
576 576 because repo.cancopy() is False
577 577
578 578 $ cd ../initialrepo
579 579 $ hg verify
580 580 checking changesets
581 581 checking manifests
582 582 crosschecking files in changesets and manifests
583 583 checking files
584 584 7 files, 8 changesets, 7 total revisions
585 585
586 586 $ cd ..
587 587
588 588 check whether HG_PENDING makes pending changes only in related
589 589 repositories visible to an external hook.
590 590
591 591 (emulate a transaction running concurrently by copied
592 592 .hg/phaseroots.pending in subsequent test)
593 593
594 594 $ cat > $TESTTMP/savepending.sh <<EOF
595 595 > cp .hg/store/phaseroots.pending .hg/store/phaseroots.pending.saved
596 596 > exit 1 # to avoid changing phase for subsequent tests
597 597 > EOF
598 598 $ cd push-dest
599 599 $ hg phase 6
600 600 6: draft
601 601 $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" phase -f -s 6
602 602 transaction abort!
603 603 rollback completed
604 604 abort: pretxnclose hook exited with status 1
605 605 [255]
606 606 $ cp .hg/store/phaseroots.pending.saved .hg/store/phaseroots.pending
607 607
608 608 (check (in)visibility of phaseroot while transaction running in repo)
609 609
610 610 $ cat > $TESTTMP/checkpending.sh <<EOF
611 611 > echo '@initialrepo'
612 > hg -R $TESTTMP/initialrepo phase 7
612 > hg -R "$TESTTMP/initialrepo" phase 7
613 613 > echo '@push-dest'
614 > hg -R $TESTTMP/push-dest phase 6
614 > hg -R "$TESTTMP/push-dest" phase 6
615 615 > exit 1 # to avoid changing phase for subsequent tests
616 616 > EOF
617 617 $ cd ../initialrepo
618 618 $ hg phase 7
619 619 7: public
620 620 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" phase -f -s 7
621 621 @initialrepo
622 622 7: secret
623 623 @push-dest
624 624 6: draft
625 625 transaction abort!
626 626 rollback completed
627 627 abort: pretxnclose hook exited with status 1
628 628 [255]
@@ -1,416 +1,416 b''
1 1 #require killdaemons
2 2
3 3 $ echo "[extensions]" >> $HGRCPATH
4 4 $ echo "share = " >> $HGRCPATH
5 5
6 6 prepare repo1
7 7
8 8 $ hg init repo1
9 9 $ cd repo1
10 10 $ echo a > a
11 11 $ hg commit -A -m'init'
12 12 adding a
13 13
14 14 share it
15 15
16 16 $ cd ..
17 17 $ hg share repo1 repo2
18 18 updating working directory
19 19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
20 20
21 21 share shouldn't have a store dir
22 22
23 23 $ cd repo2
24 24 $ test -d .hg/store
25 25 [1]
26 26
27 27 Some sed versions appends newline, some don't, and some just fails
28 28
29 29 $ cat .hg/sharedpath; echo
30 30 $TESTTMP/repo1/.hg (glob)
31 31
32 32 trailing newline on .hg/sharedpath is ok
33 33 $ hg tip -q
34 34 0:d3873e73d99e
35 35 $ echo '' >> .hg/sharedpath
36 36 $ cat .hg/sharedpath
37 37 $TESTTMP/repo1/.hg (glob)
38 38 $ hg tip -q
39 39 0:d3873e73d99e
40 40
41 41 commit in shared clone
42 42
43 43 $ echo a >> a
44 44 $ hg commit -m'change in shared clone'
45 45
46 46 check original
47 47
48 48 $ cd ../repo1
49 49 $ hg log
50 50 changeset: 1:8af4dc49db9e
51 51 tag: tip
52 52 user: test
53 53 date: Thu Jan 01 00:00:00 1970 +0000
54 54 summary: change in shared clone
55 55
56 56 changeset: 0:d3873e73d99e
57 57 user: test
58 58 date: Thu Jan 01 00:00:00 1970 +0000
59 59 summary: init
60 60
61 61 $ hg update
62 62 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
63 63 $ cat a # should be two lines of "a"
64 64 a
65 65 a
66 66
67 67 commit in original
68 68
69 69 $ echo b > b
70 70 $ hg commit -A -m'another file'
71 71 adding b
72 72
73 73 check in shared clone
74 74
75 75 $ cd ../repo2
76 76 $ hg log
77 77 changeset: 2:c2e0ac586386
78 78 tag: tip
79 79 user: test
80 80 date: Thu Jan 01 00:00:00 1970 +0000
81 81 summary: another file
82 82
83 83 changeset: 1:8af4dc49db9e
84 84 user: test
85 85 date: Thu Jan 01 00:00:00 1970 +0000
86 86 summary: change in shared clone
87 87
88 88 changeset: 0:d3873e73d99e
89 89 user: test
90 90 date: Thu Jan 01 00:00:00 1970 +0000
91 91 summary: init
92 92
93 93 $ hg update
94 94 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
95 95 $ cat b # should exist with one "b"
96 96 b
97 97
98 98 hg serve shared clone
99 99
100 100 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid
101 101 $ cat hg.pid >> $DAEMON_PIDS
102 102 $ get-with-headers.py localhost:$HGPORT 'raw-file/'
103 103 200 Script output follows
104 104
105 105
106 106 -rw-r--r-- 4 a
107 107 -rw-r--r-- 2 b
108 108
109 109
110 110
111 111 test unshare command
112 112
113 113 $ hg unshare
114 114 $ test -d .hg/store
115 115 $ test -f .hg/sharedpath
116 116 [1]
117 117 $ grep shared .hg/requires
118 118 [1]
119 119 $ hg unshare
120 120 abort: this is not a shared repo
121 121 [255]
122 122
123 123 check that a change does not propagate
124 124
125 125 $ echo b >> b
126 126 $ hg commit -m'change in unshared'
127 127 $ cd ../repo1
128 128 $ hg id -r tip
129 129 c2e0ac586386 tip
130 130
131 131 $ cd ..
132 132
133 133
134 134 test sharing bookmarks
135 135
136 136 $ hg share -B repo1 repo3
137 137 updating working directory
138 138 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
139 139 $ cd repo1
140 140 $ hg bookmark bm1
141 141 $ hg bookmarks
142 142 * bm1 2:c2e0ac586386
143 143 $ cd ../repo2
144 144 $ hg book bm2
145 145 $ hg bookmarks
146 146 * bm2 3:0e6e70d1d5f1
147 147 $ cd ../repo3
148 148 $ hg bookmarks
149 149 bm1 2:c2e0ac586386
150 150 $ hg book bm3
151 151 $ hg bookmarks
152 152 bm1 2:c2e0ac586386
153 153 * bm3 2:c2e0ac586386
154 154 $ cd ../repo1
155 155 $ hg bookmarks
156 156 * bm1 2:c2e0ac586386
157 157 bm3 2:c2e0ac586386
158 158
159 159 check whether HG_PENDING makes pending changes only in relatd
160 160 repositories visible to an external hook.
161 161
162 162 In "hg share" case, another transaction can't run in other
163 163 repositories sharing same source repository, because starting
164 164 transaction requires locking store of source repository.
165 165
166 166 Therefore, this test scenario ignores checking visibility of
167 167 .hg/bookmakrs.pending in repo2, which shares repo1 without bookmarks.
168 168
169 169 $ cat > $TESTTMP/checkbookmarks.sh <<EOF
170 170 > echo "@repo1"
171 > hg -R $TESTTMP/repo1 bookmarks
171 > hg -R "$TESTTMP/repo1" bookmarks
172 172 > echo "@repo2"
173 > hg -R $TESTTMP/repo2 bookmarks
173 > hg -R "$TESTTMP/repo2" bookmarks
174 174 > echo "@repo3"
175 > hg -R $TESTTMP/repo3 bookmarks
175 > hg -R "$TESTTMP/repo3" bookmarks
176 176 > exit 1 # to avoid adding new bookmark for subsequent tests
177 177 > EOF
178 178
179 179 $ cd ../repo1
180 180 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkbookmarks.sh" -q book bmX
181 181 @repo1
182 182 bm1 2:c2e0ac586386
183 183 bm3 2:c2e0ac586386
184 184 * bmX 2:c2e0ac586386
185 185 @repo2
186 186 * bm2 3:0e6e70d1d5f1
187 187 @repo3
188 188 bm1 2:c2e0ac586386
189 189 * bm3 2:c2e0ac586386
190 190 bmX 2:c2e0ac586386
191 191 transaction abort!
192 192 rollback completed
193 193 abort: pretxnclose hook exited with status 1
194 194 [255]
195 195 $ hg book bm1
196 196
197 197 FYI, in contrast to above test, bmX is invisible in repo1 (= shared
198 198 src), because (1) HG_PENDING refers only repo3 and (2)
199 199 "bookmarks.pending" is written only into repo3.
200 200
201 201 $ cd ../repo3
202 202 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkbookmarks.sh" -q book bmX
203 203 @repo1
204 204 * bm1 2:c2e0ac586386
205 205 bm3 2:c2e0ac586386
206 206 @repo2
207 207 * bm2 3:0e6e70d1d5f1
208 208 @repo3
209 209 bm1 2:c2e0ac586386
210 210 bm3 2:c2e0ac586386
211 211 * bmX 2:c2e0ac586386
212 212 transaction abort!
213 213 rollback completed
214 214 abort: pretxnclose hook exited with status 1
215 215 [255]
216 216 $ hg book bm3
217 217
218 218 $ cd ../repo1
219 219
220 220 test that commits work
221 221
222 222 $ echo 'shared bookmarks' > a
223 223 $ hg commit -m 'testing shared bookmarks'
224 224 $ hg bookmarks
225 225 * bm1 3:b87954705719
226 226 bm3 2:c2e0ac586386
227 227 $ cd ../repo3
228 228 $ hg bookmarks
229 229 bm1 3:b87954705719
230 230 * bm3 2:c2e0ac586386
231 231 $ echo 'more shared bookmarks' > a
232 232 $ hg commit -m 'testing shared bookmarks'
233 233 created new head
234 234 $ hg bookmarks
235 235 bm1 3:b87954705719
236 236 * bm3 4:62f4ded848e4
237 237 $ cd ../repo1
238 238 $ hg bookmarks
239 239 * bm1 3:b87954705719
240 240 bm3 4:62f4ded848e4
241 241 $ cd ..
242 242
243 243 test pushing bookmarks works
244 244
245 245 $ hg clone repo3 repo4
246 246 updating to branch default
247 247 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
248 248 $ cd repo4
249 249 $ hg boo bm4
250 250 $ echo foo > b
251 251 $ hg commit -m 'foo in b'
252 252 $ hg boo
253 253 bm1 3:b87954705719
254 254 bm3 4:62f4ded848e4
255 255 * bm4 5:92793bfc8cad
256 256 $ hg push -B bm4
257 257 pushing to $TESTTMP/repo3 (glob)
258 258 searching for changes
259 259 adding changesets
260 260 adding manifests
261 261 adding file changes
262 262 added 1 changesets with 1 changes to 1 files
263 263 exporting bookmark bm4
264 264 $ cd ../repo1
265 265 $ hg bookmarks
266 266 * bm1 3:b87954705719
267 267 bm3 4:62f4ded848e4
268 268 bm4 5:92793bfc8cad
269 269 $ cd ../repo3
270 270 $ hg bookmarks
271 271 bm1 3:b87954705719
272 272 * bm3 4:62f4ded848e4
273 273 bm4 5:92793bfc8cad
274 274 $ cd ..
275 275
276 276 test behavior when sharing a shared repo
277 277
278 278 $ hg share -B repo3 repo5
279 279 updating working directory
280 280 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
281 281 $ cd repo5
282 282 $ hg book
283 283 bm1 3:b87954705719
284 284 bm3 4:62f4ded848e4
285 285 bm4 5:92793bfc8cad
286 286 $ cd ..
287 287
288 288 test what happens when an active bookmark is deleted
289 289
290 290 $ cd repo1
291 291 $ hg boo -d bm3
292 292 $ hg boo
293 293 * bm1 3:b87954705719
294 294 bm4 5:92793bfc8cad
295 295 $ cd ../repo3
296 296 $ hg boo
297 297 bm1 3:b87954705719
298 298 bm4 5:92793bfc8cad
299 299 $ cd ..
300 300
301 301 verify that bookmarks are not written on failed transaction
302 302
303 303 $ cat > failpullbookmarks.py << EOF
304 304 > """A small extension that makes bookmark pulls fail, for testing"""
305 305 > from mercurial import extensions, exchange, error
306 306 > def _pullbookmarks(orig, pullop):
307 307 > orig(pullop)
308 308 > raise error.HookAbort('forced failure by extension')
309 309 > def extsetup(ui):
310 310 > extensions.wrapfunction(exchange, '_pullbookmarks', _pullbookmarks)
311 311 > EOF
312 312 $ cd repo4
313 313 $ hg boo
314 314 bm1 3:b87954705719
315 315 bm3 4:62f4ded848e4
316 316 * bm4 5:92793bfc8cad
317 317 $ cd ../repo3
318 318 $ hg boo
319 319 bm1 3:b87954705719
320 320 bm4 5:92793bfc8cad
321 321 $ hg --config "extensions.failpullbookmarks=$TESTTMP/failpullbookmarks.py" pull $TESTTMP/repo4
322 322 pulling from $TESTTMP/repo4 (glob)
323 323 searching for changes
324 324 no changes found
325 325 adding remote bookmark bm3
326 326 abort: forced failure by extension
327 327 [255]
328 328 $ hg boo
329 329 bm1 3:b87954705719
330 330 bm4 5:92793bfc8cad
331 331 $ hg pull $TESTTMP/repo4
332 332 pulling from $TESTTMP/repo4 (glob)
333 333 searching for changes
334 334 no changes found
335 335 adding remote bookmark bm3
336 336 $ hg boo
337 337 bm1 3:b87954705719
338 338 * bm3 4:62f4ded848e4
339 339 bm4 5:92793bfc8cad
340 340 $ cd ..
341 341
342 342 verify bookmark behavior after unshare
343 343
344 344 $ cd repo3
345 345 $ hg unshare
346 346 $ hg boo
347 347 bm1 3:b87954705719
348 348 * bm3 4:62f4ded848e4
349 349 bm4 5:92793bfc8cad
350 350 $ hg boo -d bm4
351 351 $ hg boo bm5
352 352 $ hg boo
353 353 bm1 3:b87954705719
354 354 bm3 4:62f4ded848e4
355 355 * bm5 4:62f4ded848e4
356 356 $ cd ../repo1
357 357 $ hg boo
358 358 * bm1 3:b87954705719
359 359 bm3 4:62f4ded848e4
360 360 bm4 5:92793bfc8cad
361 361 $ cd ..
362 362
363 363 test shared clones using relative paths work
364 364
365 365 $ mkdir thisdir
366 366 $ hg init thisdir/orig
367 367 $ hg share -U thisdir/orig thisdir/abs
368 368 $ hg share -U --relative thisdir/abs thisdir/rel
369 369 $ cat thisdir/rel/.hg/sharedpath
370 370 ../../orig/.hg (no-eol) (glob)
371 371 $ grep shared thisdir/*/.hg/requires
372 372 thisdir/abs/.hg/requires:shared
373 373 thisdir/rel/.hg/requires:shared
374 374 thisdir/rel/.hg/requires:relshared
375 375
376 376 test that relative shared paths aren't relative to $PWD
377 377
378 378 $ cd thisdir
379 379 $ hg -R rel root
380 380 $TESTTMP/thisdir/rel (glob)
381 381 $ cd ..
382 382
383 383 now test that relative paths really are relative, survive across
384 384 renames and changes of PWD
385 385
386 386 $ hg -R thisdir/abs root
387 387 $TESTTMP/thisdir/abs (glob)
388 388 $ hg -R thisdir/rel root
389 389 $TESTTMP/thisdir/rel (glob)
390 390 $ mv thisdir thatdir
391 391 $ hg -R thatdir/abs root
392 392 abort: .hg/sharedpath points to nonexistent directory $TESTTMP/thisdir/orig/.hg! (glob)
393 393 [255]
394 394 $ hg -R thatdir/rel root
395 395 $TESTTMP/thatdir/rel (glob)
396 396
397 397 test unshare relshared repo
398 398
399 399 $ cd thatdir/rel
400 400 $ hg unshare
401 401 $ test -d .hg/store
402 402 $ test -f .hg/sharedpath
403 403 [1]
404 404 $ grep shared .hg/requires
405 405 [1]
406 406 $ hg unshare
407 407 abort: this is not a shared repo
408 408 [255]
409 409 $ cd ../..
410 410
411 411 $ rm -r thatdir
412 412
413 413 Explicitly kill daemons to let the test exit on Windows
414 414
415 415 $ killdaemons.py
416 416
General Comments 0
You need to be logged in to leave comments. Login now