##// END OF EJS Templates
grep: move getbody() to grepsearcher class
Yuya Nishihara -
r46290:41e0cbcc default
parent child Browse files
Show More
@@ -3404,16 +3404,6 b' def grep(ui, repo, pattern, *pats, **opt'
3404 matches = searcher._matches
3404 matches = searcher._matches
3405 copies = searcher._copies
3405 copies = searcher._copies
3406
3406
3407 def grepbody(fn, rev, body):
3408 matches[rev].setdefault(fn, [])
3409 m = matches[rev][fn]
3410 if body is None:
3411 return
3412
3413 for lnum, cstart, cend, line in grepmod.matchlines(body, regexp):
3414 s = grepmod.linestate(line, lnum, cstart, cend)
3415 m.append(s)
3416
3417 uipathfn = scmutil.getuipathfn(repo)
3407 uipathfn = scmutil.getuipathfn(repo)
3418
3408
3419 def display(fm, fn, ctx, pstates, states):
3409 def display(fm, fn, ctx, pstates, states):
@@ -3591,12 +3581,12 b' def grep(ui, repo, pattern, *pats, **opt'
3591 files.append(fn)
3581 files.append(fn)
3592
3582
3593 if fn not in matches[rev]:
3583 if fn not in matches[rev]:
3594 grepbody(fn, rev, readfile(ctx, fn))
3584 searcher._grepbody(fn, rev, readfile(ctx, fn))
3595
3585
3596 if diff:
3586 if diff:
3597 pfn = copy or fn
3587 pfn = copy or fn
3598 if pfn not in matches[parent] and pfn in pctx:
3588 if pfn not in matches[parent] and pfn in pctx:
3599 grepbody(pfn, parent, readfile(pctx, pfn))
3589 searcher._grepbody(pfn, parent, readfile(pctx, pfn))
3600
3590
3601 wopts = logcmdutil.walkopts(
3591 wopts = logcmdutil.walkopts(
3602 pats=pats,
3592 pats=pats,
@@ -90,3 +90,13 b' class grepsearcher(object):'
90 self._copies = {}
90 self._copies = {}
91 self._skip = set()
91 self._skip = set()
92 self._revfiles = {}
92 self._revfiles = {}
93
94 def _grepbody(self, fn, rev, body):
95 self._matches[rev].setdefault(fn, [])
96 m = self._matches[rev][fn]
97 if body is None:
98 return
99
100 for lnum, cstart, cend, line in matchlines(body, self._regexp):
101 s = linestate(line, lnum, cstart, cend)
102 m.append(s)
General Comments 0
You need to be logged in to leave comments. Login now