diff mercurial/commands.py @ 14755:6ba51c81ff75 stable

revert: improve hints on abort when reverting to parent without --all BEFORE: $ hg revert abort: no files or directories specified (use --all to discard all changes) AFTER: Uncommitted changes (using --all *will* nuke edits): $ hg revert abort: no files or directories specified (uncommitted changes, use --all to discard all changes) Clean working directory (using --all won't discard anything): $ hg revert abort: no files or directories specified (use --all to revert all files)
author Adrian Buehlmann <adrian@cadifra.com>
date Sun, 26 Jun 2011 01:13:30 +0200
parents 271424fdbeec
children 11b5a5d2ca8b d87814992728
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Jun 24 19:44:59 2011 +0300
+++ b/mercurial/commands.py	Sun Jun 26 01:13:30 2011 +0200
@@ -4184,17 +4184,22 @@
 
     if not pats and not opts.get('all'):
         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")
-        elif node != parent:
-            if util.any(repo.status()):
+            raise util.Abort(msg, hint=hint)
+        dirty = util.any(repo.status())
+        if node != parent:
+            if dirty:
                 hint = _("uncommitted changes, use --all to discard all"
                          " changes, or 'hg update %s' to update") % ctx.rev()
             else:
                 hint = _("use --all to revert all files,"
                          " or 'hg update %s' to update") % ctx.rev()
+        elif dirty:
+            hint = _("uncommitted changes, use --all to discard all changes")
+        else:
+            hint = _("use --all to revert all files")
         raise util.Abort(msg, hint=hint)
 
     mf = ctx.manifest()