rebase: properly calculate descendant set when aborting (issue3332) stable
authorMatt Mackall <mpm@selenic.com>
Thu, 22 Mar 2012 17:47:00 -0500
branchstable
changeset 16280 0806823370d8
parent 16278 900eee0778d1
child 16281 d8cc67114dc3
rebase: properly calculate descendant set when aborting (issue3332) Checking for descendants of target being public was also wrong.
hgext/rebase.py
--- a/hgext/rebase.py	Thu Mar 22 17:07:39 2012 -0500
+++ b/hgext/rebase.py	Thu Mar 22 17:47:00 2012 -0500
@@ -557,15 +557,18 @@
 
 def abort(repo, originalwd, target, state):
     'Restore the repository to its original state'
-    descendants = repo.changelog.descendants
-    ispublic = lambda r: repo._phaserev[r] == phases.public
-    if filter(ispublic, descendants(target)):
+    dstates = [s for s in state.values() if s != nullrev]
+    if [d for d in dstates if not repo[d].mutable()]:
         repo.ui.warn(_("warning: immutable rebased changeset detected, "
                        "can't abort\n"))
         return -1
-    elif set(descendants(target)) - set(state.values()):
+
+    descendants = set()
+    if dstates:
+        descendants = set(repo.changelog.descendants(*dstates))
+    if descendants - set(dstates):
         repo.ui.warn(_("warning: new changesets detected on target branch, "
-                                                    "can't abort\n"))
+                       "can't abort\n"))
         return -1
     else:
         # Strip from the first rebased revision