changeset 14721:4fcde634f5e0 stable

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)
author Adrian Buehlmann <adrian@cadifra.com>
date Wed, 22 Jun 2011 15:34:33 +0200
parents 36283a7b6856
children b6dc362b051c
files mercurial/commands.py tests/test-confused-revert.t
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Jun 22 10:13:44 2011 +0200
+++ b/mercurial/commands.py	Wed Jun 22 15:34:33 2011 +0200
@@ -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()
--- a/tests/test-confused-revert.t	Wed Jun 22 10:13:44 2011 +0200
+++ b/tests/test-confused-revert.t	Wed Jun 22 15:34:33 2011 +0200
@@ -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: