Patchwork [stable] revert: accept just -I/-X without paths or -a/-i (issue4592)

login
register
mail settings
Submitter Martin von Zweigbergk
Date April 22, 2015, 11:42 p.m.
Message ID <e70dc166aab563b700e2.1429746162@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8768/
State Accepted
Headers show

Comments

Martin von Zweigbergk - April 22, 2015, 11:42 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1429745916 25200
#      Wed Apr 22 16:38:36 2015 -0700
# Branch stable
# Node ID e70dc166aab563b700e203db2892386a490033aa
# Parent  1f9127c9239b9c39c676bb09752db1e2ca6c26f7
revert: accept just -I/-X without paths or -a/-i (issue4592)

'hg revert -I foo' currently fails with

  abort: no files or directories specified
  (use --all to revert all files, or 'hg update 1' to update)

It doesn't seem intentional that -I/-X without other paths or
--all/--interactive should fail, and it doesn't seem that harmful to
allow it either, so let's just do that.
Durham Goode - April 23, 2015, 1:47 a.m.
On 4/22/15 4:42 PM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1429745916 25200
> #      Wed Apr 22 16:38:36 2015 -0700
> # Branch stable
> # Node ID e70dc166aab563b700e203db2892386a490033aa
> # Parent  1f9127c9239b9c39c676bb09752db1e2ca6c26f7
> revert: accept just -I/-X without paths or -a/-i (issue4592)
>
> 'hg revert -I foo' currently fails with
>
>    abort: no files or directories specified
>    (use --all to revert all files, or 'hg update 1' to update)
>
> It doesn't seem intentional that -I/-X without other paths or
> --all/--interactive should fail, and it doesn't seem that harmful to
> allow it either, so let's just do that.
>
Pushed to the clowncopter. Thanks for fixing this so quickly!

Patch

diff -r 1f9127c9239b -r e70dc166aab5 mercurial/commands.py
--- a/mercurial/commands.py	Wed Apr 22 23:38:55 2015 +0900
+++ b/mercurial/commands.py	Wed Apr 22 16:38:36 2015 -0700
@@ -5511,7 +5511,8 @@ 
 
     ctx = scmutil.revsingle(repo, opts.get('rev'))
 
-    if not pats and not (opts.get('all') or opts.get('interactive')):
+    if (not (pats or opts.get('include') or opts.get('exclude') or
+             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,"
diff -r 1f9127c9239b -r e70dc166aab5 tests/test-revert.t
--- a/tests/test-revert.t	Wed Apr 22 23:38:55 2015 +0900
+++ b/tests/test-revert.t	Wed Apr 22 16:38:36 2015 -0700
@@ -201,12 +201,26 @@ 
   (use --all to revert all files, or 'hg update 1' to update)
   [255]
 
+call `hg revert` with -I
+---------------------------
+
+  $ echo a >> a
+  $ hg revert -I a
+  reverting a
+
+call `hg revert` with -X
+---------------------------
+
+  $ echo a >> a
+  $ hg revert -X d
+  reverting a
+
 call `hg revert` with --all
 ---------------------------
 
   $ hg revert --all -rtip
   reverting a
-
+  $ rm *.orig
 
 Issue332: confusing message when reverting directory
 ----------------------------------------------------