##// END OF EJS Templates
grep: correct handling of matching lines without line ending (issue3050)...
Mads Kiilerich -
r15293:0e34699d stable
parent child Browse files
Show More
@@ -2660,7 +2660,7 b' def grep(ui, repo, pattern, *pats, **opt'
2660 mstart, mend = match.span()
2660 mstart, mend = match.span()
2661 linenum += body.count('\n', begin, mstart) + 1
2661 linenum += body.count('\n', begin, mstart) + 1
2662 lstart = body.rfind('\n', begin, mstart) + 1 or begin
2662 lstart = body.rfind('\n', begin, mstart) + 1 or begin
2663 begin = body.find('\n', mend) + 1 or len(body)
2663 begin = body.find('\n', mend) + 1 or len(body) + 1
2664 lend = begin - 1
2664 lend = begin - 1
2665 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
2665 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
2666
2666
@@ -106,12 +106,8 b' match in last "line" without newline'
106 $ python -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();'
106 $ python -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();'
107 $ hg ci -Amnoeol
107 $ hg ci -Amnoeol
108 adding noeol
108 adding noeol
109
110 last character omitted in output to avoid infinite loop
111
112 $ hg grep loop
109 $ hg grep loop
113 noeol:4:no infinite loo
110 noeol:4:no infinite loop
114
115
111
116 $ cd ..
112 $ cd ..
117
113
General Comments 0
You need to be logged in to leave comments. Login now