From 73b6e1e5df904d2e4079b7ae89a00d3ee9ef1b5b Mon Sep 17 00:00:00 2001 From: Jonathan Maw Date: Mon, 15 Jan 2018 17:49:23 +0000 Subject: 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 --- buildstream/plugins/sources/bzr.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'buildstream') 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()): -- cgit v1.2.1