{"thread":{"id":"41052","subject":"[PATCH] git-p4.py: add support for filetype change","startedAt":"2015-12-21T13:09:25Z","lastAt":"2015-12-29T17:33:12Z","messageCount":3,"participants":["Romain Picard","Luke Diamand"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"274802","messageId":"1450703365-10427-1-git-send-email-romain.picard@oakbits.com","threadId":"41052","inReplyTo":null,"subject":"[PATCH] git-p4.py: add support for filetype change","fromName":"Romain Picard","fromEmail":"romain.picard@oakbits.com","sentAt":"2015-12-21T13:09:25Z","receivedAt":"2015-12-21T13:09:25Z","isPatch":true,"sender":{"key":"romain.picard@oakbits.com","avatar":"https://avatars.githubusercontent.com/u/814804?v=4"},"body":"After changing the type of a file in the git repository, it is not possible to\n\"git p4 publish\" the commit to perforce. This is due to the fact that the git\n\"T\" status is not handled in git-p4.py. This can typically occur when replacing\nan existing file with a symbolic link.\n\nThe \"T\" modifier is now supported in git-p4.py. When a file type has changed,\ninform perforce with the \"p4 edit -f auto\" command.\n\nSigned-off-by: Romain Picard <romain.picard@oakbits.com>\n---\n git-p4.py | 9 +++++++--\n 1 file changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/git-p4.py b/git-p4.py\nindex a7ec118..b7a3494 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -240,8 +240,8 @@ def p4_add(f):\n def p4_delete(f):\n     p4_system([\"delete\", wildcard_encode(f)])\n \n-def p4_edit(f):\n-    p4_system([\"edit\", wildcard_encode(f)])\n+def p4_edit(f, *options):\n+    p4_system([\"edit\"] + list(options) + [wildcard_encode(f)])\n \n def p4_revert(f):\n     p4_system([\"revert\", wildcard_encode(f)])\n@@ -1344,6 +1344,7 @@ class P4Submit(Command, P4UserMap):\n \n         diff = read_pipe_lines(\"git diff-tree -r %s \\\"%s^\\\" \\\"%s\\\"\" % (self.diffOpts, id, id))\n         filesToAdd = set()\n+        filesToChangeType = set()\n         filesToDelete = set()\n         editedFiles = set()\n         pureRenameCopy = set()\n@@ -1404,6 +1405,8 @@ class P4Submit(Command, P4UserMap):\n                     os.unlink(dest)\n                     filesToDelete.add(src)\n                 editedFiles.add(dest)\n+            elif modifier == \"T\":\n+                filesToChangeType.add(path)\n             else:\n                 die(\"unknown modifier %s for %s\" % (modifier, path))\n \n@@ -1463,6 +1466,8 @@ class P4Submit(Command, P4UserMap):\n         #\n         system(applyPatchCmd)\n \n+        for f in filesToChangeType:\n+            p4_edit(f, \"-t\", \"auto\")\n         for f in filesToAdd:\n             p4_add(f)\n         for f in filesToDelete:\n-- \n2.6.4\n"},{"id":"275003","messageId":"CAE5ih7-3H=O8GqzGebzKTttwUs=HRA+B+pV85sfWoesAvKXKgg@mail.gmail.com","threadId":"41052","inReplyTo":"1450703365-10427-1-git-send-email-romain.picard@oakbits.com","subject":"Re: [PATCH] git-p4.py: add support for filetype change","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2015-12-26T10:26:41Z","receivedAt":"2015-12-26T10:26:41Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"On 21 December 2015 at 13:09, Romain Picard <romain.picard@oakbits.com> wrote:\n> After changing the type of a file in the git repository, it is not possible to\n> \"git p4 publish\" the commit to perforce. This is due to the fact that the git\n> \"T\" status is not handled in git-p4.py. This can typically occur when replacing\n> an existing file with a symbolic link.\n>\n> The \"T\" modifier is now supported in git-p4.py. When a file type has changed,\n> inform perforce with the \"p4 edit -f auto\" command.\n\nRomain,\n\nThanks for looking at this. It looks like a reasonable change.\n\nDo you think you could add a unit test as well?\n\nThanks\nLuke\n\n\n>\n> Signed-off-by: Romain Picard <romain.picard@oakbits.com>\n> ---\n>  git-p4.py | 9 +++++++--\n>  1 file changed, 7 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-p4.py b/git-p4.py\n> index a7ec118..b7a3494 100755\n> --- a/git-p4.py\n> +++ b/git-p4.py\n> @@ -240,8 +240,8 @@ def p4_add(f):\n>  def p4_delete(f):\n>      p4_system([\"delete\", wildcard_encode(f)])\n>\n> -def p4_edit(f):\n> -    p4_system([\"edit\", wildcard_encode(f)])\n> +def p4_edit(f, *options):\n> +    p4_system([\"edit\"] + list(options) + [wildcard_encode(f)])\n>\n>  def p4_revert(f):\n>      p4_system([\"revert\", wildcard_encode(f)])\n> @@ -1344,6 +1344,7 @@ class P4Submit(Command, P4UserMap):\n>\n>          diff = read_pipe_lines(\"git diff-tree -r %s \\\"%s^\\\" \\\"%s\\\"\" % (self.diffOpts, id, id))\n>          filesToAdd = set()\n> +        filesToChangeType = set()\n>          filesToDelete = set()\n>          editedFiles = set()\n>          pureRenameCopy = set()\n> @@ -1404,6 +1405,8 @@ class P4Submit(Command, P4UserMap):\n>                      os.unlink(dest)\n>                      filesToDelete.add(src)\n>                  editedFiles.add(dest)\n> +            elif modifier == \"T\":\n> +                filesToChangeType.add(path)\n>              else:\n>                  die(\"unknown modifier %s for %s\" % (modifier, path))\n>\n> @@ -1463,6 +1466,8 @@ class P4Submit(Command, P4UserMap):\n>          #\n>          system(applyPatchCmd)\n>\n> +        for f in filesToChangeType:\n> +            p4_edit(f, \"-t\", \"auto\")\n>          for f in filesToAdd:\n>              p4_add(f)\n>          for f in filesToDelete:\n> --\n> 2.6.4\n"},{"id":"275149","messageId":"3d38fd830e58bef6cd50c41650268244@oakbits.com","threadId":"41052","inReplyTo":"CAE5ih7-3H=O8GqzGebzKTttwUs=HRA+B+pV85sfWoesAvKXKgg@mail.gmail.com","subject":"Re: [PATCH] git-p4.py: add support for filetype change","fromName":"Romain Picard","fromEmail":"romain.picard@oakbits.com","sentAt":"2015-12-29T17:33:12Z","receivedAt":"2015-12-29T17:33:12Z","isPatch":true,"sender":{"key":"romain.picard@oakbits.com","avatar":"https://avatars.githubusercontent.com/u/814804?v=4"},"body":"Le 26.12.2015 11:26, Luke Diamand a écrit :\n> On 21 December 2015 at 13:09, Romain Picard <romain.picard@oakbits.com> \n> wrote:\n>> After changing the type of a file in the git repository, it is not \n>> possible to\n>> \"git p4 publish\" the commit to perforce. This is due to the fact that \n>> the git\n>> \"T\" status is not handled in git-p4.py. This can typically occur when \n>> replacing\n>> an existing file with a symbolic link.\n>> \n>> The \"T\" modifier is now supported in git-p4.py. When a file type has \n>> changed,\n>> inform perforce with the \"p4 edit -f auto\" command.\n> \n> Romain,\n> \n> Thanks for looking at this. It looks like a reasonable change.\n> \n> Do you think you could add a unit test as well?\n\nYes, I will look at the existing tests to see how to add some new ones.\n\n> \n> Thanks\n> Luke\n> \n> \n>> \n>> Signed-off-by: Romain Picard <romain.picard@oakbits.com>\n>> ---\n>>  git-p4.py | 9 +++++++--\n>>  1 file changed, 7 insertions(+), 2 deletions(-)\n>> \n>> diff --git a/git-p4.py b/git-p4.py\n>> index a7ec118..b7a3494 100755\n>> --- a/git-p4.py\n>> +++ b/git-p4.py\n>> @@ -240,8 +240,8 @@ def p4_add(f):\n>>  def p4_delete(f):\n>>      p4_system([\"delete\", wildcard_encode(f)])\n>> \n>> -def p4_edit(f):\n>> -    p4_system([\"edit\", wildcard_encode(f)])\n>> +def p4_edit(f, *options):\n>> +    p4_system([\"edit\"] + list(options) + [wildcard_encode(f)])\n>> \n>>  def p4_revert(f):\n>>      p4_system([\"revert\", wildcard_encode(f)])\n>> @@ -1344,6 +1344,7 @@ class P4Submit(Command, P4UserMap):\n>> \n>>          diff = read_pipe_lines(\"git diff-tree -r %s \\\"%s^\\\" \\\"%s\\\"\" % \n>> (self.diffOpts, id, id))\n>>          filesToAdd = set()\n>> +        filesToChangeType = set()\n>>          filesToDelete = set()\n>>          editedFiles = set()\n>>          pureRenameCopy = set()\n>> @@ -1404,6 +1405,8 @@ class P4Submit(Command, P4UserMap):\n>>                      os.unlink(dest)\n>>                      filesToDelete.add(src)\n>>                  editedFiles.add(dest)\n>> +            elif modifier == \"T\":\n>> +                filesToChangeType.add(path)\n>>              else:\n>>                  die(\"unknown modifier %s for %s\" % (modifier, path))\n>> \n>> @@ -1463,6 +1466,8 @@ class P4Submit(Command, P4UserMap):\n>>          #\n>>          system(applyPatchCmd)\n>> \n>> +        for f in filesToChangeType:\n>> +            p4_edit(f, \"-t\", \"auto\")\n>>          for f in filesToAdd:\n>>              p4_add(f)\n>>          for f in filesToDelete:\n>> --\n>> 2.6.4\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"}]}