##// END OF EJS Templates
grep: explicitly pass regexp to closure functions...
Yuya Nishihara -
r46287:760bb4d7 default
parent child Browse files
Show More
@@ -3400,7 +3400,7 b' def grep(ui, repo, pattern, *pats, **opt'
3400
3400
3401 getfile = util.lrucachefunc(repo.file)
3401 getfile = util.lrucachefunc(repo.file)
3402
3402
3403 def matchlines(body):
3403 def matchlines(body, regexp):
3404 begin = 0
3404 begin = 0
3405 linenum = 0
3405 linenum = 0
3406 while begin < len(body):
3406 while begin < len(body):
@@ -3427,7 +3427,7 b' def grep(ui, repo, pattern, *pats, **opt'
3427 def __eq__(self, other):
3427 def __eq__(self, other):
3428 return self.line == other.line
3428 return self.line == other.line
3429
3429
3430 def findpos(self):
3430 def findpos(self, regexp):
3431 """Iterate all (start, end) indices of matches"""
3431 """Iterate all (start, end) indices of matches"""
3432 yield self.colstart, self.colend
3432 yield self.colstart, self.colend
3433 p = self.colend
3433 p = self.colend
@@ -3450,7 +3450,7 b' def grep(ui, repo, pattern, *pats, **opt'
3450 if body is None:
3450 if body is None:
3451 return
3451 return
3452
3452
3453 for lnum, cstart, cend, line in matchlines(body):
3453 for lnum, cstart, cend, line in matchlines(body, regexp):
3454 s = linestate(line, lnum, cstart, cend)
3454 s = linestate(line, lnum, cstart, cend)
3455 m.append(s)
3455 m.append(s)
3456
3456
@@ -3562,7 +3562,7 b' def grep(ui, repo, pattern, *pats, **opt'
3562
3562
3563 def displaymatches(fm, l):
3563 def displaymatches(fm, l):
3564 p = 0
3564 p = 0
3565 for s, e in l.findpos():
3565 for s, e in l.findpos(regexp):
3566 if p < s:
3566 if p < s:
3567 fm.startitem()
3567 fm.startitem()
3568 fm.write(b'text', b'%s', l.line[p:s])
3568 fm.write(b'text', b'%s', l.line[p:s])
General Comments 0
You need to be logged in to leave comments. Login now