summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2018-04-13 16:47:18 +0100
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-07-29 17:12:42 +0900
commit5497b2122931b83dd2d574b9e4823d594cc05d8f (patch)
treed9be0718991013bcbbc0813f5f4d0ced5e2e4d42
parent8a9fd8e1f757ebde1e8b417240c15d35c00ae3aa (diff)
downloadbuildstream-5497b2122931b83dd2d574b9e4823d594cc05d8f.tar.gz
bzr.py: Improve mirror support
This fixes: * Bzr repositories pulling from the branch they were created with. * Bzr's _ensure_mirror() not actually checking that it successfully mirrored the ref.
-rw-r--r--buildstream/plugins/sources/bzr.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/buildstream/plugins/sources/bzr.py b/buildstream/plugins/sources/bzr.py
index 21121428c..c1e289704 100644
--- a/buildstream/plugins/sources/bzr.py
+++ b/buildstream/plugins/sources/bzr.py
@@ -102,7 +102,7 @@ class BzrSource(Source):
def track(self):
with self.timed_activity("Tracking {}".format(self.url),
silent_nested=True):
- self._ensure_mirror()
+ self._ensure_mirror(skip_ref_check=True)
ret, out = self.check_output([self.host_bzr, "version-info",
"--custom", "--template={revno}",
self._get_branch_dir()],
@@ -212,7 +212,7 @@ class BzrSource(Source):
yield repodir
self._atomic_replace_mirrordir(repodir)
- def _ensure_mirror(self):
+ def _ensure_mirror(self, skip_ref_check=False):
with self._atomic_repodir() as repodir:
# Initialize repo if no metadata
bzr_metadata_dir = os.path.join(repodir, ".bzr")
@@ -221,18 +221,21 @@ class BzrSource(Source):
fail="Failed to initialize bzr repository")
branch_dir = os.path.join(repodir, self.tracking)
+ branch_url = self.url + "/" + self.tracking
if not os.path.exists(branch_dir):
# `bzr branch` the branch if it doesn't exist
# to get the upstream code
- branch_url = self.url + "/" + self.tracking
self.call([self.host_bzr, "branch", branch_url, branch_dir],
fail="Failed to branch from {} to {}".format(branch_url, branch_dir))
else:
# `bzr pull` the branch if it does exist
# to get any changes to the upstream code
- self.call([self.host_bzr, "pull", "--directory={}".format(branch_dir)],
+ self.call([self.host_bzr, "pull", "--directory={}".format(branch_dir), branch_url],
fail="Failed to pull new changes for {}".format(branch_dir))
+ if not skip_ref_check and not self._check_ref():
+ raise SourceError("Failed to ensure ref '{}' was mirrored".format(self.ref),
+ reason="ref-not-mirrored")
def setup():