aboutsummaryrefslogtreecommitdiffstats
path: root/git-p4.py
diff options
context:
space:
mode:
authorRomain Merland <merlorom@yahoo.fr>2018-06-01 09:46:14 +0200
committerJunio C Hamano <gitster@pobox.com>2018-06-12 14:45:16 -0700
commitf55b87c1c748cdec7ce1631e6296e3edfd7cfc7d (patch)
tree51b21c9b89aa6b67822d22df31bad18579185496 /git-p4.py
parentccdcbd54c4475c2238b310f7113ab3075b5abc9c (diff)
downloadgit-f55b87c1c748cdec7ce1631e6296e3edfd7cfc7d.tar.gz
git-p4: add options --commit and --disable-rebase
On a daily work with multiple local git branches, the usual way to submit only a specified commit was to cherry-pick the commit on master then run git-p4 submit. It can be very annoying to switch between local branches and master, only to submit one commit. The proposed new way is to select directly the commit you want to submit. Add option --commit to command 'git-p4 submit' in order to submit only specified commit(s) in p4. On a daily work developping software with big compilation time, one may not want to rebase on his local git tree, in order to avoid long recompilation. Add option --disable-rebase to command 'git-p4 submit' in order to disable rebase after submission. Thanks-to: Cedric Borgese <cedric.borgese@gmail.com> Reviewed-by: Luke Diamand <luke@diamand.org> Signed-off-by: Romain Merland <merlorom@yahoo.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-p4.py')
-rwxr-xr-xgit-p4.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/git-p4.py b/git-p4.py
index 7bb9cadc69..f4a6f3b4c3 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1352,7 +1352,12 @@ 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("--commit", dest="commit", metavar="COMMIT",
+ help="submit only the specified commit(s), one commit or xxx..xxx"),
+ optparse.make_option("--disable-rebase", dest="disable_rebase", action="store_true",
+ help="Disable rebase after submit is completed. Can be useful if you "
+ "work from a local git branch that is not master")
]
self.description = "Submit changes from git to the perforce depot."
self.usage += " [name of git branch to submit into perforce depot]"
@@ -1362,6 +1367,8 @@ class P4Submit(Command, P4UserMap):
self.dry_run = False
self.shelve = False
self.update_shelve = list()
+ self.commit = ""
+ self.disable_rebase = False
self.prepare_p4_only = False
self.conflict_behavior = None
self.isWindows = (platform.system() == "Windows")
@@ -2103,9 +2110,18 @@ 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.commit != "":
+ if self.commit.find("..") != -1:
+ limits_ish = self.commit.split("..")
+ for line in read_pipe_lines(["git", "rev-list", "--no-merges", "%s..%s" % (limits_ish[0], limits_ish[1])]):
+ commits.append(line.strip())
+ commits.reverse()
+ else:
+ commits.append(self.commit)
+ 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 +2231,9 @@ class P4Submit(Command, P4UserMap):
sync.branch = self.branch
sync.run([])
- rebase = P4Rebase()
- rebase.rebase()
+ if self.disable_rebase is False:
+ rebase = P4Rebase()
+ rebase.rebase()
else:
if len(applied) == 0: