tests: test divergence created during interrupted rebase
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 23 Mar 2021 10:12:58 -0700
changeset 46830 6648307d4fe8
parent 46829 13b200ffe8eb
child 46831 7d80622fc212
tests: test divergence created during interrupted rebase If a rebase runs into conflicts and the user somehow rewrites an unrebased commit in the rebase set while the rebase is interrupted, continuing it might result in divergence. It turns out that we decide to skip the commit. That seems to make sense, but it wasn't obvious to me that that's what we should do. Either way, this patch adds a test case for the current behavior. Differential Revision: https://phab.mercurial-scm.org/D10256
tests/test-rebase-obsolete3.t
--- a/tests/test-rebase-obsolete3.t	Tue Mar 23 09:13:29 2021 -0700
+++ b/tests/test-rebase-obsolete3.t	Tue Mar 23 10:12:58 2021 -0700
@@ -282,6 +282,49 @@
   
   $ cd ..
 
+Start a normal rebase. When it runs into conflicts, rewrite one of the
+commits in the rebase set, causing divergence when the rebase continues.
+
+  $ hg init $TESTTMP/new-divergence-after-conflict
+  $ cd $TESTTMP/new-divergence-after-conflict
+  $ hg debugdrawdag <<'EOS'
+  >  C2
+  >  | C1
+  >  |/
+  >  B # B/D=B
+  >  | D
+  >  |/
+  >  A
+  > EOS
+  $ hg rebase -r B::C1 -d D
+  rebasing 1:2ec65233581b B "B"
+  merging D
+  warning: conflicts while merging D! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
+  [240]
+  $ hg debugobsolete $(hg log -r C1 -T '{node}') $(hg log -r C2 -T '{node}')
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg log -G
+  o  4:fdb9df6b130c C2
+  |
+  | x  3:7e5bfd3c08f0 C1 (rewritten as 4:fdb9df6b130c)
+  |/
+  | @  2:b18e25de2cf5 D
+  | |
+  % |  1:2ec65233581b B
+  |/
+  o  0:426bada5c675 A
+  
+  $ echo resolved > D
+  $ hg resolve -m D
+  (no more unresolved files)
+  continue: hg rebase --continue
+  $ hg rebase -c
+  rebasing 1:2ec65233581b B "B"
+  note: not rebasing 3:7e5bfd3c08f0 C1 "C1" and its descendants as this would cause divergence
+  1 new orphan changesets
+
 Rebase merge where successor of one parent is equal to destination (issue5198)
 
   $ hg init p1-succ-is-dest