Debian Codegraph @

tests/test-rebase-collapse.t

raw
1 $ cat >> $HGRCPATH <<EOF
2 > [extensions]
3 > rebase=
4 > mq=
5 > drawdag=$TESTDIR/drawdag.py
6 >
7 > [phases]
8 > publish=False
9 >
10 > [alias]
11 > tglog = log -G --template "{rev}: {node|short} '{desc}' {branches}\n"
12 > tglogp = log -G --template "{rev}: {node|short} {phase} '{desc}' {branches}\n"
13 > EOF
14
15 Highest phase of source commits is used:
16
17 $ hg init phase
18 $ cd phase
19 $ hg debugdrawdag << 'EOF'
20 > D
21 > |
22 > F C
23 > | |
24 > E B
25 > |/
26 > A
27 > EOF
28
29 $ hg phase --force --secret D
30
31 $ cat > $TESTTMP/editor.sh <<EOF
32 > echo "==== before editing"
33 > cat \$1
34 > echo "===="
35 > echo "edited manually" >> \$1
36 > EOF
37 $ HGEDITOR="sh $TESTTMP/editor.sh" hg rebase --collapse --keepbranches -e --source B --dest F
38 rebasing 1:112478962961 B "B"
39 rebasing 3:26805aba1e60 C "C"
40 rebasing 5:f585351a92f8 D tip "D"
41 ==== before editing
42 Collapsed revision
43 * B
44 * C
45 * D
46
47
48 HG: Enter commit message. Lines beginning with 'HG:' are removed.
49 HG: Leave message empty to abort commit.
50 HG: --
51 HG: user: test
52 HG: branch 'default'
53 HG: added B
54 HG: added C
55 HG: added D
56 ====
57 saved backup bundle to $TESTTMP/phase/.hg/strip-backup/112478962961-cb2a9b47-rebase.hg
58
59 $ hg tglogp
60 o 3: 92fa5f5fe108 secret 'Collapsed revision
61 | * B
62 | * C
63 | * D
64 |
65 |
66 | edited manually'
67 o 2: 64a8289d2492 draft 'F'
68 |
69 o 1: 7fb047a69f22 draft 'E'
70 |
71 o 0: 426bada5c675 draft 'A'
72
73 $ hg manifest --rev tip
74 A
75 B
76 C
77 D
78 E
79 F
80
81 $ cd ..
82
83
84 Merge gets linearized:
85
86 $ hg init linearized-merge
87 $ cd linearized-merge
88
89 $ hg debugdrawdag << 'EOF'
90 > F D
91 > |/|
92 > C B
93 > |/
94 > A
95 > EOF
96
97 $ hg phase --force --secret D
98 $ hg rebase --source B --collapse --dest F
99 rebasing 1:112478962961 B "B"
100 rebasing 3:4e4f9194f9f1 D "D"
101 saved backup bundle to $TESTTMP/linearized-merge/.hg/strip-backup/112478962961-e389075b-rebase.hg
102
103 $ hg tglog
104 o 3: 5bdc08b7da2b 'Collapsed revision
105 | * B
106 | * D'
107 o 2: afc707c82df0 'F'
108 |
109 o 1: dc0947a82db8 'C'
110 |
111 o 0: 426bada5c675 'A'
112
113 $ hg manifest --rev tip
114 A
115 B
116 C
117 F
118
119 $ cd ..
120
121 Custom message:
122
123 $ hg init message
124 $ cd message
125
126 $ hg debugdrawdag << 'EOF'
127 > C
128 > |
129 > D B
130 > |/
131 > A
132 > EOF
133
134
135 $ hg rebase --base B -m 'custom message'
136 abort: message can only be specified with collapse
137 [10]
138
139 $ cat > $TESTTMP/checkeditform.sh <<EOF
140 > env | grep HGEDITFORM
141 > true
142 > EOF
143 $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg rebase --source B --collapse -m 'custom message' -e --dest D
144 rebasing 1:112478962961 B "B"
145 rebasing 3:26805aba1e60 C tip "C"
146 HGEDITFORM=rebase.collapse
147 saved backup bundle to $TESTTMP/message/.hg/strip-backup/112478962961-f4131707-rebase.hg
148
149 $ hg tglog
150 o 2: 2f197b9a08f3 'custom message'
151 |
152 o 1: b18e25de2cf5 'D'
153 |
154 o 0: 426bada5c675 'A'
155
156 $ hg manifest --rev tip
157 A
158 B
159 C
160 D
161
162 $ cd ..
163
164 Rebase and collapse - more than one external (fail):
165
166 $ hg init multiple-external-parents
167 $ cd multiple-external-parents
168
169 $ hg debugdrawdag << 'EOF'
170 > G
171 > |\
172 > | F
173 > | |
174 > D E
175 > |\|
176 > H C B
177 > \|/
178 > A
179 > EOF
180
181 $ hg rebase -s C --dest H --collapse
182 abort: unable to collapse on top of 3, there is more than one external parent: 1, 6
183 [20]
184
185 Rebase and collapse - E onto H:
186
187 $ hg rebase -s E --dest H --collapse # root (E) is not a merge
188 rebasing 5:49cb92066bfd E "E"
189 rebasing 6:11abe3fb10b8 F "F"
190 rebasing 7:64e264db77f0 G tip "G"
191 saved backup bundle to $TESTTMP/multiple-external-parents/.hg/strip-backup/49cb92066bfd-ee8a8a79-rebase.hg
192
193 $ hg tglog
194 o 5: 8b2315790719 'Collapsed revision
195 |\ * E
196 | | * F
197 | | * G'
198 | o 4: 4e4f9194f9f1 'D'
199 | |\
200 o | | 3: 575c4b5ec114 'H'
201 | | |
202 +---o 2: dc0947a82db8 'C'
203 | |
204 | o 1: 112478962961 'B'
205 |/
206 o 0: 426bada5c675 'A'
207
208 $ hg manifest --rev tip
209 A
210 C
211 E
212 F
213 H
214
215 $ cd ..
216
217
218
219
220 Test that branchheads cache is updated correctly when doing a strip in which
221 the parent of the ancestor node to be stripped does not become a head and also,
222 the parent of a node that is a child of the node stripped becomes a head (node
223 3). The code is now much simpler and we could just test a simpler scenario
224 We keep it the test this way in case new complexity is injected.
225
226 Create repo b:
227
228 $ hg init branch-heads
229 $ cd branch-heads
230
231 $ hg debugdrawdag << 'EOF'
232 > G
233 > |\
234 > | F
235 > | |
236 > D E
237 > |\|
238 > H C B
239 > \|/
240 > A
241 > EOF
242
243 $ hg heads --template="{rev}:{node} {branch}\n"
244 7:64e264db77f061f16d9132b70c5a58e2461fb630 default
245 3:575c4b5ec114d64b681d33f8792853568bfb2b2c default
246
247 $ cat $TESTTMP/branch-heads/.hg/cache/branch2-served
248 64e264db77f061f16d9132b70c5a58e2461fb630 7
249 575c4b5ec114d64b681d33f8792853568bfb2b2c o default
250 64e264db77f061f16d9132b70c5a58e2461fb630 o default
251
252 $ hg strip 4
253 saved backup bundle to $TESTTMP/branch-heads/.hg/strip-backup/4e4f9194f9f1-5ec4b5e6-backup.hg
254
255 $ cat $TESTTMP/branch-heads/.hg/cache/branch2-served
256 11abe3fb10b8689b560681094b17fe161871d043 5
257 dc0947a82db884575bb76ea10ac97b08536bfa03 o default
258 575c4b5ec114d64b681d33f8792853568bfb2b2c o default
259 11abe3fb10b8689b560681094b17fe161871d043 o default
260
261 $ hg heads --template="{rev}:{node} {branch}\n"
262 5:11abe3fb10b8689b560681094b17fe161871d043 default
263 3:575c4b5ec114d64b681d33f8792853568bfb2b2c default
264 2:dc0947a82db884575bb76ea10ac97b08536bfa03 default
265
266 $ cd ..
267
268
269
270 Preserves external parent
271
272 $ hg init external-parent
273 $ cd external-parent
274
275 $ hg debugdrawdag << 'EOF'
276 > H
277 > |\
278 > | G
279 > | |
280 > | F # F/E = F\n
281 > | |
282 > D E # D/D = D\n
283 > |\|
284 > I C B
285 > \|/
286 > A
287 > EOF
288
289 $ hg rebase -s F --dest I --collapse # root (F) is not a merge
290 rebasing 6:c82b08f646f1 F "F"
291 file 'E' was deleted in local [dest] but was modified in other [source].
292 You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
293 What do you want to do? u
294 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
295 [240]
296
297 $ echo F > E
298 $ hg resolve -m
299 (no more unresolved files)
300 continue: hg rebase --continue
301 $ hg rebase -c
302 rebasing 6:c82b08f646f1 F "F"
303 rebasing 7:a6db7fa104e1 G "G"
304 rebasing 8:e1d201b72d91 H tip "H"
305 saved backup bundle to $TESTTMP/external-parent/.hg/strip-backup/c82b08f646f1-f2721fbf-rebase.hg
306
307 $ hg tglog
308 o 6: 681daa3e686d 'Collapsed revision
309 |\ * F
310 | | * G
311 | | * H'
312 | | o 5: 49cb92066bfd 'E'
313 | | |
314 | o | 4: 09143c0bf13e 'D'
315 | |\|
316 o | | 3: 08ebfeb61bac 'I'
317 | | |
318 | o | 2: dc0947a82db8 'C'
319 |/ /
320 | o 1: 112478962961 'B'
321 |/
322 o 0: 426bada5c675 'A'
323
324 $ hg manifest --rev tip
325 A
326 C
327 D
328 E
329 F
330 G
331 I
332
333 $ hg up tip -q
334 $ cat E
335 F
336
337 $ cd ..
338
339 Rebasing from multiple bases:
340
341 $ hg init multiple-bases
342 $ cd multiple-bases
343 $ hg debugdrawdag << 'EOF'
344 > C B
345 > D |/
346 > |/
347 > A
348 > EOF
349 $ hg rebase --collapse -r 'B+C' -d D
350 rebasing 1:fc2b737bb2e5 B "B"
351 rebasing 2:dc0947a82db8 C "C"
352 saved backup bundle to $TESTTMP/multiple-bases/.hg/strip-backup/dc0947a82db8-b0c1a7ea-rebase.hg
353 $ hg tglog
354 o 2: 2127ae44d291 'Collapsed revision
355 | * B
356 | * C'
357 o 1: b18e25de2cf5 'D'
358 |
359 o 0: 426bada5c675 'A'
360
361 $ cd ..
362
363 With non-contiguous commits:
364
365 $ hg init non-contiguous
366 $ cd non-contiguous
367 $ cat >> .hg/hgrc <<EOF
368 > [experimental]
369 > evolution=all
370 > EOF
371
372 $ hg debugdrawdag << 'EOF'
373 > F
374 > |
375 > E
376 > |
377 > D
378 > |
379 > C
380 > |
381 > B G
382 > |/
383 > A
384 > EOF
385
386 BROKEN: should be allowed
387 $ hg rebase --collapse -r 'B+D+F' -d G
388 abort: unable to collapse on top of 2, there is more than one external parent: 3, 5
389 [20]
390 $ cd ..
391
392
393 $ hg init multiple-external-parents-2
394 $ cd multiple-external-parents-2
395 $ hg debugdrawdag << 'EOF'
396 > D G
397 > |\ /|
398 > B C E F
399 > \| |/
400 > \ H /
401 > \|/
402 > A
403 > EOF
404
405 $ hg rebase --collapse -d H -s 'B+F'
406 abort: unable to collapse on top of 5, there is more than one external parent: 1, 3
407 [20]
408 $ cd ..
409
410 With internal merge:
411
412 $ hg init internal-merge
413 $ cd internal-merge
414
415 $ hg debugdrawdag << 'EOF'
416 > E
417 > |\
418 > C D
419 > |/
420 > F B
421 > |/
422 > A
423 > EOF
424
425
426 $ hg rebase -s B --collapse --dest F
427 rebasing 1:112478962961 B "B"
428 rebasing 3:26805aba1e60 C "C"
429 rebasing 4:be0ef73c17ad D "D"
430 rebasing 5:02c4367d6973 E tip "E"
431 saved backup bundle to $TESTTMP/internal-merge/.hg/strip-backup/112478962961-1dfb057b-rebase.hg
432
433 $ hg tglog
434 o 2: c0512a1797b0 'Collapsed revision
435 | * B
436 | * C
437 | * D
438 | * E'
439 o 1: 8908a377a434 'F'
440 |
441 o 0: 426bada5c675 'A'
442
443 $ hg manifest --rev tip
444 A
445 B
446 C
447 D
448 F
449 $ cd ..
450
451 Interactions between collapse and keepbranches
452 $ hg init e
453 $ cd e
454 $ echo 'a' > a
455 $ hg ci -Am 'A'
456 adding a
457
458 $ hg branch 'one'
459 marked working directory as branch one
460 (branches are permanent and global, did you want a bookmark?)
461 $ echo 'b' > b
462 $ hg ci -Am 'B'
463 adding b
464
465 $ hg branch 'two'
466 marked working directory as branch two
467 $ echo 'c' > c
468 $ hg ci -Am 'C'
469 adding c
470
471 $ hg up -q 0
472 $ echo 'd' > d
473 $ hg ci -Am 'D'
474 adding d
475
476 $ hg tglog
477 @ 3: 41acb9dca9eb 'D'
478 |
479 | o 2: 8ac4a08debf1 'C' two
480 | |
481 | o 1: 1ba175478953 'B' one
482 |/
483 o 0: 1994f17a630e 'A'
484
485 $ hg rebase --keepbranches --collapse -s 1 -d 3
486 abort: cannot collapse multiple named branches
487 [10]
488
489 $ cd ..
490
491 Rebase, collapse and copies
492
493 $ hg init copies
494 $ cd copies
495 $ hg unbundle "$TESTDIR/bundles/renames.hg"
496 adding changesets
497 adding manifests
498 adding file changes
499 added 4 changesets with 11 changes to 7 files (+1 heads)
500 new changesets f447d5abf5ea:338e84e2e558 (4 drafts)
501 (run 'hg heads' to see heads, 'hg merge' to merge)
502 $ hg up -q tip
503 $ hg tglog
504 @ 3: 338e84e2e558 'move2'
505 |
506 o 2: 6e7340ee38c0 'move1'
507 |
508 | o 1: 1352765a01d4 'change'
509 |/
510 o 0: f447d5abf5ea 'add'
511
512 $ hg rebase --collapse -d 1
513 rebasing 2:6e7340ee38c0 "move1"
514 merging a and d to d
515 merging b and e to e
516 merging c and f to f
517 rebasing 3:338e84e2e558 tip "move2"
518 merging f and c to c
519 merging e and g to g
520 saved backup bundle to $TESTTMP/copies/.hg/strip-backup/6e7340ee38c0-ef8ef003-rebase.hg
521 $ hg st
522 $ hg st --copies --change tip
523 A d
524 a
525 A g
526 b
527 R b
528 $ hg up tip -q
529 $ cat c
530 c
531 c
532 $ cat d
533 a
534 a
535 $ cat g
536 b
537 b
538 $ hg log -r . --template "{file_copies}\n"
539 d (a)g (b)
540
541 Test collapsing a middle revision in-place
542
543 $ hg tglog
544 @ 2: 64b456429f67 'Collapsed revision
545 | * move1
546 | * move2'
547 o 1: 1352765a01d4 'change'
548 |
549 o 0: f447d5abf5ea 'add'
550
551 $ hg rebase --collapse -r 1 -d 0
552 abort: cannot rebase changeset, as that will orphan 1 descendants
553 (see 'hg help evolution.instability')
554 [10]
555
556 Test collapsing in place
557
558 $ hg rebase --collapse -b . -d 0
559 rebasing 1:1352765a01d4 "change"
560 rebasing 2:64b456429f67 tip "Collapsed revision"
561 saved backup bundle to $TESTTMP/copies/.hg/strip-backup/1352765a01d4-45a352ea-rebase.hg
562 $ hg st --change tip --copies
563 M a
564 M c
565 A d
566 a
567 A g
568 b
569 R b
570 $ hg up tip -q
571 $ cat a
572 a
573 a
574 $ cat c
575 c
576 c
577 $ cat d
578 a
579 a
580 $ cat g
581 b
582 b
583 $ cd ..
584
585
586 Test stripping a revision with another child
587
588 $ hg init f
589 $ cd f
590
591 $ hg debugdrawdag << 'EOF'
592 > C B
593 > |/
594 > A
595 > EOF
596
597 $ hg heads --template="{rev}:{node} {branch}: {desc}\n"
598 2:dc0947a82db884575bb76ea10ac97b08536bfa03 default: C
599 1:112478962961147124edd43549aedd1a335e44bf default: B
600
601 $ hg strip C
602 saved backup bundle to $TESTTMP/f/.hg/strip-backup/dc0947a82db8-d21b92a4-backup.hg
603
604 $ hg tglog
605 o 1: 112478962961 'B'
606 |
607 o 0: 426bada5c675 'A'
608
609
610
611 $ hg heads --template="{rev}:{node} {branch}: {desc}\n"
612 1:112478962961147124edd43549aedd1a335e44bf default: B
613
614 $ cd ..
615
616 Test collapsing changes that add then remove a file
617
618 $ hg init collapseaddremove
619 $ cd collapseaddremove
620
621 $ touch base
622 $ hg commit -Am base
623 adding base
624 $ touch a
625 $ hg commit -Am a
626 adding a
627 $ hg rm a
628 $ touch b
629 $ hg commit -Am b
630 adding b
631 $ hg book foo
632 $ hg rebase -d 0 -r "1::2" --collapse -m collapsed
633 rebasing 1:6d8d9f24eec3 "a"
634 rebasing 2:1cc73eca5ecc foo tip "b"
635 saved backup bundle to $TESTTMP/collapseaddremove/.hg/strip-backup/6d8d9f24eec3-77d3b6e2-rebase.hg
636 $ hg log -G --template "{rev}: '{desc}' {bookmarks}"
637 @ 1: 'collapsed' foo
638 |
639 o 0: 'base'
640
641 $ hg manifest --rev tip
642 b
643 base
644
645 $ cd ..
646
647 Test that rebase --collapse will remember message after
648 running into merge conflict and invoking rebase --continue.
649
650 $ hg init collapse_remember_message
651 $ cd collapse_remember_message
652 $ hg debugdrawdag << 'EOF'
653 > C B # B/A = B\n
654 > |/ # C/A = C\n
655 > A
656 > EOF
657 $ hg rebase --collapse -m "new message" -b B -d C
658 rebasing 1:81e5401e4d37 B "B"
659 merging A
660 warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
661 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
662 [240]
663 $ rm A.orig
664 $ hg resolve --mark A
665 (no more unresolved files)
666 continue: hg rebase --continue
667 $ hg rebase --continue
668 rebasing 1:81e5401e4d37 B "B"
669 saved backup bundle to $TESTTMP/collapse_remember_message/.hg/strip-backup/81e5401e4d37-96c3dd30-rebase.hg
670 $ hg log
671 changeset: 2:17186933e123
672 tag: tip
673 user: test
674 date: Thu Jan 01 00:00:00 1970 +0000
675 summary: new message
676
677 changeset: 1:043039e9df84
678 tag: C
679 user: test
680 date: Thu Jan 01 00:00:00 1970 +0000
681 summary: C
682
683 changeset: 0:426bada5c675
684 tag: A
685 user: test
686 date: Thu Jan 01 00:00:00 1970 +0000
687 summary: A
688
689 $ cd ..
690
691 Test aborted editor on final message
692
693 $ HGMERGE=:merge3
694 $ export HGMERGE
695 $ hg init aborted-editor
696 $ cd aborted-editor
697 $ hg debugdrawdag << 'EOF'
698 > C # D/A = D\n
699 > | # C/A = C\n
700 > B D # B/A = B\n
701 > |/ # A/A = A\n
702 > A
703 > EOF
704 $ hg rebase --collapse -t internal:merge3 -s B -d D
705 rebasing 1:f899f3910ce7 B "B"
706 merging A
707 warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
708 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
709 [240]
710 $ hg tglog
711 o 3: 63668d570d21 'C'
712 |
713 | @ 2: 82b8abf9c185 'D'
714 | |
715 % | 1: f899f3910ce7 'B'
716 |/
717 o 0: 4a2df7238c3b 'A'
718
719 $ cat A
720 <<<<<<< dest: 82b8abf9c185 D - test: D
721 D
722 ||||||| parent of source: 4a2df7238c3b A - test: A
723 A
724 =======
725 B
726 >>>>>>> source: f899f3910ce7 B - test: B
727 $ echo BC > A
728 $ hg resolve -m
729 (no more unresolved files)
730 continue: hg rebase --continue
731 $ hg rebase --continue
732 rebasing 1:f899f3910ce7 B "B"
733 rebasing 3:63668d570d21 C tip "C"
734 merging A
735 warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
736 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
737 [240]
738 $ hg tglog
739 % 3: 63668d570d21 'C'
740 |
741 | @ 2: 82b8abf9c185 'D'
742 | |
743 o | 1: f899f3910ce7 'B'
744 |/
745 o 0: 4a2df7238c3b 'A'
746
747 $ cat A
748 <<<<<<< dest: 82b8abf9c185 D - test: D
749 BC
750 ||||||| parent of source: f899f3910ce7 B - test: B
751 B
752 =======
753 C
754 >>>>>>> source: 63668d570d21 C tip - test: C
755 $ echo BD > A
756 $ hg resolve -m
757 (no more unresolved files)
758 continue: hg rebase --continue
759 $ HGEDITOR=false hg rebase --continue --config ui.interactive=1
760 already rebased 1:f899f3910ce7 B "B" as 82b8abf9c185
761 rebasing 3:63668d570d21 C tip "C"
762 abort: edit failed: false exited with status 1
763 [250]
764 $ hg tglog
765 o 3: 63668d570d21 'C'
766 |
767 | @ 2: 82b8abf9c185 'D'
768 | |
769 o | 1: f899f3910ce7 'B'
770 |/
771 o 0: 4a2df7238c3b 'A'
772
773 $ hg rebase --continue
774 already rebased 1:f899f3910ce7 B "B" as 82b8abf9c185
775 already rebased 3:63668d570d21 C tip "C" as 82b8abf9c185
776 saved backup bundle to $TESTTMP/aborted-editor/.hg/strip-backup/f899f3910ce7-7cab5e15-rebase.hg