@matheusbsbs / matheus-bagliano / commits / 4fddb41bd7
Fork 0

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 <vitor.hda@gmail.com> Acked-by: Pete Wyckoff <pw@padd.com> Acked-by: Tor Arvid Lund <torarvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Vitor Antunes committed Feb 20, 2011 at 01:18 UTC 4fddb41bd77dd0f685d8f79c81d3d40128578fe1
1 file changed +16
contrib/fast-import/git-p4
+16
@@ -623,6 +623,12 @@ class P4Submit(Command):
623 else:
624 diffOpts = ""
625
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 +
632 diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (diffOpts, id, id))
633 filesToAdd = set()
634 filesToDelete = set()
@@ -646,6 +652,16 @@ class P4Submit(Command):
652 filesToDelete.add(path)
653 if path in filesToAdd:
654 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)
665 elif modifier == "R":
666 src, dest = diff['src'], diff['dst']
667 p4_system("integrate -Dt \"%s\" \"%s\"" % (src, dest))