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)
--- 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()
--- a/tests/test-revert.t Fri Jun 24 19:44:59 2011 +0300
+++ b/tests/test-revert.t Sun Jun 26 01:13:30 2011 +0200
@@ -10,7 +10,7 @@
$ hg revert
abort: no files or directories specified
- (use --all to discard all changes)
+ (use --all to revert all files)
[255]
$ echo 123 > b