# HG changeset patch # User Mads Kiilerich # Date 1318721166 -7200 # Node ID 0e34699d6988d2cad9feea74f508c831f4a4ea76 # Parent 7fa471248185742ad1cba8704cf7888718f2157e grep: correct handling of matching lines without line ending (issue3050) Matching lines without trailing '\n' was missing the last character. That seems to have been an unintended side effect of 261a9f47b44b. The test in dac14cc9711e documents the bad behaviour. diff -r 7fa471248185 -r 0e34699d6988 mercurial/commands.py --- a/mercurial/commands.py Mon Oct 17 11:37:59 2011 +0200 +++ b/mercurial/commands.py Sun Oct 16 01:26:06 2011 +0200 @@ -2660,7 +2660,7 @@ mstart, mend = match.span() linenum += body.count('\n', begin, mstart) + 1 lstart = body.rfind('\n', begin, mstart) + 1 or begin - begin = body.find('\n', mend) + 1 or len(body) + begin = body.find('\n', mend) + 1 or len(body) + 1 lend = begin - 1 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] diff -r 7fa471248185 -r 0e34699d6988 tests/test-grep.t --- a/tests/test-grep.t Mon Oct 17 11:37:59 2011 +0200 +++ b/tests/test-grep.t Sun Oct 16 01:26:06 2011 +0200 @@ -106,12 +106,8 @@ $ python -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();' $ hg ci -Amnoeol adding noeol - -last character omitted in output to avoid infinite loop - $ hg grep loop - noeol:4:no infinite loo - + noeol:4:no infinite loop $ cd ..