diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-05-24 19:12:10 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-05-24 19:52:10 +0900 |
commit | 002190d996edad6a8a29158fef5c94586d889524 (patch) | |
tree | 8bb35574f2b099453dfee581af0bbc9134a886ea | |
parent | 08d1694545d1d62295c7beba1fea65a21b93a723 (diff) | |
download | buildstream-002190d996edad6a8a29158fef5c94586d889524.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-- | buildstream/_loader/loader.py | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py index 1d7476776..2efc4d360 100644 --- a/buildstream/_loader/loader.py +++ b/buildstream/_loader/loader.py @@ -534,29 +534,31 @@ class Loader(): element = Element._new_from_meta(meta_element, self._context.artifactcache) element._preflight() + element._update_state() - for source in element.sources(): - # Handle the case where a subproject needs to be fetched - # - if source.get_consistency() == Consistency.RESOLVED: - if fetch_subprojects: + # Handle the case where a subproject needs to be fetched + # + if element._get_consistency() == Consistency.RESOLVED: + if fetch_subprojects: + for source in element.sources(): if ticker: ticker(filename, 'Fetching subproject from {} source'.format(source.get_kind())) - source._fetch() - else: - detail = "Try fetching the project with `bst fetch {}`".format(filename) - raise LoadError(LoadErrorReason.SUBPROJECT_FETCH_NEEDED, - "Subproject fetch needed for junction: {}".format(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 track {}`".format(filename) - raise LoadError(LoadErrorReason.SUBPROJECT_INCONSISTENT, - "Subproject has no ref for junction: {}".format(filename), + if source._get_consistency() != Consistency.CACHED: + source._fetch() + else: + detail = "Try fetching the project with `bst fetch {}`".format(filename) + raise LoadError(LoadErrorReason.SUBPROJECT_FETCH_NEEDED, + "Subproject fetch needed for junction: {}".format(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 track {}`".format(filename) + raise LoadError(LoadErrorReason.SUBPROJECT_INCONSISTENT, + "Subproject has no ref for junction: {}".format(filename), + detail=detail) + # Stage sources os.makedirs(self._context.builddir, exist_ok=True) basedir = tempfile.mkdtemp(prefix="{}-".format(element.normal_name), dir=self._context.builddir) |