Re: [PATCH] git-p4 - Add option --sha1 to submit in p4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2 May 2018 at 15:32, Merland Romain <merlorom@xxxxxxxx> wrote:
> From 4867808cad2b759ebf31c275356e602b72c5659f Mon Sep 17 00:00:00 2001
> From: Romain Merland <merlorom@xxxxxxxx>
> To: git@xxxxxxxxxxxxxxx
> Cc: Junio C Hamano <gitster@xxxxxxxxx>, Jeff King <peff@xxxxxxxx>, Luke
> Diamand <luke@xxxxxxxxxxx>, Vinicius Kursancew <viniciusalexandre@xxxxxxxxx>
> Date: Wed, 2 May 2018 15:02:11 +0200
> Subject: [PATCH] git-p4 - Add option --sha1 to submit in p4
>
> Add option --sha1 to command 'git-p4 submit' in order to submit in p4 a
> commit
> that is not necessarily on master.
> In that case, don't rebase the submitted changes.

That could be very useful, I often find the commit I want to submit is
half-way down a long list of other commits.

Currently I end up cherry-picking the one I want into a clean repo,
but that's much more awkward than your --sha1 change.

A few comments inline:

> Signed-off-by: Romain Merland <merlorom@xxxxxxxx>
> ---
>  git-p4.py | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/git-p4.py b/git-p4.py
> index 7bb9cadc6..d64ff79dd 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -1352,7 +1352,9 @@ class P4Submit(Command, P4UserMap):
>                  optparse.make_option("--update-shelve",
> dest="update_shelve", action="append", type="int",
>                                       metavar="CHANGELIST",
>                                       help="update an existing shelved
> changelist, implies --shelve, "
> -                                           "repeat in-order for multiple
> shelved changelists")
> +                                           "repeat in-order for multiple
> shelved changelists"),
> +                optparse.make_option("--sha1", dest="sha1", metavar="SHA1",
> +                                     help="submit only the specified
> commit, don't rebase afterwards")

Is there a better name than "sha1" ? If git ever changes its hash to
something else will this still make sense?

I wonder why you wouldn't rebase afterwards?

Perhaps an additional option to skip the rebase?

>          ]
>          self.description = "Submit changes from git to the perforce depot."
>          self.usage += " [name of git branch to submit into perforce depot]"
> @@ -1362,6 +1364,7 @@ class P4Submit(Command, P4UserMap):
>          self.dry_run = False
>          self.shelve = False
>          self.update_shelve = list()
> +        self.sha1 = ""
>          self.prepare_p4_only = False
>          self.conflict_behavior = None
>          self.isWindows = (platform.system() == "Windows")
> @@ -2103,9 +2106,12 @@ class P4Submit(Command, P4UserMap):
>          else:
>              commitish = 'HEAD'
>
> -        for line in read_pipe_lines(["git", "rev-list", "--no-merges",
> "%s..%s" % (self.origin, commitish)]):
> -            commits.append(line.strip())
> -        commits.reverse()
> +        if self.sha1 != "":
> +            commits.append(self.sha1)
> +        else:
> +            for line in read_pipe_lines(["git", "rev-list", "--no-merges",
> "%s..%s" % (self.origin, commitish)]):
> +                commits.append(line.strip())
> +            commits.reverse()
>
>          if self.preserveUser or gitConfigBool("git-p4.skipUserNameCheck"):
>              self.checkAuthorship = False
> @@ -2215,8 +2221,11 @@ class P4Submit(Command, P4UserMap):
>                  sync.branch = self.branch
>              sync.run([])
>
> -            rebase = P4Rebase()
> -            rebase.rebase()
> +            if self.sha1 == "":

if not self.skip_rebase:

> +                rebase = P4Rebase()
> +                rebase.rebase()
> +            else:
> +                print "You will have to do 'git p4 sync' and rebase."
>
>          else:
>              if len(applied) == 0:
> --
> 2.17.0
>
>

This would be better with some documentation in git-p4.txt and a test case!

Regards!
Luke



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux