rebase: allow aborting when descendants detected stable
authorMatt Mackall <mpm@selenic.com>
Thu, 01 Aug 2013 17:54:12 -0500
branchstable
changeset 19518 12843143663d
parent 19517 eab2ff59481e
child 19519 c2a479a058d0
rebase: allow aborting when descendants detected With this, all aborts will succeed in removing the state, rather than leaving the user in 'what do I do now?' limbo.
hgext/rebase.py
tests/test-rebase-interruptions.t
--- a/hgext/rebase.py	Thu Aug 01 17:45:13 2013 -0500
+++ b/hgext/rebase.py	Thu Aug 01 17:54:12 2013 -0500
@@ -608,32 +608,36 @@
     'Restore the repository to its original state'
     dstates = [s for s in state.values() if s != nullrev]
     immutable = [d for d in dstates if not repo[d].mutable()]
+    cleanup = True
     if immutable:
         repo.ui.warn(_("warning: can't clean up immutable changesets %s\n")
                      % ', '.join(str(repo[r]) for r in immutable),
                      hint=_('see hg help phases for details'))
+        cleanup = False
 
     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"))
-        return -1
-    else:
+                       "can't strip\n"))
+        cleanup = False
+
+    if cleanup:
         # Update away from the rebase if necessary
-        if not immutable and inrebase(repo, originalwd, state):
+        if inrebase(repo, originalwd, state):
             merge.update(repo, repo[originalwd].rev(), False, True, False)
 
         # Strip from the first rebased revision
         rebased = filter(lambda x: x > -1 and x != target, state.values())
-        if rebased and not immutable:
+        if rebased:
             strippoints = [c.node()  for c in repo.set('roots(%ld)', rebased)]
             # no backup of rebased cset versions needed
             repair.strip(repo.ui, repo, strippoints)
-        clearstatus(repo)
-        repo.ui.warn(_('rebase aborted\n'))
-        return 0
+
+    clearstatus(repo)
+    repo.ui.warn(_('rebase aborted\n'))
+    return 0
 
 def buildstate(repo, dest, rebaseset, collapse):
     '''Define which revisions are going to be rebased and where
--- a/tests/test-rebase-interruptions.t	Thu Aug 01 17:45:13 2013 -0500
+++ b/tests/test-rebase-interruptions.t	Thu Aug 01 17:54:12 2013 -0500
@@ -180,8 +180,8 @@
 Abort the rebasing:
 
   $ hg rebase --abort
-  warning: new changesets detected on target branch, can't abort
-  [255]
+  warning: new changesets detected on target branch, can't strip
+  rebase aborted
 
   $ hg tglog
   @  6: 'Extra'