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

grep: explicitly pass regexp to closure functions

These functions will be extracted to new module.
parent d1c10d33a85c
......@@ -3400,7 +3400,7 @@ def grep(ui, repo, pattern, *pats, **opts):
getfile = util.lrucachefunc(repo.file)
def matchlines(body):
def matchlines(body, regexp):
begin = 0
linenum = 0
while begin < len(body):
......@@ -3427,7 +3427,7 @@ def grep(ui, repo, pattern, *pats, **opts):
def __eq__(self, other):
return self.line == other.line
def findpos(self):
def findpos(self, regexp):
"""Iterate all (start, end) indices of matches"""
yield self.colstart, self.colend
p = self.colend
......@@ -3450,7 +3450,7 @@ def grep(ui, repo, pattern, *pats, **opts):
if body is None:
for lnum, cstart, cend, line in matchlines(body):
for lnum, cstart, cend, line in matchlines(body, regexp):
s = linestate(line, lnum, cstart, cend)
......@@ -3562,7 +3562,7 @@ def grep(ui, repo, pattern, *pats, **opts):
def displaymatches(fm, l):
p = 0
for s, e in l.findpos():
for s, e in l.findpos(regexp):
if p < s:
fm.write(b'text', b'%s', l.line[p:s])
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