Mercurial > kallithea
changeset 4694:11d6d1cec667
diff: fix diff of renamed files with whitespace in their names
Before, header parsing would fail.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Mon, 15 Dec 2014 13:47:36 +0100 |
parents | 9740ec3be07a |
children | 97ed7d05d3d2 |
files | kallithea/lib/diffs.py kallithea/tests/fixtures/hg_diff_rename_space_cr.diff kallithea/tests/models/test_diff_parsers.py |
diffstat | 3 files changed, 19 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/diffs.py Mon Dec 15 13:47:36 2014 +0100 +++ b/kallithea/lib/diffs.py Mon Dec 15 13:47:36 2014 +0100 @@ -157,11 +157,12 @@ _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<a_path>.+?)[ ]b/(?P<b_path>.+?)\n (?:^similarity[ ]index[ ](?P<similarity_index>\d+)%\n - ^rename[ ]from[ ](?P<rename_from>\S+)\n - ^rename[ ]to[ ](?P<rename_to>\S+)(?:\n|$))? + ^rename[ ]from[ ](?P<rename_from>.+)\n + ^rename[ ]to[ ](?P<rename_to>.+)(?:\n|$))? (?:^old[ ]mode[ ](?P<old_mode>\d+)\n ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? (?:^new[ ]file[ ]mode[ ](?P<new_file_mode>.+)(?:\n|$))? @@ -173,15 +174,16 @@ (?:^\+\+\+[ ](b/(?P<b_file>.+)|/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<a_path>.+?)[ ]b/(?P<b_path>.+?)\n (?:^old[ ]mode[ ](?P<old_mode>\d+)\n ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? (?:^similarity[ ]index[ ](?P<similarity_index>\d+)%(?:\n|$))? - (?:^rename[ ]from[ ](?P<rename_from>\S+)\n - ^rename[ ]to[ ](?P<rename_to>\S+)(?:\n|$))? - (?:^copy[ ]from[ ](?P<copy_from>\S+)\n - ^copy[ ]to[ ](?P<copy_to>\S+)(?:\n|$))? + (?:^rename[ ]from[ ](?P<rename_from>.+)\n + ^rename[ ]to[ ](?P<rename_to>.+)(?:\n|$))? + (?:^copy[ ]from[ ](?P<copy_from>.+)\n + ^copy[ ]to[ ](?P<copy_to>.+)(?:\n|$))? (?:^new[ ]file[ ]mode[ ](?P<new_file_mode>.+)(?:\n|$))? (?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))? (?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+)
--- a/kallithea/tests/fixtures/hg_diff_rename_space_cr.diff Mon Dec 15 13:47:36 2014 +0100 +++ b/kallithea/tests/fixtures/hg_diff_rename_space_cr.diff Mon Dec 15 13:47:36 2014 +0100 @@ -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
--- a/kallithea/tests/models/test_diff_parsers.py Mon Dec 15 13:47:36 2014 +0100 +++ b/kallithea/tests/models/test_diff_parsers.py Mon Dec 15 13:47:36 2014 +0100 @@ -248,11 +248,11 @@ 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'}}), ], }