Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 45697:494642ed3c50
grep: add stub class that maintains cache and states of grep operation
Prepares for extracting stateful functions from commands.grep().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 09 Sep 2020 15:56:40 +0900 |
parents | de6f2afc0247 |
children | 41e0cbccb260 |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Sep 09 15:23:49 2020 +0900 +++ b/mercurial/commands.py Wed Sep 09 15:56:40 2020 +0900 @@ -3398,9 +3398,11 @@ if opts.get(b'print0'): sep = eol = b'\0' - getfile = util.lrucachefunc(repo.file) - matches = {} - copies = {} + searcher = grepmod.grepsearcher(ui, repo, regexp) + + getfile = searcher._getfile + matches = searcher._matches + copies = searcher._copies def grepbody(fn, rev, body): matches[rev].setdefault(fn, []) @@ -3520,12 +3522,12 @@ fm.data(matched=False) fm.end() - skip = set() - revfiles = {} + skip = searcher._skip + revfiles = searcher._revfiles found = False follow = opts.get(b'follow') - getrenamed = scmutil.getrenamedfn(repo) + getrenamed = searcher._getrenamed def readfile(ctx, fn): rev = ctx.rev()