[PATCH] rebase: improve error message on improper phases

Dan Villiom Podlaski Christiansen dan at cabo.dk
Mon Jun 18 04:16:58 CDT 2012


# HG changeset patch
# User Dan Villiom Podlaski Christiansen <dan at cabo.dk>
# Date 1340010984 -7200
# Node ID d7c24017dfd67c724938a0075117b1f611a18120
# Parent  921458360270c650fcc00a31648a52e0e0cd9bae
rebase: improve error message on improper phases

The previous error message had two issues: The first issue was that it
wasn't, in fact, an error but a warning, even though it described a
fatal error condition preventing the successful completion of the
command. The second was that it didn't mention the immutable
changesets, leaving the user guessing at the true cause of the error.

The main downside to this change is that we now get an 'abort: can't
abort...' message which technically contradicts itself. In this case,
I blame that on the two uses we have for the word; if it weren't for
backwards compatibility, we could make util.Abort print out 'error:
<whatever>'.

diff -r 921458360270 -r d7c24017dfd6 hgext/rebase.py
--- a/hgext/rebase.py	Mon Jun 18 03:42:28 2012 +0200
+++ b/hgext/rebase.py	Mon Jun 18 11:16:24 2012 +0200
@@ -568,10 +568,11 @@ def restorestatus(repo):
 def abort(repo, originalwd, target, state):
     'Restore the repository to its original state'
     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
+    immutable = [d for d in dstates if not repo[d].mutable()]
+    if immutable:
+        raise util.Abort(_("can't abort rebase due to immutable changesets %s")
+                         % ', '.join(str(repo[r]) for r in immutable),
+                         hint=_('see hg help phases for details'))
 
     descendants = set()
     if dstates:
diff -r 921458360270 -r d7c24017dfd6 tests/test-rebase-interruptions.t
--- a/tests/test-rebase-interruptions.t	Mon Jun 18 03:42:28 2012 +0200
+++ b/tests/test-rebase-interruptions.t	Mon Jun 18 11:16:24 2012 +0200
@@ -248,7 +248,8 @@ Change phase on B and B'
 Abort the rebasing:
 
   $ hg rebase --abort
-  warning: immutable rebased changeset detected, can't abort
+  abort: can't abort rebase due to immutable changesets 45396c49d53b
+  (see hg help phases for details)
   [255]
 
   $ hg tglogp


More information about the Mercurial-devel mailing list