{"thread":{"id":"26540","subject":"[PATCH] git-p4: Add copy detection support","startedAt":"2011-02-18T00:20:12Z","lastAt":"2011-02-18T00:20:12Z","messageCount":1,"participants":["Vitor Antunes"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"161472","messageId":"1297988412-6754-1-git-send-email-vitor.hda@gmail.com","threadId":"26540","inReplyTo":null,"subject":"[PATCH] git-p4: Add copy detection support","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-02-18T00:20:12Z","receivedAt":"2011-02-18T00:20:12Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Add new config options:\n    git-p4.detectCopies         - Enable copy detection.\n    git-p4.detectCopiesHarder   - Find copies harder.\nThe detectCopies option should be set to a true/false value.\nThe detectCopiesHarder option should be set to true/false value.\nP4Submit can now process diff-tree C status and integrate files accordingly.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\nAcked-by: Pete Wyckoff <pw@padd.com>\n---\n contrib/fast-import/git-p4 |   16 ++++++++++++++++\n 1 files changed, 16 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex b0da28a..1b1fc76 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -623,6 +623,12 @@ class P4Submit(Command):\n         else:\n             diffOpts = \"\"\n \n+        if gitConfig(\"git-p4.detectCopies\").lower() == \"true\":\n+            diffOpts += \" -C\"\n+\n+        if gitConfig(\"git-p4.detectCopiesHarder\").lower() == \"true\":\n+            diffOpts += \" --find-copies-harder\"\n+\n         diff = read_pipe_lines(\"git diff-tree -r %s \\\"%s^\\\" \\\"%s\\\"\" % (diffOpts, id, id))\n         filesToAdd = set()\n         filesToDelete = set()\n@@ -646,6 +652,16 @@ class P4Submit(Command):\n                 filesToDelete.add(path)\n                 if path in filesToAdd:\n                     filesToAdd.remove(path)\n+            elif modifier == \"C\":\n+                src, dest = diff['src'], diff['dst']\n+                p4_system(\"integrate -Dt \\\"%s\\\" \\\"%s\\\"\" % (src, dest))\n+                if diff['src_sha1'] != diff['dst_sha1']:\n+                    p4_system(\"edit \\\"%s\\\"\" % (dest))\n+                if isModeExecChanged(diff['src_mode'], diff['dst_mode']):\n+                    p4_system(\"edit \\\"%s\\\"\" % (dest))\n+                    filesToChangeExecBit[dest] = diff['dst_mode']\n+                os.unlink(dest)\n+                editedFiles.add(dest)\n             elif modifier == \"R\":\n                 src, dest = diff['src'], diff['dst']\n                 p4_system(\"integrate -Dt \\\"%s\\\" \\\"%s\\\"\" % (src, dest))\n-- \n1.7.2.3\n"}]}