changeset 38946:f3f109971359

grep: add MULTIREV support to --allfiles flag This patch facilitates passing multiple revisions with all-files flag. It's assumed that if you are passing multiple revisions to --allfiles, you want hits from all of them. Differential Revision: https://phab.mercurial-scm.org/D3976
author Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
date Wed, 25 Jul 2018 12:50:31 +0530
parents 0dce1297dd01
children f9a98075a37e
files mercurial/cmdutil.py mercurial/commands.py tests/test-grep.t
diffstat 3 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Jul 25 10:34:31 2018 +0200
+++ b/mercurial/cmdutil.py	Wed Jul 25 12:50:31 2018 +0530
@@ -1889,9 +1889,6 @@
     revs = _walkrevs(repo, opts)
     if not revs:
         return []
-    if allfiles and len(revs) > 1:
-        raise error.Abort(_("multiple revisions not supported with "
-                            "--all-files"))
     wanted = set()
     slowpath = match.anypats() or (not match.always() and opts.get('removed'))
     fncache = {}
--- a/mercurial/commands.py	Wed Jul 25 10:34:31 2018 +0200
+++ b/mercurial/commands.py	Wed Jul 25 12:50:31 2018 +0530
@@ -2533,6 +2533,7 @@
     """
     opts = pycompat.byteskwargs(opts)
     diff = opts.get('all') or opts.get('diff')
+    all_files = opts.get('all_files')
     if diff and opts.get('all_files'):
         raise error.Abort(_('--diff and --all-files are mutually exclusive'))
     # TODO: remove "not opts.get('rev')" if --all-files -rMULTIREV gets working
@@ -2757,7 +2758,7 @@
             if pstates or states:
                 r = display(fm, fn, ctx, pstates, states)
                 found = found or r
-                if r and not diff:
+                if r and not diff and not all_files:
                     skip[fn] = True
                     if copy:
                         skip[copy] = True
--- a/tests/test-grep.t	Wed Jul 25 10:34:31 2018 +0200
+++ b/tests/test-grep.t	Wed Jul 25 12:50:31 2018 +0530
@@ -491,3 +491,13 @@
   ]
 
   $ cd ..
+
+test -rMULTIREV with --all-files
+
+  $ cd sng
+  $ hg rm um
+  $ hg commit -m "deletes um"
+  $ hg grep -r "0:2" "unmod" --all-files
+  um:0:unmod
+  um:1:unmod
+  $ cd ..