# HG changeset patch # User Adrian Buehlmann # Date 1309043610 -7200 # Node ID 6ba51c81ff752aeeeb0611a117f070d774e6418e # Parent 189a7562d72ee1d3ce42daa8641a574da68cf906 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) diff -r 189a7562d72e -r 6ba51c81ff75 mercurial/commands.py --- 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() diff -r 189a7562d72e -r 6ba51c81ff75 tests/test-revert.t --- 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