changeset 19518:12843143663d stable

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.
author Matt Mackall <mpm@selenic.com>
date Thu, 01 Aug 2013 17:54:12 -0500
parents eab2ff59481e
children c2a479a058d0
files hgext/rebase.py tests/test-rebase-interruptions.t
diffstat 2 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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'