comparison mercurial/commands.py @ 45649:bba730d7a6f4

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.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 10 Sep 2020 17:14:03 +0900
parents 3a024d7cd08e
children 0356b41fe01d
comparison
equal deleted inserted replaced
45648:3a024d7cd08e 45649:bba730d7a6f4
43 graphmod, 43 graphmod,
44 hbisect, 44 hbisect,
45 help, 45 help,
46 hg, 46 hg,
47 logcmdutil, 47 logcmdutil,
48 match as matchmod,
48 merge as mergemod, 49 merge as mergemod,
49 mergestate as mergestatemod, 50 mergestate as mergestatemod,
50 narrowspec, 51 narrowspec,
51 obsolete, 52 obsolete,
52 obsutil, 53 obsutil,
3619 # pathauditor checks without this in mozilla-central 3620 # pathauditor checks without this in mozilla-central
3620 contextmanager = repo.wvfs.audit.cached 3621 contextmanager = repo.wvfs.audit.cached
3621 else: 3622 else:
3622 contextmanager = util.nullcontextmanager 3623 contextmanager = util.nullcontextmanager
3623 with contextmanager(): 3624 with contextmanager():
3624 assert fmatch.isexact() 3625 # TODO: maybe better to warn missing files?
3625 for fn in fmatch.files(): 3626 if all_files:
3627 fmatch = matchmod.badmatch(fmatch, lambda f, msg: None)
3628 filenames = ctx.matches(fmatch)
3629 else:
3630 filenames = (f for f in ctx.files() if fmatch(f))
3631 for fn in filenames:
3626 # fn might not exist in the revision (could be a file removed by 3632 # fn might not exist in the revision (could be a file removed by
3627 # the revision). We could check `fn not in ctx` even when rev is 3633 # the revision). We could check `fn not in ctx` even when rev is
3628 # None, but it's less racy to protect againt that in readfile. 3634 # None, but it's less racy to protect againt that in readfile.
3629 if rev is not None and fn not in ctx: 3635 if rev is not None and fn not in ctx:
3630 continue 3636 continue