[PATCH] revert: do not requires '--all' if '--interative' is present

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sat Apr 11 16:32:56 UTC 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1428769614 14400
#      Sat Apr 11 12:26:54 2015 -0400
# Node ID 83a202ecaff8e5fb3328a931d6c414960a5a0d30
# Parent  207e295aecc5bc8e728ec4c58674171167d034a5
revert: do not requires '--all' if '--interative' is present

The '--all' option have been introduced in 890e285c52a1 (August 2006), most
probably to prevent user shotting themselves in the foot. As the record process
will let you, view and select the set of files and change you want to revert, I
feel like the '--all' flag is superfluous in the '--interactive' case.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5512,11 +5512,11 @@ def revert(ui, repo, *pats, **opts):
         raise util.Abort(_('uncommitted merge with no revision specified'),
                          hint=_('use "hg update" or see "hg help revert"'))
 
     ctx = scmutil.revsingle(repo, opts.get('rev'))
 
-    if not pats and not opts.get('all'):
+    if not pats and not (opts.get('all') or opts.get('interactive')):
         msg = _("no files or directories specified")
         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)
diff --git a/tests/test-revert-interactive.t b/tests/test-revert-interactive.t
--- a/tests/test-revert-interactive.t
+++ b/tests/test-revert-interactive.t
@@ -119,10 +119,25 @@ 10 run the same test than 8 from within 
   2
   3
   4
   5
   f
+
+Test that --interative lift the need for --all
+
+  $ echo q | hg revert -i -r 2
+  reverting folder1/g (glob)
+  reverting folder2/h (glob)
+  diff -r 89ac3d72e4a4 folder1/g
+  1 hunks, 1 lines changed
+  examine changes to 'folder1/g'? [Ynesfdaq?] q
+  
+  abort: user quit
+  [255]
+  $ rm folder1/g.orig
+
+
   $ hg update -C 6
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg revert -i -r 2 --all -- << EOF
   > y
   > y


More information about the Mercurial-devel mailing list