changeset 14542:afe0d4c24866

revert: drop requirement to use -r to revert with two parents This reduces documentation confusion between the need to: a) hg revert -a -r . (drop all changes from a merge) b) hg up -C . (drop the second parent entirely) Currently revert is one of two commands (the other being tag) that still complains about uncommitted merges, dating from its former use of a generic defaultrev function that aborted.
author Matt Mackall <mpm@selenic.com>
date Tue, 07 Jun 2011 14:19:05 -0500
parents 07ee46a2ece3
children 691925bd8bb8
files mercurial/commands.py tests/test-confused-revert.t tests/test-revert.t
diffstat 3 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Jun 07 14:18:39 2011 -0500
+++ b/mercurial/commands.py	Tue Jun 07 14:19:05 2011 -0500
@@ -4093,11 +4093,9 @@
        To cancel a merge (and lose your changes), use :hg:`update --clean .`.
 
     With no revision specified, revert the named files or directories
-    to the contents they had in the parent of the working directory.
+    to the contents they had in the first parent of the working directory.
     This restores the contents of the affected files to an unmodified
-    state and unschedules adds, removes, copies, and renames. If the
-    working directory has two parents, you must explicitly specify a
-    revision.
+    state and unschedules adds, removes, copies, and renames.
 
     Using the -r/--rev option, revert the given files or directories
     to their contents as of a specific revision. This can be helpful
@@ -4129,13 +4127,10 @@
         opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
 
     parent, p2 = repo.dirstate.parents()
-    if not opts.get('rev') and p2 != nullid:
-        raise util.Abort(_('uncommitted merge - '
-                           'use "hg update", see "hg help revert"'))
 
     if not pats and not opts.get('all'):
-        raise util.Abort(_('no files or directories specified; '
-                           'use --all to revert the whole repo'))
+        raise util.Abort(_('no files or directories specified'),
+                         hint=_('use --all to revert all files'))
 
     ctx = scmutil.revsingle(repo, opts.get('rev'))
     node = ctx.node()
--- a/tests/test-confused-revert.t	Tue Jun 07 14:18:39 2011 -0500
+++ b/tests/test-confused-revert.t	Tue Jun 07 14:19:05 2011 -0500
@@ -59,7 +59,8 @@
 Revert should fail:
 
   $ hg revert
-  abort: uncommitted merge - use "hg update", see "hg help revert"
+  abort: no files or directories specified
+  (use --all to revert all files)
   [255]
 
 Revert should be ok now:
--- a/tests/test-revert.t	Tue Jun 07 14:18:39 2011 -0500
+++ b/tests/test-revert.t	Tue Jun 07 14:19:05 2011 -0500
@@ -185,7 +185,8 @@
 should fail - no arguments
 
   $ hg revert -rtip
-  abort: no files or directories specified; use --all to revert the whole repo
+  abort: no files or directories specified
+  (use --all to revert all files)
   [255]
 
 should succeed