Skip to content

Commit 26511a3

Browse files
committed
Get correcly rename change_type.
Also store the rename score
1 parent 518c50e commit 26511a3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

git/diff.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,11 @@ class Diff(object):
251251

252252
__slots__ = ("a_blob", "b_blob", "a_mode", "b_mode", "a_rawpath", "b_rawpath",
253253
"new_file", "deleted_file", "raw_rename_from", "raw_rename_to",
254-
"diff", "change_type")
254+
"diff", "change_type", "score")
255255

256256
def __init__(self, repo, a_rawpath, b_rawpath, a_blob_id, b_blob_id, a_mode,
257257
b_mode, new_file, deleted_file, raw_rename_from,
258-
raw_rename_to, diff, change_type):
258+
raw_rename_to, diff, change_type, score):
259259

260260
self.a_mode = a_mode
261261
self.b_mode = b_mode
@@ -291,6 +291,7 @@ def __init__(self, repo, a_rawpath, b_rawpath, a_blob_id, b_blob_id, a_mode,
291291

292292
self.diff = diff
293293
self.change_type = change_type
294+
self.score = score
294295

295296
def __eq__(self, other):
296297
for name in self.__slots__:
@@ -445,7 +446,7 @@ def _index_from_patch_format(cls, repo, proc):
445446
new_file, deleted_file,
446447
rename_from,
447448
rename_to,
448-
None, None))
449+
None, None, None))
449450

450451
previous_header = header
451452
# end for each header we parse
@@ -492,15 +493,16 @@ def handle_diff_line(line):
492493
elif change_type == 'A':
493494
a_blob_id = None
494495
new_file = True
495-
elif change_type[0] == 'R': # parses RXXX, where XXX is a confidence value
496+
elif change_type == 'R':
496497
a_path, b_path = path.split('\t', 1)
497498
a_path = a_path.encode(defenc)
498499
b_path = b_path.encode(defenc)
499500
rename_from, rename_to = a_path, b_path
500501
# END add/remove handling
501502

502503
diff = Diff(repo, a_path, b_path, a_blob_id, b_blob_id, old_mode, new_mode,
503-
new_file, deleted_file, rename_from, rename_to, '', change_type)
504+
new_file, deleted_file, rename_from, rename_to, '',
505+
change_type, score)
504506
index.append(diff)
505507

506508
handle_process_output(proc, handle_diff_line, None, finalize_process, decode_streams=False)

0 commit comments

Comments
 (0)