summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2019-10-18 17:54:42 +0100
committerTristan Maat <tristan.maat@codethink.co.uk>2019-10-18 17:54:42 +0100
commit34d38738da8e8db3b751e5918cfb70d3b29e2a58 (patch)
treeda50bbf8926aa93f8a648224b4f546c0041ef05f
parente3ea19b5cfed14fa3f14a71b86bdb6a49b3d4124 (diff)
downloadbuildstream-tlater/test_workspace_visible.tar.gz
Create _initialize_state() to capture an _update_state() use casetlater/test_workspace_visible
-rw-r--r--src/buildstream/_artifactelement.py7
-rw-r--r--src/buildstream/_loader/loader.py6
-rw-r--r--src/buildstream/_pipeline.py3
-rw-r--r--src/buildstream/element.py15
-rw-r--r--tests/artifactcache/push.py3
5 files changed, 20 insertions, 14 deletions
diff --git a/src/buildstream/_artifactelement.py b/src/buildstream/_artifactelement.py
index 0baf634b4..c5df67e72 100644
--- a/src/buildstream/_artifactelement.py
+++ b/src/buildstream/_artifactelement.py
@@ -78,10 +78,11 @@ class ArtifactElement(Element):
return cls.__instantiated_artifacts[ref]
artifact_element = ArtifactElement(context, ref)
- # XXX: We need to call update state as it is responsible for
+ # XXX: We need to call initialize_state as it is responsible for
# initialising an Element/ArtifactElement's Artifact (__artifact)
- artifact_element._update_source_state()
- artifact_element._update_state()
+ #
+ # Not sure why _source_state is important for this, though...
+ artifact_element._initialize_state()
cls.__instantiated_artifacts[ref] = artifact_element
for dep_ref in artifact_element.get_dependency_refs(Scope.BUILD):
diff --git a/src/buildstream/_loader/loader.py b/src/buildstream/_loader/loader.py
index d89db1375..c5970fd9e 100644
--- a/src/buildstream/_loader/loader.py
+++ b/src/buildstream/_loader/loader.py
@@ -633,11 +633,7 @@ class Loader():
LoadErrorReason.INVALID_JUNCTION)
element = Element._new_from_meta(meta_element)
- element._update_source_state()
- # FIXME: We're doubly updating here for the moment; this
- # should be removed once we don't need the entirety of
- # _update_state() anymore
- element._update_state()
+ element._initialize_state()
# If this junction element points to a sub-sub-project, we need to
# find loader for that project.
diff --git a/src/buildstream/_pipeline.py b/src/buildstream/_pipeline.py
index c13cb05e9..39d5bc37e 100644
--- a/src/buildstream/_pipeline.py
+++ b/src/buildstream/_pipeline.py
@@ -152,8 +152,7 @@ class Pipeline():
for element in self.dependencies(targets, Scope.ALL):
# Determine initial element state.
if not element._resolved_initial_state:
- element._update_source_state()
- element._update_state()
+ element._initialize_state()
# We may already have Elements which are cached and have their runtimes
# cached, if this is the case, we should immediately notify their reverse
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 860c728ea..975f67c61 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -1251,6 +1251,16 @@ class Element(Plugin):
# cache cannot be queried until strict cache key is available
return self.__strict_cache_key is not None
+ def _initialize_state(self):
+ # assert not self._resolved_initial_state, "_initialize_state() should only be called once"
+ self._resolved_initial_state = True
+
+ self._update_source_state()
+ # FIXME: This should be unrolled; currently we're doing the
+ # work twice because _update_source_state() *probably* calls
+ # it, but might not.
+ self._update_state()
+
# _update_state()
#
# Keep track of element state. Calculate cache keys if possible and
@@ -1259,8 +1269,9 @@ class Element(Plugin):
# This must be called whenever the state of an element may have changed.
#
def _update_state(self):
- if not self._resolved_initial_state:
- self._resolved_initial_state = True
+ # assert self._resolved_initial_state, "_initialize_state() should be called first"
+ self._resolved_initial_state = True
+
context = self._get_context()
if self._get_consistency() == Consistency.INCONSISTENT:
diff --git a/tests/artifactcache/push.py b/tests/artifactcache/push.py
index d7757c314..ae7d37066 100644
--- a/tests/artifactcache/push.py
+++ b/tests/artifactcache/push.py
@@ -40,8 +40,7 @@ def _push(cli, cache_dir, project_dir, config_file, target):
# as this test does not use the cli frontend.
for e in element.dependencies(Scope.ALL):
# Determine initial element state.
- e._update_source_state()
- e._update_state()
+ e._initialize_state()
# Manually setup the CAS remotes
artifactcache.setup_remotes(use_config=True)