Debian Codegraph @

tests/test-rebase-obsolete3.t

raw
1 ==========================
2 Test rebase with obsolete
3 ==========================
4
5 Enable obsolete
6
7 $ cat >> $HGRCPATH << EOF
8 > [command-templates]
9 > log= {rev}:{node|short} {desc|firstline}{if(obsolete,' ({obsfate})')}
10 > [experimental]
11 > evolution.createmarkers=True
12 > evolution.allowunstable=True
13 > [phases]
14 > publish=False
15 > [extensions]
16 > rebase=
17 > drawdag=$TESTDIR/drawdag.py
18 > strip=
19 > EOF
20
21 Divergence cases due to obsolete changesets
22 -------------------------------------------
23
24 We should ignore branches with unstable changesets when they are based on an
25 obsolete changeset which successor is in rebase set.
26
27 $ hg init divergence
28 $ cd divergence
29 $ cat >> .hg/hgrc << EOF
30 > [extensions]
31 > strip =
32 > [alias]
33 > strip = strip --no-backup --quiet
34 > [templates]
35 > instabilities = '{rev}:{node|short} {desc|firstline}{if(instabilities," ({instabilities})")}\n'
36 > EOF
37
38 $ hg debugdrawdag <<EOF
39 > e f
40 > | |
41 > d' d # replace: d -> d'
42 > \ /
43 > c
44 > |
45 > x b
46 > \|
47 > a
48 > EOF
49 1 new orphan changesets
50 $ hg log -G -r 'a'::
51 * 7:1143e9adc121 f
52 |
53 | o 6:d60ebfa0f1cb e
54 | |
55 | o 5:027ad6c5830d d'
56 | |
57 x | 4:76be324c128b d (rewritten using replace as 5:027ad6c5830d)
58 |/
59 o 3:a82ac2b38757 c
60 |
61 | o 2:630d7c95eff7 x
62 | |
63 o | 1:488e1b7e7341 b
64 |/
65 o 0:b173517d0057 a
66
67
68 Changeset d and its descendants are excluded to avoid divergence of d, which
69 would occur because the successor of d (d') is also in rebaseset. As a
70 consequence f (descendant of d) is left behind.
71
72 $ hg rebase -b 'e' -d 'x'
73 rebasing 1:488e1b7e7341 b "b"
74 rebasing 3:a82ac2b38757 c "c"
75 note: not rebasing 4:76be324c128b d "d" and its descendants as this would cause divergence
76 rebasing 5:027ad6c5830d d' "d'"
77 rebasing 6:d60ebfa0f1cb e "e"
78 $ hg log -G -r 'a'::
79 o 11:eb6d63fc4ed5 e
80 |
81 o 10:44d8c724a70c d'
82 |
83 o 9:d008e6b4d3fd c
84 |
85 o 8:67e8f4a16c49 b
86 |
87 | * 7:1143e9adc121 f
88 | |
89 | | x 6:d60ebfa0f1cb e (rewritten using rebase as 11:eb6d63fc4ed5)
90 | | |
91 | | x 5:027ad6c5830d d' (rewritten using rebase as 10:44d8c724a70c)
92 | | |
93 | x | 4:76be324c128b d (rewritten using replace as 5:027ad6c5830d)
94 | |/
95 | x 3:a82ac2b38757 c (rewritten using rebase as 9:d008e6b4d3fd)
96 | |
97 o | 2:630d7c95eff7 x
98 | |
99 | x 1:488e1b7e7341 b (rewritten using rebase as 8:67e8f4a16c49)
100 |/
101 o 0:b173517d0057 a
102
103 $ hg strip -r 8:
104 $ hg log -G -r 'a'::
105 * 7:1143e9adc121 f
106 |
107 | o 6:d60ebfa0f1cb e
108 | |
109 | o 5:027ad6c5830d d'
110 | |
111 x | 4:76be324c128b d (rewritten using replace as 5:027ad6c5830d)
112 |/
113 o 3:a82ac2b38757 c
114 |
115 | o 2:630d7c95eff7 x
116 | |
117 o | 1:488e1b7e7341 b
118 |/
119 o 0:b173517d0057 a
120
121
122 If the rebase set has an obsolete (d) with a successor (d') outside the rebase
123 set and none in destination, we still get the divergence warning.
124 By allowing divergence, we can perform the rebase.
125
126 $ hg rebase -r 'c'::'f' -d 'x'
127 abort: this rebase will cause divergences from: 76be324c128b
128 (to force the rebase please set experimental.evolution.allowdivergence=True)
129 [20]
130 $ hg rebase --config experimental.evolution.allowdivergence=true -r 'c'::'f' -d 'x'
131 rebasing 3:a82ac2b38757 c "c"
132 rebasing 4:76be324c128b d "d"
133 rebasing 7:1143e9adc121 f tip "f"
134 1 new orphan changesets
135 2 new content-divergent changesets
136 $ hg log -G -r 'a':: -T instabilities
137 o 10:e1744ea07510 f
138 |
139 * 9:e2b36ea9a0a0 d (content-divergent)
140 |
141 o 8:6a0376de376e c
142 |
143 | x 7:1143e9adc121 f
144 | |
145 | | * 6:d60ebfa0f1cb e (orphan)
146 | | |
147 | | * 5:027ad6c5830d d' (orphan content-divergent)
148 | | |
149 | x | 4:76be324c128b d
150 | |/
151 | x 3:a82ac2b38757 c
152 | |
153 o | 2:630d7c95eff7 x
154 | |
155 | o 1:488e1b7e7341 b
156 |/
157 o 0:b173517d0057 a
158
159 $ hg strip -r 8:
160
161 (Not skipping obsoletes means that divergence is allowed.)
162
163 $ hg rebase --config experimental.rebaseskipobsolete=false -r 'c'::'f' -d 'x'
164 rebasing 3:a82ac2b38757 c "c"
165 rebasing 4:76be324c128b d "d"
166 rebasing 7:1143e9adc121 f tip "f"
167 1 new orphan changesets
168 2 new content-divergent changesets
169
170 $ hg strip -r 0:
171
172 Similar test on a more complex graph
173
174 $ hg debugdrawdag <<EOF
175 > g
176 > |
177 > f e
178 > | |
179 > e' d # replace: e -> e'
180 > \ /
181 > c
182 > |
183 > x b
184 > \|
185 > a
186 > EOF
187 1 new orphan changesets
188 $ hg log -G -r 'a':
189 * 8:2876ce66c6eb g
190 |
191 | o 7:3ffec603ab53 f
192 | |
193 x | 6:e36fae928aec e (rewritten using replace as 5:63324dc512ea)
194 | |
195 | o 5:63324dc512ea e'
196 | |
197 o | 4:76be324c128b d
198 |/
199 o 3:a82ac2b38757 c
200 |
201 | o 2:630d7c95eff7 x
202 | |
203 o | 1:488e1b7e7341 b
204 |/
205 o 0:b173517d0057 a
206
207 $ hg rebase -b 'f' -d 'x'
208 rebasing 1:488e1b7e7341 b "b"
209 rebasing 3:a82ac2b38757 c "c"
210 rebasing 4:76be324c128b d "d"
211 note: not rebasing 6:e36fae928aec e "e" and its descendants as this would cause divergence
212 rebasing 5:63324dc512ea e' "e'"
213 rebasing 7:3ffec603ab53 f "f"
214 $ hg log -G -r 'a':
215 o 13:ef6251596616 f
216 |
217 o 12:b6f172e64af9 e'
218 |
219 | o 11:a1707a5b7c2c d
220 |/
221 o 10:d008e6b4d3fd c
222 |
223 o 9:67e8f4a16c49 b
224 |
225 | * 8:2876ce66c6eb g
226 | |
227 | | x 7:3ffec603ab53 f (rewritten using rebase as 13:ef6251596616)
228 | | |
229 | x | 6:e36fae928aec e (rewritten using replace as 5:63324dc512ea)
230 | | |
231 | | x 5:63324dc512ea e' (rewritten using rebase as 12:b6f172e64af9)
232 | | |
233 | x | 4:76be324c128b d (rewritten using rebase as 11:a1707a5b7c2c)
234 | |/
235 | x 3:a82ac2b38757 c (rewritten using rebase as 10:d008e6b4d3fd)
236 | |
237 o | 2:630d7c95eff7 x
238 | |
239 | x 1:488e1b7e7341 b (rewritten using rebase as 9:67e8f4a16c49)
240 |/
241 o 0:b173517d0057 a
242
243
244 issue5782
245 $ hg strip -r 0:
246 $ hg debugdrawdag <<EOF
247 > d
248 > |
249 > c1 c # replace: c -> c1
250 > \ /
251 > b
252 > |
253 > a
254 > EOF
255 1 new orphan changesets
256 $ hg debugobsolete `hg log -T "{node}" --hidden -r 'desc("c1")'`
257 1 new obsolescence markers
258 obsoleted 1 changesets
259 $ hg log -G -r 'a': --hidden
260 * 4:76be324c128b d
261 |
262 | x 3:ef8a456de8fa c1 (pruned)
263 | |
264 x | 2:a82ac2b38757 c (rewritten using replace as 3:ef8a456de8fa)
265 |/
266 o 1:488e1b7e7341 b
267 |
268 o 0:b173517d0057 a
269
270 $ hg rebase -d 0 -r 2
271 note: not rebasing 2:a82ac2b38757 c "c", it has no successor
272 $ hg log -G -r 'a': --hidden
273 * 4:76be324c128b d
274 |
275 | x 3:ef8a456de8fa c1 (pruned)
276 | |
277 x | 2:a82ac2b38757 c (rewritten using replace as 3:ef8a456de8fa)
278 |/
279 o 1:488e1b7e7341 b
280 |
281 o 0:b173517d0057 a
282
283 $ cd ..
284
285 Start a normal rebase. When it runs into conflicts, rewrite one of the
286 commits in the rebase set, causing divergence when the rebase continues.
287
288 $ hg init $TESTTMP/new-divergence-after-conflict
289 $ cd $TESTTMP/new-divergence-after-conflict
290 $ hg debugdrawdag <<'EOS'
291 > C2
292 > | C1
293 > |/
294 > B # B/D=B
295 > | D
296 > |/
297 > A
298 > EOS
299 $ hg rebase -r B::C1 -d D
300 rebasing 1:2ec65233581b B "B"
301 merging D
302 warning: conflicts while merging D! (edit, then use 'hg resolve --mark')
303 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
304 [240]
305 $ hg debugobsolete $(hg log -r C1 -T '{node}') $(hg log -r C2 -T '{node}')
306 1 new obsolescence markers
307 obsoleted 1 changesets
308 $ hg log -G
309 o 4:fdb9df6b130c C2
310 |
311 | x 3:7e5bfd3c08f0 C1 (rewritten as 4:fdb9df6b130c)
312 |/
313 | @ 2:b18e25de2cf5 D
314 | |
315 % | 1:2ec65233581b B
316 |/
317 o 0:426bada5c675 A
318
319 $ echo resolved > D
320 $ hg resolve -m D
321 (no more unresolved files)
322 continue: hg rebase --continue
323 $ hg rebase -c
324 rebasing 1:2ec65233581b B "B"
325 note: not rebasing 3:7e5bfd3c08f0 C1 "C1" and its descendants as this would cause divergence
326 1 new orphan changesets
327
328 Rebase merge where successor of one parent is equal to destination (issue5198)
329
330 $ hg init p1-succ-is-dest
331 $ cd p1-succ-is-dest
332
333 $ hg debugdrawdag <<EOF
334 > F
335 > /|
336 > E D B # replace: D -> B
337 > \|/
338 > A
339 > EOF
340 1 new orphan changesets
341
342 $ hg rebase -d B -s D
343 note: not rebasing 2:b18e25de2cf5 D "D", already in destination as 1:112478962961 B "B"
344 rebasing 4:66f1a38021c9 F tip "F"
345 $ hg log -G
346 o 5:50e9d60b99c6 F
347 |\
348 | | x 4:66f1a38021c9 F (rewritten using rebase as 5:50e9d60b99c6)
349 | |/|
350 | o | 3:7fb047a69f22 E
351 | | |
352 | | x 2:b18e25de2cf5 D (rewritten using replace as 1:112478962961)
353 | |/
354 o | 1:112478962961 B
355 |/
356 o 0:426bada5c675 A
357
358 $ cd ..
359
360 Rebase merge where successor of other parent is equal to destination
361
362 $ hg init p2-succ-is-dest
363 $ cd p2-succ-is-dest
364
365 $ hg debugdrawdag <<EOF
366 > F
367 > /|
368 > E D B # replace: E -> B
369 > \|/
370 > A
371 > EOF
372 1 new orphan changesets
373
374 $ hg rebase -d B -s E
375 note: not rebasing 3:7fb047a69f22 E "E", already in destination as 1:112478962961 B "B"
376 rebasing 4:66f1a38021c9 F tip "F"
377 $ hg log -G
378 o 5:aae1787dacee F
379 |\
380 | | x 4:66f1a38021c9 F (rewritten using rebase as 5:aae1787dacee)
381 | |/|
382 | | x 3:7fb047a69f22 E (rewritten using replace as 1:112478962961)
383 | | |
384 | o | 2:b18e25de2cf5 D
385 | |/
386 o / 1:112478962961 B
387 |/
388 o 0:426bada5c675 A
389
390 $ cd ..
391
392 Rebase merge where successor of one parent is ancestor of destination
393
394 $ hg init p1-succ-in-dest
395 $ cd p1-succ-in-dest
396
397 $ hg debugdrawdag <<EOF
398 > F C
399 > /| |
400 > E D B # replace: D -> B
401 > \|/
402 > A
403 > EOF
404 1 new orphan changesets
405
406 $ hg rebase -d C -s D
407 note: not rebasing 2:b18e25de2cf5 D "D", already in destination as 1:112478962961 B "B"
408 rebasing 5:66f1a38021c9 F tip "F"
409
410 $ hg log -G
411 o 6:0913febf6439 F
412 |\
413 +---x 5:66f1a38021c9 F (rewritten using rebase as 6:0913febf6439)
414 | | |
415 | o | 4:26805aba1e60 C
416 | | |
417 o | | 3:7fb047a69f22 E
418 | | |
419 +---x 2:b18e25de2cf5 D (rewritten using replace as 1:112478962961)
420 | |
421 | o 1:112478962961 B
422 |/
423 o 0:426bada5c675 A
424
425 $ cd ..
426
427 Rebase merge where successor of other parent is ancestor of destination
428
429 $ hg init p2-succ-in-dest
430 $ cd p2-succ-in-dest
431
432 $ hg debugdrawdag <<EOF
433 > F C
434 > /| |
435 > E D B # replace: E -> B
436 > \|/
437 > A
438 > EOF
439 1 new orphan changesets
440
441 $ hg rebase -d C -s E
442 note: not rebasing 3:7fb047a69f22 E "E", already in destination as 1:112478962961 B "B"
443 rebasing 5:66f1a38021c9 F tip "F"
444 $ hg log -G
445 o 6:c6ab0cc6d220 F
446 |\
447 +---x 5:66f1a38021c9 F (rewritten using rebase as 6:c6ab0cc6d220)
448 | | |
449 | o | 4:26805aba1e60 C
450 | | |
451 | | x 3:7fb047a69f22 E (rewritten using replace as 1:112478962961)
452 | | |
453 o---+ 2:b18e25de2cf5 D
454 / /
455 o / 1:112478962961 B
456 |/
457 o 0:426bada5c675 A
458
459 $ cd ..
460
461 Rebase merge where successor of one parent is ancestor of destination
462
463 $ hg init p1-succ-in-dest-b
464 $ cd p1-succ-in-dest-b
465
466 $ hg debugdrawdag <<EOF
467 > F C
468 > /| |
469 > E D B # replace: E -> B
470 > \|/
471 > A
472 > EOF
473 1 new orphan changesets
474
475 $ hg rebase -d C -b F
476 rebasing 2:b18e25de2cf5 D "D"
477 note: not rebasing 3:7fb047a69f22 E "E", already in destination as 1:112478962961 B "B"
478 rebasing 5:66f1a38021c9 F tip "F"
479 note: not rebasing 5:66f1a38021c9 F tip "F", its destination already has all its changes
480 $ hg log -G
481 o 6:8f47515dda15 D
482 |
483 | x 5:66f1a38021c9 F (pruned using rebase)
484 | |\
485 o | | 4:26805aba1e60 C
486 | | |
487 | | x 3:7fb047a69f22 E (rewritten using replace as 1:112478962961)
488 | | |
489 | x | 2:b18e25de2cf5 D (rewritten using rebase as 6:8f47515dda15)
490 | |/
491 o / 1:112478962961 B
492 |/
493 o 0:426bada5c675 A
494
495 $ cd ..
496
497 Rebase merge where successor of other parent is ancestor of destination
498
499 $ hg init p2-succ-in-dest-b
500 $ cd p2-succ-in-dest-b
501
502 $ hg debugdrawdag <<EOF
503 > F C
504 > /| |
505 > E D B # replace: D -> B
506 > \|/
507 > A
508 > EOF
509 1 new orphan changesets
510
511 $ hg rebase -d C -b F
512 note: not rebasing 2:b18e25de2cf5 D "D", already in destination as 1:112478962961 B "B"
513 rebasing 3:7fb047a69f22 E "E"
514 rebasing 5:66f1a38021c9 F tip "F"
515 note: not rebasing 5:66f1a38021c9 F tip "F", its destination already has all its changes
516
517 $ hg log -G
518 o 6:533690786a86 E
519 |
520 | x 5:66f1a38021c9 F (pruned using rebase)
521 | |\
522 o | | 4:26805aba1e60 C
523 | | |
524 | | x 3:7fb047a69f22 E (rewritten using rebase as 6:533690786a86)
525 | | |
526 | x | 2:b18e25de2cf5 D (rewritten using replace as 1:112478962961)
527 | |/
528 o / 1:112478962961 B
529 |/
530 o 0:426bada5c675 A
531
532 $ cd ..
533
534 Rebase merge where extinct node has successor that is not an ancestor of
535 destination
536
537 $ hg init extinct-with-succ-not-in-dest
538 $ cd extinct-with-succ-not-in-dest
539
540 $ hg debugdrawdag <<EOF
541 > E C # replace: C -> E
542 > | |
543 > D B
544 > |/
545 > A
546 > EOF
547
548 $ hg rebase -d D -s B
549 rebasing 1:112478962961 B "B"
550 note: not rebasing 3:26805aba1e60 C "C" and its descendants as this would cause divergence
551
552 $ cd ..
553
554 $ hg init p2-succ-in-dest-c
555 $ cd p2-succ-in-dest-c
556
557 The scenario here was that B::D were developed on default. B was queued on
558 stable, but amended before being push to hg-committed. C was queued on default,
559 along with unrelated J.
560
561 $ hg debugdrawdag <<EOF
562 > J
563 > |
564 > F
565 > |
566 > E
567 > | D
568 > | |
569 > | C # replace: C -> F
570 > | | H I # replace: B -> H -> I
571 > | B |/
572 > |/ G
573 > A
574 > EOF
575 1 new orphan changesets
576
577 This strip seems to be the key to avoid an early divergence warning.
578 $ hg --config extensions.strip= --hidden strip -qr H
579 1 new orphan changesets
580
581 $ hg rebase -b 'desc("D")' -d 'desc("J")'
582 abort: this rebase will cause divergences from: 112478962961
583 (to force the rebase please set experimental.evolution.allowdivergence=True)
584 [20]
585
586 Rebase merge where both parents have successors in destination
587
588 $ hg init p12-succ-in-dest
589 $ cd p12-succ-in-dest
590 $ hg debugdrawdag <<'EOS'
591 > E F
592 > /| /| # replace: A -> C
593 > A B C D # replace: B -> D
594 > | |
595 > X Y
596 > EOS
597 1 new orphan changesets
598 $ hg rebase -r A+B+E -d F
599 note: not rebasing 4:a3d17304151f A "A", already in destination as 0:96cc3511f894 C "C"
600 note: not rebasing 5:b23a2cc00842 B "B", already in destination as 1:058c1e1fb10a D "D"
601 rebasing 7:dac5d11c5a7d E tip "E"
602 abort: rebasing 7:dac5d11c5a7d will include unwanted changes from 3:59c792af609c, 5:b23a2cc00842 or 2:ba2b7fa7166d, 4:a3d17304151f
603 [10]
604 $ cd ..
605
606 Rebase a non-clean merge. One parent has successor in destination, the other
607 parent moves as requested.
608
609 $ hg init p1-succ-p2-move
610 $ cd p1-succ-p2-move
611 $ hg debugdrawdag <<'EOS'
612 > D Z
613 > /| | # replace: A -> C
614 > A B C # D/D = D
615 > EOS
616 1 new orphan changesets
617 $ hg rebase -r A+B+D -d Z
618 note: not rebasing 0:426bada5c675 A "A", already in destination as 2:96cc3511f894 C "C"
619 rebasing 1:fc2b737bb2e5 B "B"
620 rebasing 3:b8ed089c80ad D "D"
621
622 $ rm .hg/localtags
623 $ hg log -G
624 o 6:e4f78693cc88 D
625 |
626 o 5:76840d832e98 B
627 |
628 o 4:50e41c1f3950 Z
629 |
630 o 2:96cc3511f894 C
631
632 $ hg files -r tip
633 B
634 C
635 D
636 Z
637
638 $ cd ..
639
640 $ hg init p1-move-p2-succ
641 $ cd p1-move-p2-succ
642 $ hg debugdrawdag <<'EOS'
643 > D Z
644 > /| | # replace: B -> C
645 > A B C # D/D = D
646 > EOS
647 1 new orphan changesets
648 $ hg rebase -r B+A+D -d Z
649 rebasing 0:426bada5c675 A "A"
650 note: not rebasing 1:fc2b737bb2e5 B "B", already in destination as 2:96cc3511f894 C "C"
651 rebasing 3:b8ed089c80ad D "D"
652
653 $ rm .hg/localtags
654 $ hg log -G
655 o 6:1b355ed94d82 D
656 |
657 o 5:a81a74d764a6 A
658 |
659 o 4:50e41c1f3950 Z
660 |
661 o 2:96cc3511f894 C
662
663 $ hg files -r tip
664 A
665 C
666 D
667 Z
668
669 $ cd ..