summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-05-24 19:12:10 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-05-24 19:55:37 +0900
commitbcad4ff67ad7701fba6d8a8d5858f053b1f36eb3 (patch)
treea509ef6c0712a8f6f6e44a8711eb7a17fe751465
parentb01c44fddb5a2b71b36c2239c91d124db1420d73 (diff)
downloadbuildstream-bcad4ff67ad7701fba6d8a8d5858f053b1f36eb3.tar.gz
_loader/loader.py: Check Element._get_consistency() for junction consistency
Instead of looping over the sources directly, we should be using the canonical way of checking element consistency. This requires an additional call to Element._update_state() on the freshly loaded junction element in order to ensure we calculate consistency. This fixes issue #1030.
-rw-r--r--src/buildstream/_loader/loader.py45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/buildstream/_loader/loader.py b/src/buildstream/_loader/loader.py
index 261ec40e4..6287f84aa 100644
--- a/src/buildstream/_loader/loader.py
+++ b/src/buildstream/_loader/loader.py
@@ -518,6 +518,7 @@ class Loader():
element = Element._new_from_meta(meta_element)
element._preflight()
+ element._update_state()
# If this junction element points to a sub-sub-project, we need to
# find loader for that project.
@@ -531,29 +532,29 @@ class Loader():
self._loaders[filename] = loader
return loader
+ # Handle the case where a subproject needs to be fetched
+ #
sources = list(element.sources())
- if not element._source_cached():
- for idx, source in enumerate(sources):
- # Handle the case where a subproject needs to be fetched
- #
- if source.get_consistency() == Consistency.RESOLVED:
- if fetch_subprojects:
- if ticker:
- ticker(filename, 'Fetching subproject from {} source'.format(source.get_kind()))
- source._fetch(sources[0:idx])
- else:
- detail = "Try fetching the project with `bst source fetch {}`".format(filename)
- raise LoadError(LoadErrorReason.SUBPROJECT_FETCH_NEEDED,
- "{}Subproject fetch needed for junction: {}".format(provenance_str, filename),
- detail=detail)
-
- # Handle the case where a subproject has no ref
- #
- elif source.get_consistency() == Consistency.INCONSISTENT:
- detail = "Try tracking the junction element with `bst source track {}`".format(filename)
- raise LoadError(LoadErrorReason.SUBPROJECT_INCONSISTENT,
- "{}Subproject has no ref for junction: {}".format(provenance_str, filename),
- detail=detail)
+ if element._get_consistency() == Consistency.RESOLVED:
+ if fetch_subprojects:
+ for source in sources:
+ if ticker:
+ ticker(filename, 'Fetching subproject from {} source'.format(source.get_kind()))
+ if source._get_consistency() != Consistency.CACHED:
+ source._fetch()
+ else:
+ detail = "Try fetching the project with `bst source fetch {}`".format(filename)
+ raise LoadError(LoadErrorReason.SUBPROJECT_FETCH_NEEDED,
+ "{}Subproject fetch needed for junction: {}".format(provenance_str, filename),
+ detail=detail)
+
+ # Handle the case where a subproject has no ref
+ #
+ elif element._get_consistency() == Consistency.INCONSISTENT:
+ detail = "Try tracking the junction element with `bst source track {}`".format(filename)
+ raise LoadError(LoadErrorReason.SUBPROJECT_INCONSISTENT,
+ "{}Subproject has no ref for junction: {}".format(provenance_str, filename),
+ detail=detail)
workspace = element._get_workspace()
if workspace: