Re: [PATCH] git-p4.py: add support for filetype change
- From
Luke Diamand <luke@diamand.org>
- Date
- Dec 26, 2015, 10:26 UTC
- Message-ID
- <CAE5ih7-3H=O8GqzGebzKTttwUs=HRA+B+pV85sfWoesAvKXKgg@mail.gmail.com>
- In-Reply-To
- <1450703365-10427-1-git-send-email-romain.picard@oakbits.com>
On 21 December 2015 at 13:09, Romain Picard <romain.picard@oakbits.com> wrote:
Show 7 quoted lines
> 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
Show 49 quoted lines
>
> 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