Skip to content

Commit 4fddb41

Browse files
vhdagitster
authored andcommitted
git-p4: Add copy detection support
Add new config options: git-p4.detectCopies - Enable copy detection. git-p4.detectCopiesHarder - Find copies harder. The detectCopies option should be set to a true/false value. The detectCopiesHarder option should be set to true/false value. P4Submit can now process diff-tree C status and integrate files accordingly. Signed-off-by: Vitor Antunes <[email protected]> Acked-by: Pete Wyckoff <[email protected]> Acked-by: Tor Arvid Lund <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae90109 commit 4fddb41

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

contrib/fast-import/git-p4

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,12 @@ class P4Submit(Command):
623623
else:
624624
diffOpts = ""
625625

626+
if gitConfig("git-p4.detectCopies").lower() == "true":
627+
diffOpts += " -C"
628+
629+
if gitConfig("git-p4.detectCopiesHarder").lower() == "true":
630+
diffOpts += " --find-copies-harder"
631+
626632
diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (diffOpts, id, id))
627633
filesToAdd = set()
628634
filesToDelete = set()
@@ -646,6 +652,16 @@ class P4Submit(Command):
646652
filesToDelete.add(path)
647653
if path in filesToAdd:
648654
filesToAdd.remove(path)
655+
elif modifier == "C":
656+
src, dest = diff['src'], diff['dst']
657+
p4_system("integrate -Dt \"%s\" \"%s\"" % (src, dest))
658+
if diff['src_sha1'] != diff['dst_sha1']:
659+
p4_system("edit \"%s\"" % (dest))
660+
if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
661+
p4_system("edit \"%s\"" % (dest))
662+
filesToChangeExecBit[dest] = diff['dst_mode']
663+
os.unlink(dest)
664+
editedFiles.add(dest)
649665
elif modifier == "R":
650666
src, dest = diff['src'], diff['dst']
651667
p4_system("integrate -Dt \"%s\" \"%s\"" % (src, dest))

0 commit comments

Comments
 (0)