Mercurial > kallithea
comparison rhodecode/lib/diffs.py @ 3997:156cb1cdd7ad
Added handling of copied files diff parsing
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 15 Jun 2013 20:47:41 +0200 |
parents | dc4644865e8b |
children | d9a73bfc4107 |
comparison
equal
deleted
inserted
replaced
3996:267bb347d68c | 3997:156cb1cdd7ad |
---|---|
125 | 125 |
126 NEW_FILENODE = 1 | 126 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): |
135 pass | 136 pass |
136 | 137 |
177 (?:^old[ ]mode[ ](?P<old_mode>\d+)\n | 178 (?:^old[ ]mode[ ](?P<old_mode>\d+)\n |
178 ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? | 179 ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? |
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]+) |
185 \.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))? | 188 \.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))? |
186 (?:^(?P<bin_patch>GIT[ ]binary[ ]patch)(?:\n|$))? | 189 (?:^(?P<bin_patch>GIT[ ]binary[ ]patch)(?:\n|$))? |
386 and head['rename_from'] != head['rename_to']): | 389 and head['rename_from'] != head['rename_to']): |
387 op = 'M' | 390 op = 'M' |
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']: |
395 op = 'A' | 403 op = 'A' |
396 stats['binary'] = True | 404 stats['binary'] = True |