[PATCH] revert: be more helpful on uncommitted merges

Adrian Buehlmann adrian at cadifra.com
Wed Jun 22 09:05:29 CDT 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1308749673 -7200
# Node ID 37ca9f5b44d4f9b722d4103136875eae51ef599b
# Parent  8deebb5777511369a852e5cb42e69844c40ebf7a
revert: be more helpful on uncommitted merges

 BEFORE:
   $ hg revert
   abort: no files or directories specified
   (use --all to discard all changes)

 AFTER:
   $ hg revert
   abort: no files or directories specified
   (uncommitted merge, use --all to discard all changes, or 'hg update -C .' to abort the merge)

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4181,8 +4181,12 @@
     parent, p2 = repo.dirstate.parents()
 
     if not pats and not opts.get('all'):
-        raise util.Abort(_('no files or directories specified'),
-                         hint=_('use --all to discard all changes'))
+        msg = _("no files or directories specified")
+        hint = _("use --all to discard all changes")
+        if p2 != nullid:
+            hint = _("uncommitted merge, use --all to discard all changes,"
+                     " or 'hg update -C .' to abort the merge")
+        raise util.Abort(msg, hint=hint)
 
     ctx = scmutil.revsingle(repo, opts.get('rev'))
     node = ctx.node()
diff --git a/tests/test-confused-revert.t b/tests/test-confused-revert.t
--- a/tests/test-confused-revert.t
+++ b/tests/test-confused-revert.t
@@ -60,7 +60,7 @@
 
   $ hg revert
   abort: no files or directories specified
-  (use --all to discard all changes)
+  (uncommitted merge, use --all to discard all changes, or 'hg update -C .' to abort the merge)
   [255]
 
 Revert should be ok now:


More information about the Mercurial-devel mailing list