[PATCH] walkchangerevs: obey allfiles parameter when taking the slow path

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] walkchangerevs: obey allfiles parameter when taking the slow path

Jordi Gutiérrez Hermoso
# HG changeset patch
# User Jordi Gutiérrez Hermoso <[hidden email]>
# Date 1550009431 18000
#      Tue Feb 12 17:10:31 2019 -0500
# Node ID 06f76b4009c4802a48abc184984d0eebc7d7d91e
# Parent  61415361e90684a8c7a031413e9182f51937c2e7
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.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1961,7 +1961,10 @@ def walkchangerevs(repo, match, opts, pr
                 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)
diff --git a/tests/test-grep.t b/tests/test-grep.t
--- a/tests/test-grep.t
+++ b/tests/test-grep.t
@@ -517,5 +517,8 @@ test -rMULTIREV with --all-files
   $ 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 ..
 
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] walkchangerevs: obey allfiles parameter when taking the slow path

Yuya Nishihara
On Tue, 12 Feb 2019 17:20:56 -0500, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <[hidden email]>
> # Date 1550009431 18000
> #      Tue Feb 12 17:10:31 2019 -0500
> # Node ID 06f76b4009c4802a48abc184984d0eebc7d7d91e
> # Parent  61415361e90684a8c7a031413e9182f51937c2e7
> walkchangerevs: obey allfiles parameter when taking the slow path

Queued, thanks.
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel