aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/scripts
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-12-26 13:45:08 +0100
committerGuido Günther <agx@sigxcpu.org>2011-12-26 14:02:29 +0100
commit01a268968770bf265ca2fa3df158ee4936d741d6 (patch)
tree199c31dece68000bd2ae90b7435547940307d920 /gbp/scripts
parent694dd200e3ad985b904952e0102a73470b4bb583 (diff)
gbp-pq: add "switch" action
to quickly switch between patch-queue and base branch.
Diffstat (limited to 'gbp/scripts')
-rw-r--r--gbp/scripts/pq.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py
index 78eb6a24..1852973d 100644
--- a/gbp/scripts/pq.py
+++ b/gbp/scripts/pq.py
@@ -250,8 +250,10 @@ def import_quilt_patches(repo, branch, series, tries, force):
def switch_to_pq_branch(repo, branch):
- """Switch to patch-queue branch if not already there, create it if it
- doesn't exist yet"""
+ """
+ Switch to patch-queue branch if not already there, create it if it
+ doesn't exist yet
+ """
if is_pq_branch (branch):
return
@@ -320,6 +322,16 @@ def rebase_pq(repo, branch):
GitCommand("rebase")([base])
+def switch_pq(repo, current):
+ """Switch to patch-queue branch if on base branch and vice versa"""
+ if is_pq_branch(current):
+ base = pq_branch_base(current)
+ gbp.log.info("Switching to %s" % base)
+ repo.checkout(base)
+ else:
+ switch_to_pq_branch(repo, current)
+
+
def main(argv):
retval = 0
@@ -333,7 +345,8 @@ def main(argv):
" rebase switch to patch queue branch associated to the current\n"
" branch and rebase against current branch.\n"
" drop drop (delete) the patch queue associated to the current branch.\n"
- " apply apply a patch\n")
+ " apply apply a patch\n"
+ " switch switch to patch-queue branch and vice versa")
parser.add_boolean_config_file_option(option_name="patch-numbers", dest="patch_numbers")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
@@ -352,7 +365,7 @@ def main(argv):
else:
action = args[1]
- if args[1] in ["export", "import", "rebase", "drop"]:
+ if args[1] in ["export", "import", "rebase", "drop", "switch"]:
pass
elif args[1] in ["apply"]:
if len(args) != 3:
@@ -388,6 +401,8 @@ def main(argv):
elif action == "apply":
patch = Patch(patchfile)
apply_single_patch(repo, current, patch, options.topic)
+ elif action == "switch":
+ switch_pq(repo, current)
except CommandExecFailed:
retval = 1
except GbpError, err: