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 769e7fba authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

grep: move getbody() to grepsearcher class

parent 494642ed3c50
......@@ -3404,16 +3404,6 @@ def grep(ui, repo, pattern, *pats, **opts):
matches = searcher._matches
copies = searcher._copies
def grepbody(fn, rev, body):
matches[rev].setdefault(fn, [])
m = matches[rev][fn]
if body is None:
for lnum, cstart, cend, line in grepmod.matchlines(body, regexp):
s = grepmod.linestate(line, lnum, cstart, cend)
uipathfn = scmutil.getuipathfn(repo)
def display(fm, fn, ctx, pstates, states):
......@@ -3591,12 +3581,12 @@ def grep(ui, repo, pattern, *pats, **opts):
if fn not in matches[rev]:
grepbody(fn, rev, readfile(ctx, fn))
searcher._grepbody(fn, rev, readfile(ctx, fn))
if diff:
pfn = copy or fn
if pfn not in matches[parent] and pfn in pctx:
grepbody(pfn, parent, readfile(pctx, pfn))
searcher._grepbody(pfn, parent, readfile(pctx, pfn))
wopts = logcmdutil.walkopts(
......@@ -90,3 +90,13 @@ class grepsearcher(object):
self._copies = {}
self._skip = set()
self._revfiles = {}
def _grepbody(self, fn, rev, body):
self._matches[rev].setdefault(fn, [])
m = self._matches[rev][fn]
if body is None:
for lnum, cstart, cend, line in matchlines(body, self._regexp):
s = linestate(line, lnum, cstart, cend)
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