From: Markus Lehtonen Date: Fri, 11 May 2012 07:56:17 +0000 (+0300) Subject: gbp-pq: readiness to configure the pq branch name X-Git-Tag: debian/0.6.26~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90f242f72805074b9e7d2c8980c5da27eaa7f1e5;p=tools%2Fgit-buildpackage.git gbp-pq: readiness to configure the pq branch name All other gbp branches have configurable names. This commit adds the readiness for user to configure/change the name of the patch-queue branches, as well. Patch-queue is defined in options as a format string, where '%(branch)s' refers to the debian/packaging branch. If the pq-branch format string does not contain '%(branch)s', there is only one patch-queue branch and the debian/packaging branch is used as its base branch. That is, e.g. a 'gbp-pq switch' operation from the patch-queue branch always switches to the debian/packaging branch. Signed-off-by: Markus Lehtonen Signed-off-by: Olev Kartau Conflicts: gbp/scripts/common/pq.py --- diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py index a91ec8e9..c2bc629e 100644 --- a/gbp/scripts/common/pq.py +++ b/gbp/scripts/common/pq.py @@ -88,6 +88,10 @@ def is_pq_branch(branch, options): return True return False + pq_re = re.compile(r'^%s$' % (pq_format_str % dict(branch="(?P\S+)"))) + if pq_re.match(branch): + return True + return False def pq_branch_name(branch, options, extra_keys=None): """ @@ -116,6 +120,8 @@ def pq_branch_name(branch, options, extra_keys=None): if not is_pq_branch(branch, options): return pq_format_str % format_fields + if not is_pq_branch(branch, options): + return pq_format_str % dict(branch=branch) def pq_branch_base(pq_branch, options): """ @@ -331,7 +337,11 @@ def get_maintainer_from_control(repo): return GitModifier() +<<<<<<< HEAD def switch_to_pq_branch(repo, branch, options, name_keys=None): +======= +def switch_to_pq_branch(repo, branch, options): +>>>>>>> 3ba82da... gbp-pq: readiness to configure the pq branch name """ Switch to patch-queue branch if not already there, create it if it doesn't exist yet @@ -339,7 +349,11 @@ def switch_to_pq_branch(repo, branch, options, name_keys=None): if is_pq_branch(branch, options): return +<<<<<<< HEAD pq_branch = pq_branch_name(branch, options, name_keys) +======= + pq_branch = pq_branch_name(branch, options) +>>>>>>> 3ba82da... gbp-pq: readiness to configure the pq branch name if not repo.has_branch(pq_branch): try: repo.create_branch(pq_branch) @@ -382,12 +396,20 @@ def apply_and_commit_patch(repo, patch, fallback_author, topic=None): repo.update_ref('HEAD', commit, msg="gbp-pq import %s" % patch.path) +<<<<<<< HEAD def drop_pq(repo, branch, options, name_keys=None): +======= +def drop_pq(repo, branch, options): +>>>>>>> 3ba82da... gbp-pq: readiness to configure the pq branch name if is_pq_branch(branch, options): gbp.log.err("On a patch-queue branch, can't drop it.") raise GbpError else: +<<<<<<< HEAD pq_branch = pq_branch_name(branch, options, name_keys) +======= + pq_branch = pq_branch_name(branch, options) +>>>>>>> 3ba82da... gbp-pq: readiness to configure the pq branch name if repo.has_branch(pq_branch): repo.delete_branch(pq_branch) diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index 70adf6e9..02b74e75 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -193,7 +193,7 @@ def export_patches(repo, branch, options): gbp.log.info("No patches on '%s' - nothing to do." % pq_branch) if options.drop: - drop_pq(repo, branch) + drop_pq(repo, branch, options) def safe_patches(series, tmpdir_base): diff --git a/tests/13_test_gbp_pq.py b/tests/13_test_gbp_pq.py index 87bcd796..f71c5420 100644 --- a/tests/13_test_gbp_pq.py +++ b/tests/13_test_gbp_pq.py @@ -151,7 +151,7 @@ class TestExport(testutils.DebianGitTestRepo): repo = self.repo start = repo.get_branch() pq = os.path.join('patch-queue', start) - switch_pq(repo, start) + switch_pq(repo, start, TestExport.Options) self.assertEqual(repo.get_branch(), pq) export_patches(repo, pq, TestExport.Options) self.assertEqual(repo.get_branch(), start)