summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2019-10-18 14:24:17 +0100
committerTristan Maat <tristan.maat@codethink.co.uk>2019-10-18 17:36:43 +0100
commite3ea19b5cfed14fa3f14a71b86bdb6a49b3d4124 (patch)
treedfddddc838722948c0433daf5232b7b91fd3ec34
parent069b565cab4afffc0d3cfbcaf69db80904356566 (diff)
downloadbuildstream-e3ea19b5cfed14fa3f14a71b86bdb6a49b3d4124.tar.gz
Only run `element.__update_source_state` when necessary
-rw-r--r--src/buildstream/_artifactelement.py1
-rw-r--r--src/buildstream/_loader/loader.py4
-rw-r--r--src/buildstream/_pipeline.py1
-rw-r--r--src/buildstream/element.py21
-rw-r--r--tests/artifactcache/push.py1
5 files changed, 21 insertions, 7 deletions
diff --git a/src/buildstream/_artifactelement.py b/src/buildstream/_artifactelement.py
index 48c3d1769..0baf634b4 100644
--- a/src/buildstream/_artifactelement.py
+++ b/src/buildstream/_artifactelement.py
@@ -80,6 +80,7 @@ class ArtifactElement(Element):
artifact_element = ArtifactElement(context, ref)
# XXX: We need to call update state as it is responsible for
# initialising an Element/ArtifactElement's Artifact (__artifact)
+ artifact_element._update_source_state()
artifact_element._update_state()
cls.__instantiated_artifacts[ref] = artifact_element
diff --git a/src/buildstream/_loader/loader.py b/src/buildstream/_loader/loader.py
index 0c0d9d65a..d89db1375 100644
--- a/src/buildstream/_loader/loader.py
+++ b/src/buildstream/_loader/loader.py
@@ -633,6 +633,10 @@ 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()
# If this junction element points to a sub-sub-project, we need to
diff --git a/src/buildstream/_pipeline.py b/src/buildstream/_pipeline.py
index 943d65e44..c13cb05e9 100644
--- a/src/buildstream/_pipeline.py
+++ b/src/buildstream/_pipeline.py
@@ -152,6 +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()
# We may already have Elements which are cached and have their runtimes
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 9818f737e..860c728ea 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -1263,9 +1263,6 @@ class Element(Plugin):
self._resolved_initial_state = True
context = self._get_context()
- # Compute and determine consistency of sources
- self.__update_source_state()
-
if self._get_consistency() == Consistency.INCONSISTENT:
# Tracking may still be pending
return
@@ -1354,7 +1351,7 @@ class Element(Plugin):
self.__tracking_scheduled = False
- self._update_state()
+ self._update_source_state()
# _track():
#
@@ -1785,7 +1782,7 @@ class Element(Plugin):
# Fetching cannot change the source state from INCONSISTENT to CACHED because
# we prevent fetching when it's INCONSISTENT.
# Therefore, only the source state will change.
- self.__update_source_state()
+ self._update_source_state()
# _pull_pending()
#
@@ -2392,7 +2389,7 @@ class Element(Plugin):
# Private Local Methods #
#############################################################
- # __update_source_state()
+ # _update_source_state()
#
# Updates source consistency state
#
@@ -2400,12 +2397,13 @@ class Element(Plugin):
# cache keys, because the source's ref, whether defined in yaml or
# from the workspace, is a component of the element's cache keys.
#
- def __update_source_state(self):
+ def _update_source_state(self):
# Cannot resolve source state until tracked
if self.__tracking_scheduled:
return
+ old_consistency = self.__consistency
self.__consistency = Consistency.CACHED
workspace = self._get_workspace()
@@ -2425,6 +2423,9 @@ class Element(Plugin):
source._update_state()
self.__consistency = min(self.__consistency, source._get_consistency())
+ if old_consistency != self.__consistency:
+ self._update_state()
+
# __can_build_incrementally()
#
# Check if the element can be built incrementally, this
@@ -3243,6 +3244,9 @@ class Element(Plugin):
assert not rdep.__build_deps_without_strict_cache_key < 0
if rdep.__build_deps_without_strict_cache_key == 0:
+ # FIXME: Get to the bottom of why we need
+ # source cache keys to be updated here
+ rdep._update_source_state()
rdep._update_state()
# __update_ready_for_runtime()
@@ -3279,6 +3283,9 @@ class Element(Plugin):
assert not rdep.__build_deps_without_cache_key < 0
if rdep.__build_deps_without_cache_key == 0:
+ # FIXME: Get to the bottom of why we need
+ # source cache keys to be updated here
+ rdep._update_source_state()
rdep._update_state()
# If the element is cached, and has all of its runtime dependencies cached,
diff --git a/tests/artifactcache/push.py b/tests/artifactcache/push.py
index 8b00d0fb7..d7757c314 100644
--- a/tests/artifactcache/push.py
+++ b/tests/artifactcache/push.py
@@ -40,6 +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()
# Manually setup the CAS remotes