# HG changeset patch # User Yuya Nishihara <y...@tcha.org> # Date 1599634803 -32400 # Wed Sep 09 16:00:03 2020 +0900 # Node ID a19bef408f16ba119ae395379df62aba2586c42a # Parent 55130738756a9836d6d8a8da75e7bca808a327cb grep: move getbody() to grepsearcher class
diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3404,16 +3404,6 @@ def grep(ui, repo, pattern, *pats, **opt matches = searcher._matches copies = searcher._copies - def grepbody(fn, rev, body): - matches[rev].setdefault(fn, []) - m = matches[rev][fn] - if body is None: - return - - for lnum, cstart, cend, line in grepmod.matchlines(body, regexp): - s = grepmod.linestate(line, lnum, cstart, cend) - m.append(s) - uipathfn = scmutil.getuipathfn(repo) def display(fm, fn, ctx, pstates, states): @@ -3591,12 +3581,12 @@ def grep(ui, repo, pattern, *pats, **opt files.append(fn) 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( pats=pats, diff --git a/mercurial/grep.py b/mercurial/grep.py --- a/mercurial/grep.py +++ b/mercurial/grep.py @@ -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: + return + + for lnum, cstart, cend, line in matchlines(body, self._regexp): + s = linestate(line, lnum, cstart, cend) + m.append(s) _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel