From: Andrew Oakley <aoakley@roku.com>
To: <git@vger.kernel.org>
Cc: <luke@diamand.org>, <larsxschneider@gmail.com>,
Andrew Oakley <aoakley@roku.com>
Subject: [PATCH] git-p4: improve branch option handling
Date: Thu, 20 Apr 2017 14:52:32 +0100 [thread overview]
Message-ID: <20170420135232.16415-1-aoakley@roku.com> (raw)
It is sometimes useful (much quicker) to request commands only operate
on a single branch.
The P4Sync command has been updated to handle self.branch being None for
consitency with the P4Submit.
The P4Rebase command has been given a branch option which is forwarded
to the P4Sync command it runs.
The P4Submit command has been simplified to not call P4Sync itself, it
lets P4Rebase do it instead (now that the branch can be handled). This
fixes an issue where P4Submit does a sync of the requested branch and
then does a rebase which does a sync of all branches.
Signed-off-by: Andrew Oakley <aoakley@roku.com>
---
Documentation/git-p4.txt | 4 ++++
git-p4.py | 15 +++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index 7436c64..a03a291 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -328,6 +328,10 @@ Rebase options
~~~~~~~~~~~~~~
These options can be used to modify 'git p4 rebase' behavior.
+--branch <branch>::
+ Sync this named branch instead of the default p4/master. See the
+ "Sync options" section above for more information.
+
--import-labels::
Import p4 labels.
diff --git a/git-p4.py b/git-p4.py
index 8d151da..e58b34a 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2161,13 +2161,9 @@ class P4Submit(Command, P4UserMap):
elif len(commits) == len(applied):
print ("All commits {0}!".format(shelved_applied))
- sync = P4Sync()
- if self.branch:
- sync.branch = self.branch
- sync.run([])
-
rebase = P4Rebase()
- rebase.rebase()
+ rebase.branch = self.branch
+ rebase.run([])
else:
if len(applied) == 0:
@@ -2343,7 +2339,7 @@ class P4Sync(Command, P4UserMap):
self.silent = False
self.createdBranches = set()
self.committedChanges = set()
- self.branch = ""
+ self.branch = None
self.detectBranches = False
self.detectLabels = False
self.importLabels = False
@@ -3281,7 +3277,7 @@ class P4Sync(Command, P4UserMap):
system("git fetch origin")
branch_arg_given = bool(self.branch)
- if len(self.branch) == 0:
+ if not branch_arg_given:
self.branch = self.refPrefix + "master"
if gitBranchExists("refs/heads/p4") and self.importIntoRemotes:
system("git update-ref %s refs/heads/p4" % self.branch)
@@ -3567,14 +3563,17 @@ class P4Rebase(Command):
def __init__(self):
Command.__init__(self)
self.options = [
+ optparse.make_option("--branch", dest="branch"),
optparse.make_option("--import-labels", dest="importLabels", action="store_true"),
]
+ self.branch = None
self.importLabels = False
self.description = ("Fetches the latest revision from perforce and "
+ "rebases the current work (branch) against it")
def run(self, args):
sync = P4Sync()
+ sync.branch = self.branch
sync.importLabels = self.importLabels
sync.run([])
--
2.10.2
next reply other threads:[~2017-04-20 13:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-20 13:52 Andrew Oakley [this message]
2017-04-20 17:48 ` [PATCH] git-p4: improve branch option handling Luke Diamand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170420135232.16415-1-aoakley@roku.com \
--to=aoakley@roku.com \
--cc=git@vger.kernel.org \
--cc=larsxschneider@gmail.com \
--cc=luke@diamand.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).