changeset 36146 | 29dd37a418aa |
parent 34435 | 5326e4ef1dab |
child 41269 | 8b7973d40a01 |
--- a/mercurial/pure/bdiff.py Mon Feb 12 16:09:31 2018 +0100 +++ b/mercurial/pure/bdiff.py Thu Jan 25 21:16:28 2018 -0500 @@ -90,3 +90,13 @@ text = re.sub('[ \t\r]+', ' ', text) text = text.replace(' \n', '\n') return text + +def splitnewlines(text): + '''like str.splitlines, but only split on newlines.''' + lines = [l + '\n' for l in text.split('\n')] + if lines: + if lines[-1] == '\n': + lines.pop() + else: + lines[-1] = lines[-1][:-1] + return lines