changeset 41683:5d383d9636d0

walkchangerevs: obey allfiles parameter when taking the slow path When walkchangerevs sees that there's a pattern, it hits the slow path. The slow path in turn reverts to the old dumb grep behaviour of only looking at files changed at each revision. Therefore, a command such as hg grep -l --all-files '.*' 'glob:**' would show you all the nonempty files touched by the current revision. This modifies that behaviour to look at the manifest at each revision instead of the changed files in case that --all-files was requested.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 12 Feb 2019 17:10:31 -0500
parents 1ab6f5df263e
children a8d3a4be066e
files mercurial/cmdutil.py tests/test-grep.t
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Fri Feb 08 18:26:35 2019 +0100
+++ b/mercurial/cmdutil.py	Tue Feb 12 17:10:31 2019 -0500
@@ -1961,7 +1961,10 @@
                 else:
                     self.revs.discard(value)
                     ctx = change(value)
-                    matches = [f for f in ctx.files() if match(f)]
+                    if allfiles:
+                        matches = list(ctx.manifest().walk(match))
+                    else:
+                        matches = [f for f in ctx.files() if match(f)]
                     if matches:
                         fncache[value] = matches
                         self.set.add(value)
--- a/tests/test-grep.t	Fri Feb 08 18:26:35 2019 +0100
+++ b/tests/test-grep.t	Tue Feb 12 17:10:31 2019 -0500
@@ -517,5 +517,8 @@
   $ hg grep -r "0:2" "unmod" --all-files um
   um:0:unmod
   um:1:unmod
+  $ hg grep -r "0:2" "unmod" --all-files "glob:**/um" # Check that patterns also work
+  um:0:unmod
+  um:1:unmod
   $ cd ..