diff mercurial/commands.py @ 45652:0356b41fe01d

cmdutil: rewrite walkchangerevs() by using logcmdutil functions cmdutil.walkchangerevs() now takes (revs, makefilematcher) in place of (match, opts), and only provides the "windowing" functionality. Unused classes and functions will be removed by the next patch. "hg grep --follow" (--all-files) is still broken since there is no logic to follow copies while traversing changelog, but at least, it does follow the DAG.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 10 Sep 2020 18:01:43 +0900
parents bba730d7a6f4
children 760bb4d74aad
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Sep 10 17:14:03 2020 +0900
+++ b/mercurial/commands.py	Thu Sep 10 18:01:43 2020 +0900
@@ -3579,7 +3579,6 @@
 
     skip = set()
     revfiles = {}
-    match = scmutil.match(repo[None], pats, opts)
     found = False
     follow = opts.get(b'follow')
 
@@ -3654,9 +3653,21 @@
                     if pfn not in matches[parent] and pfn in pctx:
                         grepbody(pfn, parent, readfile(pctx, pfn))
 
+    wopts = logcmdutil.walkopts(
+        pats=pats,
+        opts=opts,
+        revspec=opts[b'rev'],
+        include_pats=opts[b'include'],
+        exclude_pats=opts[b'exclude'],
+        follow=follow,
+        force_changelog_traversal=all_files,
+        filter_revisions_by_pats=not all_files,
+    )
+    revs, makefilematcher = logcmdutil.makewalker(repo, wopts)
+
     ui.pager(b'grep')
     fm = ui.formatter(b'grep', opts)
-    for ctx in cmdutil.walkchangerevs(repo, match, opts, prep):
+    for ctx in cmdutil.walkchangerevs(repo, revs, makefilematcher, prep):
         rev = ctx.rev()
         parent = ctx.p1().rev()
         for fn in sorted(revfiles.get(rev, [])):