Show More
@@ -806,13 +806,17 b' def grep(ui, repo, pattern = None, *pats' | |||
|
806 | 806 | return fcache[fn] |
|
807 | 807 | |
|
808 | 808 | def matchlines(body): |
|
809 | # massively inefficient. rewrite. | |
|
810 | for match in regexp.finditer(body): | |
|
811 | start, end = match.span() | |
|
812 | lnum = body.count('\n', 0, start) + 1 | |
|
813 | lstart = body.rfind('\n', 0, start) + 1 | |
|
814 | lend = body.find('\n', end) | |
|
815 | yield lnum, start - lstart, end - lstart, body[lstart:lend] | |
|
809 | begin = 0 | |
|
810 | linenum = 0 | |
|
811 | while True: | |
|
812 | match = regexp.search(body, begin) | |
|
813 | if not match: break | |
|
814 | mstart, mend = match.span() | |
|
815 | linenum += body.count('\n', begin, mstart) + 1 | |
|
816 | lstart = body.rfind('\n', begin, mstart) + 1 or begin | |
|
817 | lend = body.find('\n', mend) | |
|
818 | yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] | |
|
819 | begin = lend + 1 | |
|
816 | 820 | |
|
817 | 821 | class linestate: |
|
818 | 822 | def __init__(self, line, linenum, colstart, colend): |
General Comments 0
You need to be logged in to leave comments.
Login now