bootstrap: add manifest subclass
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 10 Jun 2014 12:51:09 +0000 (15:51 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 10 Jun 2014 12:53:50 +0000 (15:53 +0300)
Move add_project() functionality from gbp back to the test data repo.
This functionality is only used here so it makes sense to maintain it
here, too.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
bootstrap.py

index ec6c321d8b547ec7ce83aac79bc79550556fd9ea..08506be0d975a1bc5d88b56b3ad3f44b49bf8ec0 100755 (executable)
@@ -48,6 +48,20 @@ class GitError(Exception):
     pass
 
 
+class TestDataRepoManifest(RepoManifest):
+    """Test repo manifest"""
+    def add_project(self, name, branches):
+        """Add new project to the manifest"""
+        prj_e = self._doc.createElement('project')
+        prj_e.setAttribute('name', name)
+        for branch, revision in branches.iteritems():
+            br_e = self._doc.createElement('branch')
+            br_e.setAttribute('name', branch)
+            br_e.setAttribute('revision', revision)
+            prj_e.appendChild(br_e)
+        self._doc.firstChild.appendChild(prj_e)
+
+
 def run_cmd(cmd, opts=None, capture_stdout=False, capture_stderr=False):
     """Run command"""
     args = [cmd] + opts if opts else [cmd]
@@ -206,7 +220,7 @@ def main(argv=None):
         if args.update_branches != 'no':
             force = True if args.update_branches == 'force' else False
             update_from_remote('origin', force=force)
-        test_manifest = RepoManifest()
+        test_manifest = TestDataRepoManifest()
         for pkg, pkgconf in TEST_PKGS.iteritems():
             if 'export_branches' in pkgconf:
                 update_testrepo_manifest(test_manifest, pkg,