summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-12-05 18:00:25 +0100
committerGuido Günther <agx@sigxcpu.org>2011-12-16 23:58:29 +0100
commit2ff6119ac49dc7be84e9f5b01f6e0af4335d1224 (patch)
tree57721d8ce6a73d0e6c39d26d10d94981d79311b8
parent06d109d74be6471e614f42f0b0f5c1c36105d0d9 (diff)
pq: add --force option to fore recreation of pq branch
so one doesn't have to drop the old one first.
-rw-r--r--gbp/scripts/pq.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py
index c44dbb88..28de5a8a 100644
--- a/gbp/scripts/pq.py
+++ b/gbp/scripts/pq.py
@@ -183,7 +183,7 @@ def safe_patches(series):
return (tmpdir, series)
-def import_quilt_patches(repo, branch, series, tries):
+def import_quilt_patches(repo, branch, series, tries, force):
"""
apply a series of quilt patches in the series file 'series' to branch
the patch-queue branch for 'branch'
@@ -193,18 +193,27 @@ def import_quilt_patches(repo, branch, series, tries):
@param series; series file to read patches from
@param tries: try that many times to apply the patches going back one
commit in the branches history after each failure.
+ @param force: import the patch series even if the branch already exists
"""
tmpdir = None
if is_pq_branch(branch):
- gbp.log.err("Already on a patch-queue branch '%s' - doing nothing." % branch)
- raise GbpError
+ if force:
+ branch = pq_branch_base(branch)
+ pq_branch = pq_branch_name(branch)
+ repo.checkout(branch)
+ else:
+ gbp.log.err("Already on a patch-queue branch '%s' - doing nothing." % branch)
+ raise GbpError
else:
pq_branch = pq_branch_name(branch)
if repo.has_branch(pq_branch):
- raise GbpError, ("Patch queue branch '%s'. already exists. Try 'rebase' instead."
- % pq_branch)
+ if force:
+ drop_pq(repo, branch)
+ else:
+ raise GbpError, ("Patch queue branch '%s'. already exists. Try 'rebase' instead."
+ % pq_branch)
commits = repo.get_commits(options=['-%d' % tries], first_parent=True)
# If we go back in history we have to safe our pq so we always try to apply
@@ -362,6 +371,8 @@ def main(argv):
help="verbose command execution")
parser.add_option("--topic", dest="topic", help="in case of 'apply' topic (subdir) to put patch into")
parser.add_config_file_option(option_name="time-machine", dest="time_machine", type="int")
+ parser.add_option("--force", dest="force", action="store_true", default=False,
+ help="in case of import even import if the branch already exists")
parser.add_config_file_option(option_name="color", dest="color", type='tristate')
(options, args) = parser.parse_args(argv)
@@ -398,7 +409,7 @@ def main(argv):
elif action == "import":
series = SERIES_FILE
tries = options.time_machine if (options.time_machine > 0) else 1
- import_quilt_patches(repo, current, series, tries)
+ import_quilt_patches(repo, current, series, tries, options.force)
current = repo.get_branch()
gbp.log.info("Patches listed in '%s' imported on '%s'" %
(series, current))