git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-p4.py: add support for filetype change
@ 2015-12-21 13:09 Romain Picard
  2015-12-26 10:26 ` Luke Diamand
  0 siblings, 1 reply; 3+ messages in thread
From: Romain Picard @ 2015-12-21 13:09 UTC (permalink / raw)
  To: git; +Cc: Romain Picard

After changing the type of a file in the git repository, it is not possible to
"git p4 publish" the commit to perforce. This is due to the fact that the git
"T" status is not handled in git-p4.py. This can typically occur when replacing
an existing file with a symbolic link.

The "T" modifier is now supported in git-p4.py. When a file type has changed,
inform perforce with the "p4 edit -f auto" command.

Signed-off-by: Romain Picard <romain.picard@oakbits.com>
---
 git-p4.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/git-p4.py b/git-p4.py
index a7ec118..b7a3494 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -240,8 +240,8 @@ def p4_add(f):
 def p4_delete(f):
     p4_system(["delete", wildcard_encode(f)])
 
-def p4_edit(f):
-    p4_system(["edit", wildcard_encode(f)])
+def p4_edit(f, *options):
+    p4_system(["edit"] + list(options) + [wildcard_encode(f)])
 
 def p4_revert(f):
     p4_system(["revert", wildcard_encode(f)])
@@ -1344,6 +1344,7 @@ class P4Submit(Command, P4UserMap):
 
         diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (self.diffOpts, id, id))
         filesToAdd = set()
+        filesToChangeType = set()
         filesToDelete = set()
         editedFiles = set()
         pureRenameCopy = set()
@@ -1404,6 +1405,8 @@ class P4Submit(Command, P4UserMap):
                     os.unlink(dest)
                     filesToDelete.add(src)
                 editedFiles.add(dest)
+            elif modifier == "T":
+                filesToChangeType.add(path)
             else:
                 die("unknown modifier %s for %s" % (modifier, path))
 
@@ -1463,6 +1466,8 @@ class P4Submit(Command, P4UserMap):
         #
         system(applyPatchCmd)
 
+        for f in filesToChangeType:
+            p4_edit(f, "-t", "auto")
         for f in filesToAdd:
             p4_add(f)
         for f in filesToDelete:
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-p4.py: add support for filetype change
  2015-12-21 13:09 [PATCH] git-p4.py: add support for filetype change Romain Picard
@ 2015-12-26 10:26 ` Luke Diamand
  2015-12-29 17:33   ` Romain Picard
  0 siblings, 1 reply; 3+ messages in thread
From: Luke Diamand @ 2015-12-26 10:26 UTC (permalink / raw)
  To: Romain Picard; +Cc: Git Users, Lars Schneider, Eric Sunshine

On 21 December 2015 at 13:09, Romain Picard <romain.picard@oakbits.com> wrote:
> After changing the type of a file in the git repository, it is not possible to
> "git p4 publish" the commit to perforce. This is due to the fact that the git
> "T" status is not handled in git-p4.py. This can typically occur when replacing
> an existing file with a symbolic link.
>
> The "T" modifier is now supported in git-p4.py. When a file type has changed,
> inform perforce with the "p4 edit -f auto" command.

Romain,

Thanks for looking at this. It looks like a reasonable change.

Do you think you could add a unit test as well?

Thanks
Luke


>
> Signed-off-by: Romain Picard <romain.picard@oakbits.com>
> ---
>  git-p4.py | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/git-p4.py b/git-p4.py
> index a7ec118..b7a3494 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -240,8 +240,8 @@ def p4_add(f):
>  def p4_delete(f):
>      p4_system(["delete", wildcard_encode(f)])
>
> -def p4_edit(f):
> -    p4_system(["edit", wildcard_encode(f)])
> +def p4_edit(f, *options):
> +    p4_system(["edit"] + list(options) + [wildcard_encode(f)])
>
>  def p4_revert(f):
>      p4_system(["revert", wildcard_encode(f)])
> @@ -1344,6 +1344,7 @@ class P4Submit(Command, P4UserMap):
>
>          diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (self.diffOpts, id, id))
>          filesToAdd = set()
> +        filesToChangeType = set()
>          filesToDelete = set()
>          editedFiles = set()
>          pureRenameCopy = set()
> @@ -1404,6 +1405,8 @@ class P4Submit(Command, P4UserMap):
>                      os.unlink(dest)
>                      filesToDelete.add(src)
>                  editedFiles.add(dest)
> +            elif modifier == "T":
> +                filesToChangeType.add(path)
>              else:
>                  die("unknown modifier %s for %s" % (modifier, path))
>
> @@ -1463,6 +1466,8 @@ class P4Submit(Command, P4UserMap):
>          #
>          system(applyPatchCmd)
>
> +        for f in filesToChangeType:
> +            p4_edit(f, "-t", "auto")
>          for f in filesToAdd:
>              p4_add(f)
>          for f in filesToDelete:
> --
> 2.6.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-p4.py: add support for filetype change
  2015-12-26 10:26 ` Luke Diamand
