Patchwork [1,of,6] grep: add option for logcmdutil.makewalker() to not filter revs by file pats

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 3, 2020, 4:10 a.m.
Message ID <14815a48ad0acf0e4e4d.1601698205@mimosa>
Download mbox | patch
Permalink /patch/47369/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 3, 2020, 4:10 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1599730801 -32400
#      Thu Sep 10 18:40:01 2020 +0900
# Node ID 14815a48ad0acf0e4e4da658c4cca0bee459351d
# Parent  ede4a1bf14bdd101e0760db8b8c7e8d65865050e
grep: add option for logcmdutil.makewalker() to not filter revs by file pats

This is needed to implement "grep --all-files".
Pulkit Goyal - Oct. 6, 2020, 8:39 a.m.
On Sat, Oct 3, 2020 at 9:46 AM Yuya Nishihara <yuya@tcha.org> wrote:
>
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1599730801 -32400
> #      Thu Sep 10 18:40:01 2020 +0900
> # Node ID 14815a48ad0acf0e4e4da658c4cca0bee459351d
> # Parent  ede4a1bf14bdd101e0760db8b8c7e8d65865050e
> grep: add option for logcmdutil.makewalker() to not filter revs by file pats
>
> This is needed to implement "grep --all-files".

Queued this, many thanks!

Patch

diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -711,6 +711,10 @@  class walkopts(object):
     # include revisions where files were removed
     force_changelog_traversal = attr.ib(default=False)  # type: bool
 
+    # filter revisions by file patterns, which should be disabled only if
+    # you want to include revisions where files were unmodified
+    filter_revisions_by_pats = attr.ib(default=True)  # type: bool
+
     # sort revisions prior to traversal: 'desc', 'topo', or None
     sort_revisions = attr.ib(default=None)  # type: Optional[bytes]
 
@@ -902,7 +906,7 @@  def _makerevset(repo, wopts, slowpath):
         b'user': wopts.users,
     }
 
-    if slowpath:
+    if wopts.filter_revisions_by_pats and slowpath:
         # See walkchangerevs() slow path.
         #
         # pats/include/exclude cannot be represented as separate
@@ -919,7 +923,7 @@  def _makerevset(repo, wopts, slowpath):
         for p in wopts.exclude_pats:
             matchargs.append(b'x:' + p)
         opts[b'_matchfiles'] = matchargs
-    elif not wopts.follow:
+    elif wopts.filter_revisions_by_pats and not wopts.follow:
         opts[b'_patslog'] = list(wopts.pats)
 
     expr = []