pq-rpm: don't create pq branch when switching
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Wed, 9 Apr 2014 13:48:45 +0000 (16:48 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Mar 2015 08:07:48 +0000 (10:07 +0200)
Pq branch must be created with 'import'.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/scripts/pq_rpm.py
tests/component/rpm/test_pq_rpm.py

index 875ea2c596070110af8a22320668d105484ce4c8..ee4c7149d6233e3d12b09fa524512c45d13a9d92 100755 (executable)
@@ -491,15 +491,12 @@ def switch_to_pq_branch(repo, branch, options):
     spec = parse_spec(options, repo, branch)
     pq_branch = pq_branch_name(branch, options, spec.version)
     if not repo.has_branch(pq_branch):
-        upstream_commit = find_upstream_commit(repo, spec, options.upstream_tag)
-        try:
-            repo.create_branch(pq_branch, rev=upstream_commit)
-        except GitRepositoryError as err:
-            raise GbpError("Cannot create patch-queue branch: %s" % err)
+        raise GbpError("Branch '%s' does not exist" % pq_branch)
 
     gbp.log.info("Switching to branch '%s'" % pq_branch)
     repo.set_branch(pq_branch)
 
+
 def apply_single_patch(repo, patchfile, options):
     """Apply a single patch onto the pq branch"""
     current = repo.get_branch()
index 46180851c76ebe4042b9291b32077e877d9aa476..24fb283e3ade5d18ebadd5184c1f99d1babe2e51 100644 (file)
@@ -160,18 +160,22 @@ class TestPqRpm(RpmRepoTestBase):
         repo = self.init_test_repo('gbp-test')
         pkg_files = repo.list_files()
         branches = repo.get_local_branches() + ['development/master']
-        upstr_files = ['dummy.sh', 'Makefile', 'README']
-        # Switch to non-existent pq-branch should create one
+        # Switch to non-existent pq-branch should fail
+        eq_(mock_pq(['switch']), 1)
+        self._check_log(-1, ".*Branch 'development/master' does not exist")
+
+        # Import and switch to base branch and back to pq
+        eq_(mock_pq(['import']), 0)
         eq_(mock_pq(['switch']), 0)
-        self._check_repo_state(repo, 'development/master', branches,
-                               upstr_files)
+        self._check_repo_state(repo, 'master', branches)
+        eq_(mock_pq(['switch']), 0)
+        self._check_repo_state(repo, 'development/master', branches)
 
         # Switch to base branch and back to pq
         eq_(mock_pq(['switch']), 0)
         self._check_repo_state(repo, 'master', branches, pkg_files)
         eq_(mock_pq(['switch']), 0)
-        self._check_repo_state(repo, 'development/master', branches,
-                               upstr_files)
+        self._check_repo_state(repo, 'development/master', branches)
 
     def test_switch_drop(self):
         """Basic test for drop action"""