@ 2015-12-29 17:33   ` Romain Picard
  0 siblings, 0 replies; 3+ messages in thread
From: Romain Picard @ 2015-12-29 17:33 UTC (permalink / raw)
  To: Luke Diamand; +Cc: Git Users, Lars Schneider, Eric Sunshine, git-owner

Le 26.12.2015 11:26, Luke Diamand a écrit :
> On 21 December 2015 at 13:09, Romain Picard <romain.picard@oakbits.com> 
> wrote:
>> After changing the type of a file in the git repository, it is not 
>> possible to
>> "git p4 publish" the commit to perforce. This is due to the fact that 
>> the git
>> "T" status is not handled in git-p4.py. This can typically occur when 
>> replacing
>> an existing file with a symbolic link.
>> 
>> The "T" modifier is now supported in git-p4.py. When a file type has 
>> changed,
>> inform perforce with the "p4 edit -f auto" command.
> 
> Romain,
> 
> Thanks for looking at this. It looks like a reasonable change.
> 
> Do you think you could add a unit test as well?

Yes, I will look at the existing tests to see how to add some new ones.

> 
> Thanks
> Luke
> 
> 
>> 
>> Signed-off-by: Romain Picard <romain.picard@oakbits.com>
>> ---
>>  git-p4.py | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>> 
>> diff --git a/git-p4.py b/git-p4.py
>> index a7ec118..b7a3494 100755
>> --- a/git-p4.py
>> +++ b/git-p4.py
>> @@ -240,8 +240,8 @@ def p4_add(f):
>>  def p4_delete(f):
>>      p4_system(["delete", wildcard_encode(f)])
>> 
>> -def p4_edit(f):
>> -    p4_system(["edit", wildcard_encode(f)])
>> +def p4_edit(f, *options):
>> +    p4_system(["edit"] + list(options) + [wildcard_encode(f)])
>> 
>>  def p4_revert(f):
>>      p4_system(["revert", wildcard_encode(f)])
>> @@ -1344,6 +1344,7 @@ class P4Submit(Command, P4UserMap):
>> 
>>          diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % 
>> (self.diffOpts, id, id))
>>          filesToAdd = set()
>> +        filesToChangeType = set()
>>          filesToDelete = set()
>>          editedFiles = set()
>>          pureRenameCopy = set()
>> @@ -1404,6 +1405,8 @@ class P4Submit(Command, P4UserMap):
>>                      os.unlink(dest)
>>                      filesToDelete.add(src)
>>                  editedFiles.add(dest)
>> +            elif modifier == "T":
>> +                filesToChangeType.add(path)
>>              else:
>>                  die("unknown modifier %s for %s" % (modifier, path))
>> 
>> @@ -1463,6 +1466,8 @@ class P4Submit(Command, P4UserMap):
>>          #
>>          system(applyPatchCmd)
>> 
>> +        for f in filesToChangeType:
>> +            p4_edit(f, "-t", "auto")
>>          for f in filesToAdd:
>>              p4_add(f)
>>          for f in filesToDelete:
>> --
>> 2.6.4
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-29 20:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-21 13:09 [PATCH] git-p4.py: add support for filetype change Romain Picard
2015-12-26 10:26 ` Luke Diamand
2015-12-29 17:33   ` Romain Picard

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).