summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2018-01-15 17:49:23 +0000
committerJonathan Maw <jonathan.maw@codethink.co.uk>2018-01-17 17:33:34 +0000
commit446697a7976bb2a2333495fa87843006d5e29aaa (patch)
tree7778c39e52857cd74fd2146af3aee2988521676b
parent88260c7a57f9c797af3f8222c02b257b25d25d45 (diff)
downloadbuildstream-446697a7976bb2a2333495fa87843006d5e29aaa.tar.gz
bzr: Implement init_workspace
This will checkout a branch from the cache, and switch its parent branch to the url and ref that the source came from
-rw-r--r--buildstream/plugins/sources/bzr.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/buildstream/plugins/sources/bzr.py b/buildstream/plugins/sources/bzr.py
index cb7cbb040..b3427f835 100644
--- a/buildstream/plugins/sources/bzr.py
+++ b/buildstream/plugins/sources/bzr.py
@@ -113,6 +113,21 @@ class BzrSource(Source):
fail="Failed to checkout revision {} from branch {} to {}"
.format(self.ref, self._get_branch_dir(), directory))
+ def init_workspace(self, directory):
+ url = os.path.join(self.url, self.tracking)
+ with self.timed_activity('Setting up workspace "{}"'.format(directory), silent_nested=True):
+ # Checkout from the cache
+ self.call([self.host_bzr, "branch",
+ "--use-existing-dir",
+ "--revision=revno:{}".format(self.ref),
+ self._get_branch_dir(), directory],
+ fail="Failed to branch revision {} from branch {} to {}"
+ .format(self.ref, self._get_branch_dir(), directory))
+ # Switch the parent branch to the source's origin
+ self.call([self.host_bzr, "switch",
+ "--directory={}".format(directory), url],
+ fail="Failed to switch workspace's parent branch to {}".format(url))
+
def _check_ref(self):
# If the mirror doesnt exist yet, then we dont have the ref
if not os.path.exists(self._get_branch_dir()):