diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py +++ b/kallithea/lib/diffs.py @@ -363,7 +363,7 @@ class DiffProcessor(object): rest = diff_chunk[match.end():] if rest and not rest.startswith('@') and not rest.startswith('literal '): raise Exception('cannot parse diff header: %r followed by %r' % (diff_chunk[:match.end()], rest[:1000])) - difflines = imap(self._escaper, rest.splitlines(True)) + difflines = imap(self._escaper, re.findall(r'.*\n|.+$', rest)) # don't split on \r as str.splitlines do return groups, difflines def _clean_line(self, line, command): diff --git a/kallithea/tests/fixtures/hg_diff_rename_space_cr.diff b/kallithea/tests/fixtures/hg_diff_rename_space_cr.diff --- a/kallithea/tests/fixtures/hg_diff_rename_space_cr.diff +++ b/kallithea/tests/fixtures/hg_diff_rename_space_cr.diff @@ -3,7 +3,7 @@ rename from oh no rename to oh yes --- a/oh no +++ b/oh yes -@@ -1,5 +1,6 @@ +@@ -1,4 +1,4 @@ 1 -2 + 2 -3 diff --git a/kallithea/tests/models/test_diff_parsers.py b/kallithea/tests/models/test_diff_parsers.py --- a/kallithea/tests/models/test_diff_parsers.py +++ b/kallithea/tests/models/test_diff_parsers.py @@ -249,7 +249,7 @@ DIFF_FIXTURES = { ], 'hg_diff_rename_space_cr.diff': [ ('oh yes', 'R', - {'added': 4, + {'added': 3, 'deleted': 2, 'binary': False, 'ops': {RENAMED_FILENODE: 'file renamed from oh no to oh yes'}}),