This instance will be upgraded to Heptapod 0.26.0rc1 on 2021-10-25 at 14:00 UTC+2 (a few minutes of down time)

Commit 0c064f2e authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

grep: filter target files by matcher

Prepares for the migration to logcmdutil's logic, where cmdutil.walkchangerevs()
won't always build an exact set of paths to be scanned.
parent 3a024d7cd08e
......@@ -45,6 +45,7 @@ from . import (
match as matchmod,
merge as mergemod,
mergestate as mergestatemod,
......@@ -3621,8 +3622,13 @@ def grep(ui, repo, pattern, *pats, **opts):
contextmanager = util.nullcontextmanager
with contextmanager():
assert fmatch.isexact()
for fn in fmatch.files():
# TODO: maybe better to warn missing files?
if all_files:
fmatch = matchmod.badmatch(fmatch, lambda f, msg: None)
filenames = ctx.matches(fmatch)
filenames = (f for f in ctx.files() if fmatch(f))
for fn in filenames:
# fn might not exist in the revision (could be a file removed by
# the revision). We could check `fn not in ctx` even when rev is
# None, but it's less racy to protect againt that in readfile.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment