gbp-pq: readiness to configure the pq branch name
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 11 May 2012 07:56:17 +0000 (10:56 +0300)
committerJun Wang <junbill.wang@samsung.com>
Wed, 27 Jan 2016 11:16:10 +0000 (19:16 +0800)
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 <markus.lehtonen@linux.intel.com>
Signed-off-by: Olev Kartau <olev.kartau@intel.com>
Conflicts:
gbp/scripts/common/pq.py

gbp/scripts/common/pq.py
gbp/scripts/pq.py
tests/13_test_gbp_pq.py

index a91ec8e93c2506a8c42a619254ec97eb2f97aadb..c2bc629e493cd082d0cc80a8c8dccd81141f603c 100644 (file)
@@ -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<base>\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)
index 70adf6e9ba4db071b9016f000ed775b4a5df0dd9..02b74e756bb566583b407159ac296f2bfe085529 100755 (executable)
@@ -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):
index 87bcd7962144994faa7dc6db70d7cde37eb03b92..f71c5420e8d9d5b1b507efbcd5c8b36cd41ec17b 100644 (file)
@@ -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)