##// END OF EJS Templates
Added handling of copied files diff parsing
marcink -
r3997:156cb1cd default
parent child Browse files
Show More
@@ -0,0 +1,3 b''
1 diff --git a/file1 b/file2
2 copy from file1
3 copy to file2
@@ -127,8 +127,9 b' NEW_FILENODE = 1'
127 DEL_FILENODE = 2
127 DEL_FILENODE = 2
128 MOD_FILENODE = 3
128 MOD_FILENODE = 3
129 RENAMED_FILENODE = 4
129 RENAMED_FILENODE = 4
130 CHMOD_FILENODE = 5
130 COPIED_FILENODE = 5
131 BIN_FILENODE = 6
131 CHMOD_FILENODE = 6
132 BIN_FILENODE = 7
132
133
133
134
134 class DiffLimitExceeded(Exception):
135 class DiffLimitExceeded(Exception):
@@ -179,6 +180,8 b' class DiffProcessor(object):'
179 (?:^similarity[ ]index[ ](?P<similarity_index>\d+)%(?:\n|$))?
180 (?:^similarity[ ]index[ ](?P<similarity_index>\d+)%(?:\n|$))?
180 (?:^rename[ ]from[ ](?P<rename_from>\S+)\n
181 (?:^rename[ ]from[ ](?P<rename_from>\S+)\n
181 ^rename[ ]to[ ](?P<rename_to>\S+)(?:\n|$))?
182 ^rename[ ]to[ ](?P<rename_to>\S+)(?:\n|$))?
183 (?:^copy[ ]from[ ](?P<copy_from>\S+)\n
184 ^copy[ ]to[ ](?P<copy_to>\S+)(?:\n|$))?
182 (?:^new[ ]file[ ]mode[ ](?P<new_file_mode>.+)(?:\n|$))?
185 (?:^new[ ]file[ ]mode[ ](?P<new_file_mode>.+)(?:\n|$))?
183 (?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))?
186 (?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))?
184 (?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+)
187 (?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+)
@@ -388,7 +391,12 b' class DiffProcessor(object):'
388 stats['binary'] = True
391 stats['binary'] = True
389 stats['ops'][RENAMED_FILENODE] = ('file renamed from %s to %s'
392 stats['ops'][RENAMED_FILENODE] = ('file renamed from %s to %s'
390 % (head['rename_from'], head['rename_to']))
393 % (head['rename_from'], head['rename_to']))
391
394 # COPY
395 if head['copy_from'] and head['copy_to']:
396 op = 'M'
397 stats['binary'] = True
398 stats['ops'][COPIED_FILENODE] = ('file copied from %s to %s'
399 % (head['copy_from'], head['copy_to']))
392 # FALL BACK: detect missed old style add or remove
400 # FALL BACK: detect missed old style add or remove
393 if op is None:
401 if op is None:
394 if not head['a_file'] and head['b_file']:
402 if not head['a_file'] and head['b_file']:
@@ -2,7 +2,7 b' from __future__ import with_statement'
2 import os
2 import os
3 from rhodecode.tests import *
3 from rhodecode.tests import *
4 from rhodecode.lib.diffs import DiffProcessor, NEW_FILENODE, DEL_FILENODE, \
4 from rhodecode.lib.diffs import DiffProcessor, NEW_FILENODE, DEL_FILENODE, \
5 MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE
5 MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE, COPIED_FILENODE
6
6
7 dn = os.path.dirname
7 dn = os.path.dirname
8 FIXTURES = os.path.join(dn(dn(os.path.abspath(__file__))), 'fixtures')
8 FIXTURES = os.path.join(dn(dn(os.path.abspath(__file__))), 'fixtures')
@@ -217,6 +217,13 b' DIFF_FIXTURES = {'
217 'binary': False,
217 'binary': False,
218 'ops': {MOD_FILENODE: 'modified file'}}),
218 'ops': {MOD_FILENODE: 'modified file'}}),
219 ],
219 ],
220 'hg_diff_copy_file.diff': [
221 ('file2', 'M',
222 {'added': 0,
223 'deleted': 0,
224 'binary': True,
225 'ops': {COPIED_FILENODE: 'file copied from file1 to file2'}}),
226 ]
220 # 'large_diff.diff': [
227 # 'large_diff.diff': [
221 # ('.hgignore', 'A', {'deleted': 0, 'binary': False, 'added': 3, 'ops': {1: 'new file 100644'}}),
228 # ('.hgignore', 'A', {'deleted': 0, 'binary': False, 'added': 3, 'ops': {1: 'new file 100644'}}),
222 # ('MANIFEST.in', 'A', {'deleted': 0, 'binary': False, 'added': 3, 'ops': {1: 'new file 100644'}}),
229 # ('MANIFEST.in', 'A', {'deleted': 0, 'binary': False, 'added': 3, 'ops': {1: 'new file 100644'}}),
General Comments 0
You need to be logged in to leave comments. Login now