diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-12-26 13:45:08 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-12-26 14:02:29 +0100 |
commit | 01a268968770bf265ca2fa3df158ee4936d741d6 (patch) | |
tree | 199c31dece68000bd2ae90b7435547940307d920 | |
parent | 694dd200e3ad985b904952e0102a73470b4bb583 (diff) |
gbp-pq: add "switch" action
to quickly switch between patch-queue and base branch.
-rw-r--r-- | docs/manpages/gbp-pq.sgml | 20 | ||||
-rw-r--r-- | gbp/scripts/pq.py | 23 |
2 files changed, 34 insertions, 9 deletions
diff --git a/docs/manpages/gbp-pq.sgml b/docs/manpages/gbp-pq.sgml index 43e372f..cb0df02 100644 --- a/docs/manpages/gbp-pq.sgml +++ b/docs/manpages/gbp-pq.sgml @@ -26,11 +26,11 @@ <arg><option>--topic=</option><replaceable>topic</replaceable></arg> <arg><option>--time-machine=</option><replaceable>num</replaceable></arg> <group choice="plain"> - <arg><option>export</option></arg> - <arg><option>import</option></arg> - <arg><option>rebase</option></arg> - <arg><option>drop</option></arg> - <arg><option>apply</option></arg> + <arg><option>drop</option></arg> + <arg><option>export</option></arg> + <arg><option>import</option></arg> + <arg><option>rebase</option></arg> + <arg><option>switch</option></arg> </group> </cmdsynopsis> </refsynopsisdiv> @@ -106,6 +106,16 @@ pathes from debian specific patches.</para> </listitem> </varlistentry> + <varlistentry> + <term><option>switch</option> + </term> + <listitem> + <para> + Switch to the patch-queue branch if on the base branch and switch + to base branch if on patch-queue branch. + </para> + </listitem> + </varlistentry> </variablelist> </refsect1> <refsect1> diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index 78eb6a2..1852973 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: |