diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py +++ b/kallithea/lib/diffs.py @@ -157,11 +157,12 @@ class DiffProcessor(object): _chunk_re = re.compile(r'^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)') _newline_marker = re.compile(r'^\\ No newline at end of file') _git_header_re = re.compile(r""" - #^diff[ ]--git + # has already been split on this: + # ^diff[ ]--git [ ]a/(?P.+?)[ ]b/(?P.+?)\n (?:^similarity[ ]index[ ](?P\d+)%\n - ^rename[ ]from[ ](?P\S+)\n - ^rename[ ]to[ ](?P\S+)(?:\n|$))? + ^rename[ ]from[ ](?P.+)\n + ^rename[ ]to[ ](?P.+)(?:\n|$))? (?:^old[ ]mode[ ](?P\d+)\n ^new[ ]mode[ ](?P\d+)(?:\n|$))? (?:^new[ ]file[ ]mode[ ](?P.+)(?:\n|$))? @@ -173,15 +174,16 @@ class DiffProcessor(object): (?:^\+\+\+[ ](b/(?P.+)|/dev/null)(?:\n|$))? """, re.VERBOSE | re.MULTILINE) _hg_header_re = re.compile(r""" - #^diff[ ]--git + # has already been split on this: + # ^diff[ ]--git [ ]a/(?P.+?)[ ]b/(?P.+?)\n (?:^old[ ]mode[ ](?P\d+)\n ^new[ ]mode[ ](?P\d+)(?:\n|$))? (?:^similarity[ ]index[ ](?P\d+)%(?:\n|$))? - (?:^rename[ ]from[ ](?P\S+)\n - ^rename[ ]to[ ](?P\S+)(?:\n|$))? - (?:^copy[ ]from[ ](?P\S+)\n - ^copy[ ]to[ ](?P\S+)(?:\n|$))? + (?:^rename[ ]from[ ](?P.+)\n + ^rename[ ]to[ ](?P.+)(?:\n|$))? + (?:^copy[ ]from[ ](?P.+)\n + ^copy[ ]to[ ](?P.+)(?:\n|$))? (?:^new[ ]file[ ]mode[ ](?P.+)(?:\n|$))? (?:^deleted[ ]file[ ]mode[ ](?P.+)(?:\n|$))? (?:^index[ ](?P[0-9A-Fa-f]+) 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 @@ -1,12 +1,12 @@ -diff --git a/ohno b/ohyes -rename from ohno -rename to ohyes ---- a/ohno -+++ b/ohyes +diff --git a/oh no b/oh yes +rename from oh no +rename to oh yes +--- a/oh no ++++ b/oh yes @@ -1,5 +1,6 @@ 1 -2 + 2 --3 +-3 +2 +3 4 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 @@ -248,11 +248,11 @@ DIFF_FIXTURES = { MOD_FILENODE: 'modified file'}}), ], 'hg_diff_rename_space_cr.diff': [ - ('ohyes', 'R', + ('oh yes', 'R', {'added': 4, 'deleted': 2, 'binary': False, - 'ops': {RENAMED_FILENODE: 'file renamed from ohno to ohyes'}}), + 'ops': {RENAMED_FILENODE: 'file renamed from oh no to oh yes'}}), ], }