This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch tlater/test_workspace_visible
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit e3ea19b5cfed14fa3f14a71b86bdb6a49b3d4124
Author: Tristan Maat <[email protected]>
AuthorDate: Fri Oct 18 14:24:17 2019 +0100

    Only run `element.__update_source_state` when necessary
---
 src/buildstream/_artifactelement.py |  1 +
 src/buildstream/_loader/loader.py   |  4 ++++
 src/buildstream/_pipeline.py        |  1 +
 src/buildstream/element.py          | 21 ++++++++++++++-------
 tests/artifactcache/push.py         |  1 +
 5 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/buildstream/_artifactelement.py 
b/src/buildstream/_artifactelement.py
index 48c3d17..0baf634 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 0c0d9d6..d89db13 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 943d65e..c13cb05 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 9818f73..860c728 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 8b00d0f..d7757c3 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

Reply via email to