changeset 26677:e9b3d523f2e6

rebase: properly abort when destination is public (issue4896) After rebasing a set of changes onto a public changeset and having the first one be skipped, if you try to abort, the operation fails. This fix adds a check to disallow the target rev into the dstates list within the abort function. This list is checked for immutable states before the rest of abort does its thing.
author Christian Delahousse <cdelahousse@fb.com>
date Tue, 13 Oct 2015 14:06:51 -0700
parents 71a485130beb
children 613d850cce53
files hgext/rebase.py tests/test-rebase-abort.t
diffstat 2 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Wed Oct 14 18:03:17 2015 -0500
+++ b/hgext/rebase.py	Tue Oct 13 14:06:51 2015 -0700
@@ -920,7 +920,11 @@
 
     activebookmark: the name of the bookmark that should be active after the
         restore'''
-    dstates = [s for s in state.values() if s >= 0]
+
+    # If the first commits in the rebased set get skipped during the rebase,
+    # their values within the state mapping will be the target rev id. The
+    # dstates list must must not contain the target rev (issue4896)
+    dstates = [s for s in state.values() if s >= 0 and s != target]
     immutable = [d for d in dstates if not repo[d].mutable()]
     cleanup = True
     if immutable:
--- a/tests/test-rebase-abort.t	Wed Oct 14 18:03:17 2015 -0500
+++ b/tests/test-rebase-abort.t	Tue Oct 13 14:06:51 2015 -0700
@@ -318,3 +318,37 @@
   commit: (clean)
   update: 1 new changesets, 2 branch heads (merge)
   phases: 4 draft
+
+test aborting a rebase succeeds after rebasing with skipped commits onto a
+public changeset (issue4896)
+
+  $ hg init succeedonpublic
+  $ cd succeedonpublic
+  $ echo 'content' > root
+  $ hg commit -A -m 'root' -q
+
+set up public branch
+  $ echo 'content' > disappear
+  $ hg commit -A -m 'disappear public' -q
+commit will cause merge conflict on rebase
+  $ echo '' > root
+  $ hg commit -m 'remove content public' -q
+  $ hg phase --public
+
+setup the draft branch that will be rebased onto public commit
+  $ hg up -r 0 -q
+  $ echo 'content' > disappear
+commit will disappear
+  $ hg commit -A -m 'disappear draft' -q
+  $ echo 'addedcontADDEDentadded' > root
+commit will cause merge conflict on rebase
+  $ hg commit -m 'add content draft' -q
+
+  $ hg rebase -d 'public()' --tool :merge -q
+  note: rebase of 3:0682fd3dabf5 created no changes to commit
+  warning: conflicts while merging root! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --abort
+  rebase aborted
+