From 83a3fdf8de3c8f5c2c8756be4fd36b89c45b0ac6 Mon Sep 17 00:00:00 2001 From: John Berthels Date: Tue, 4 Sep 2012 17:24:51 +0100 Subject: [PATCH 1/2] add --dry-run option to 'p4 submit' --- git-p4 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/git-p4 b/git-p4 index dd87cb5..33799e3 100755 --- a/git-p4 +++ b/git-p4 @@ -811,6 +811,7 @@ class P4Submit(Command): Command.__init__(self) self.options = [ optparse.make_option("--verbose", dest="verbose", action="store_true"), + optparse.make_option("--dry-run", dest="dryRun", action="store_true"), optparse.make_option("--origin", dest="origin"), optparse.make_option("--auto", dest="interactive", action="store_false", help="Automatically submit changelists without requiring editing"), optparse.make_option("-M", dest="detectRename", action="store_true", help="detect renames"), @@ -829,6 +830,7 @@ class P4Submit(Command): if gitConfig("git-p4.detectCopy") == "true": self.detectCopy = True self.verbose = False + self.dryRun = False self.isWindows = (platform.system() == "Windows") self.importIntoRemotes = True if gitConfig("git-p4.importIntoRemotes") == "false": @@ -1159,6 +1161,12 @@ class P4Submit(Command): if self.verbose: print "Commits to apply: %s" % self.commits + if self.dryRun: + print "Would submit" + for commit in self.commits: + print (read_pipe("git log --max-count=1 --pretty=oneline %s" % commit)) + return True + self.applyCommits() if self.abort == False: From b68a035c5c6a39ec5f75eee3fff38f2090f3aa57 Mon Sep 17 00:00:00 2001 From: John Berthels Date: Tue, 18 Sep 2012 10:58:48 +0100 Subject: [PATCH 2/2] change behaviour when submitting merges. Default to squashing merged branches to a single commit. Add --no-squash to get current behaviour --- git-p4 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-p4 b/git-p4 index 33799e3..376e8c6 100755 --- a/git-p4 +++ b/git-p4 @@ -812,6 +812,7 @@ class P4Submit(Command): self.options = [ optparse.make_option("--verbose", dest="verbose", action="store_true"), optparse.make_option("--dry-run", dest="dryRun", action="store_true"), + optparse.make_option("--no-squash", dest="noSquash", action="store_true"), optparse.make_option("--origin", dest="origin"), optparse.make_option("--auto", dest="interactive", action="store_false", help="Automatically submit changelists without requiring editing"), optparse.make_option("-M", dest="detectRename", action="store_true", help="detect renames"), @@ -831,6 +832,7 @@ class P4Submit(Command): self.detectCopy = True self.verbose = False self.dryRun = False + self.noSquash = False self.isWindows = (platform.system() == "Windows") self.importIntoRemotes = True if gitConfig("git-p4.importIntoRemotes") == "false": @@ -1154,7 +1156,8 @@ class P4Submit(Command): self.check() self.commits = [] - for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)): + revListOption = "--no-merges" if self.noSquash else "--first-parent" + for line in read_pipe_lines("git rev-list %s %s..%s" % (revListOption, self.origin, self.master)): self.commits.append(line.strip()) self.commits.reverse()