{"thread":{"id":"26563","subject":"[PATCH v2 0/2] Improvements to rename and copy detection","startedAt":"2011-02-20T01:18:23Z","lastAt":"2011-02-21T09:40:32Z","messageCount":4,"participants":["Vitor Antunes","Tor Arvid Lund"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"161721","messageId":"1298164705-5366-1-git-send-email-vitor.hda@gmail.com","threadId":"26563","inReplyTo":null,"subject":"[PATCH v2 0/2] Improvements to rename and copy detection","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-02-20T01:18:23Z","receivedAt":"2011-02-20T01:18:23Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"I'm resending this set of patches because the last set I prepared did not\ncontain the correct patches. This new set should make everything clearer.\nIncluded are the changes proposed by Pete and Tor, as well as Pete's\nacknowledge of both patches.\n\nVitor Antunes (2):\n  git-p4: Improve rename detection support\n  git-p4: Add copy detection support\n\n contrib/fast-import/git-p4 |   35 +++++++++++++++++++++++++++++++----\n 1 files changed, 31 insertions(+), 4 deletions(-)\n\n-- \n1.7.4.1\n"},{"id":"161723","messageId":"1298164705-5366-2-git-send-email-vitor.hda@gmail.com","threadId":"26563","inReplyTo":"1298164705-5366-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v2 1/2] git-p4: Improve rename detection support","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-02-20T01:18:24Z","receivedAt":"2011-02-20T01:18:24Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Only open files for edit after integrating if the SHA1 of source and destination\ndiffer from each other.\nAdd git config option detectRenames to allow permanent rename detection. This\noptions should be set to a true/false value.\nRename \"detectRename\" variable to \"detectRenames\" to make it more coherent with\nthe description in git man pages, which always use plural.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\nAcked-by: Pete Wyckoff <pw@padd.com>\n---\n contrib/fast-import/git-p4 |   19 +++++++++++++++----\n 1 files changed, 15 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex a92beb6..b0da28a 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -543,13 +543,13 @@ class P4Submit(Command):\n         self.options = [\n                 optparse.make_option(\"--verbose\", dest=\"verbose\", action=\"store_true\"),\n                 optparse.make_option(\"--origin\", dest=\"origin\"),\n-                optparse.make_option(\"-M\", dest=\"detectRename\", action=\"store_true\"),\n+                optparse.make_option(\"-M\", dest=\"detectRenames\", action=\"store_true\"),\n         ]\n         self.description = \"Submit changes from git to the perforce depot.\"\n         self.usage += \" [name of git branch to submit into perforce depot]\"\n         self.interactive = True\n         self.origin = \"\"\n-        self.detectRename = False\n+        self.detectRenames = False\n         self.verbose = False\n         self.isWindows = (platform.system() == \"Windows\")\n \n@@ -613,7 +613,16 @@ class P4Submit(Command):\n \n     def applyCommit(self, id):\n         print \"Applying %s\" % (read_pipe(\"git log --max-count=1 --pretty=oneline %s\" % id))\n-        diffOpts = (\"\", \"-M\")[self.detectRename]\n+\n+        if not self.detectRenames:\n+            # If not explicitly set check the config variable\n+            self.detectRenames = gitConfig(\"git-p4.detectRenames\").lower() == \"true\"\n+\n+        if self.detectRenames:\n+            diffOpts = \"-M\"\n+        else:\n+            diffOpts = \"\"\n+\n         diff = read_pipe_lines(\"git diff-tree -r %s \\\"%s^\\\" \\\"%s\\\"\" % (diffOpts, id, id))\n         filesToAdd = set()\n         filesToDelete = set()\n@@ -640,8 +649,10 @@ class P4Submit(Command):\n             elif modifier == \"R\":\n                 src, dest = diff['src'], diff['dst']\n                 p4_system(\"integrate -Dt \\\"%s\\\" \\\"%s\\\"\" % (src, dest))\n-                p4_system(\"edit \\\"%s\\\"\" % (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-- \n1.7.4.1\n"},{"id":"161722","messageId":"1298164705-5366-3-git-send-email-vitor.hda@gmail.com","threadId":"26563","inReplyTo":"1298164705-5366-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v2 2/2] git-p4: Add copy detection support","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-02-20T01:18:25Z","receivedAt":"2011-02-20T01:18:25Z","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.4.1\n"},{"id":"161785","messageId":"AANLkTi=NOOaf+peRgCA3X4AY7oRL-8Md=91KNa=a_fJV@mail.gmail.com","threadId":"26563","inReplyTo":"1298164705-5366-2-git-send-email-vitor.hda@gmail.com","subject":"Re: [PATCH v2 1/2] git-p4: Improve rename detection support","fromName":"Tor Arvid Lund","fromEmail":"torarvid@gmail.com","sentAt":"2011-02-21T09:40:32Z","receivedAt":"2011-02-21T09:40:32Z","isPatch":true,"sender":{"key":"torarvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/439758?v=4"},"body":"On Sun, Feb 20, 2011 at 2:18 AM, Vitor Antunes <vitor.hda@gmail.com> wrote:\n> Only open files for edit after integrating if the SHA1 of source and destination\n> differ from each other.\n> Add git config option detectRenames to allow permanent rename detection. This\n> options should be set to a true/false value.\n> Rename \"detectRename\" variable to \"detectRenames\" to make it more coherent with\n> the description in git man pages, which always use plural.\n>\n> Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>\n> Acked-by: Pete Wyckoff <pw@padd.com>\n\nAcked-by: Tor Arvid Lund <torarvid@gmail.com>\n\n> ---\n>  contrib/fast-import/git-p4 |   19 +++++++++++++++----\n>  1 files changed, 15 insertions(+), 4 deletions(-)\n>\n> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\n> index a92beb6..b0da28a 100755\n> --- a/contrib/fast-import/git-p4\n> +++ b/contrib/fast-import/git-p4\n> @@ -543,13 +543,13 @@ class P4Submit(Command):\n>         self.options = [\n>                 optparse.make_option(\"--verbose\", dest=\"verbose\", action=\"store_true\"),\n>                 optparse.make_option(\"--origin\", dest=\"origin\"),\n> -                optparse.make_option(\"-M\", dest=\"detectRename\", action=\"store_true\"),\n> +                optparse.make_option(\"-M\", dest=\"detectRenames\", action=\"store_true\"),\n>         ]\n>         self.description = \"Submit changes from git to the perforce depot.\"\n>         self.usage += \" [name of git branch to submit into perforce depot]\"\n>         self.interactive = True\n>         self.origin = \"\"\n> -        self.detectRename = False\n> +        self.detectRenames = False\n>         self.verbose = False\n>         self.isWindows = (platform.system() == \"Windows\")\n>\n> @@ -613,7 +613,16 @@ class P4Submit(Command):\n>\n>     def applyCommit(self, id):\n>         print \"Applying %s\" % (read_pipe(\"git log --max-count=1 --pretty=oneline %s\" % id))\n> -        diffOpts = (\"\", \"-M\")[self.detectRename]\n> +\n> +        if not self.detectRenames:\n> +            # If not explicitly set check the config variable\n> +            self.detectRenames = gitConfig(\"git-p4.detectRenames\").lower() == \"true\"\n> +\n> +        if self.detectRenames:\n> +            diffOpts = \"-M\"\n> +        else:\n> +            diffOpts = \"\"\n> +\n>         diff = read_pipe_lines(\"git diff-tree -r %s \\\"%s^\\\" \\\"%s\\\"\" % (diffOpts, id, id))\n>         filesToAdd = set()\n>         filesToDelete = set()\n> @@ -640,8 +649,10 @@ class P4Submit(Command):\n>             elif modifier == \"R\":\n>                 src, dest = diff['src'], diff['dst']\n>                 p4_system(\"integrate -Dt \\\"%s\\\" \\\"%s\\\"\" % (src, dest))\n> -                p4_system(\"edit \\\"%s\\\"\" % (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> --\n> 1.7.4.1\n>\n>\n"}]}