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

tvb pushed a commit to branch shared/split_out_update_state
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit c58f503bc62f58d4cc3f9483c50505ed90bccd4d
Author: Jonathan Maw <[email protected]>
AuthorDate: Wed Apr 24 11:53:37 2019 +0100

    Fixes: Move is_cached out of StrictCacheKey, eliminate setting
    weak_cached
---
 buildstream/_cachekey/cachekey.py       | 15 +++++++++++++--
 buildstream/_cachekey/strictcachekey.py | 20 --------------------
 2 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/buildstream/_cachekey/cachekey.py 
b/buildstream/_cachekey/cachekey.py
index 3a71458..0279ba3 100644
--- a/buildstream/_cachekey/cachekey.py
+++ b/buildstream/_cachekey/cachekey.py
@@ -56,8 +56,6 @@ class CacheKey():
     def maybe_schedule_assemble(self):
         raise ImplError("CacheKey does not implement 
maybe_schedule_assemble()")
 
-    def is_cached(self, strength):
-        raise ImplError("CacheKey does not implement is_cached()")
 
     def tracking_done(self):
         raise ImplError("CacheKey does not implement tracking_done()")
@@ -68,6 +66,19 @@ class CacheKey():
     def assemble_done(self):
         raise ImplError("CacheKey does not implement assemble_done()")
 
+    # PUBLIC METHODS
+
+    def is_cached(self, strength):
+        if strength == _KeyStrength.STRONG:
+            return self._strong_cached
+        elif strength == _KeyStrength.STRICT:
+            # TODO: Understand difference between strict cached and strong 
cached
+            raise AssertionError("I have no idea why it's strong_cached and 
not strict_cached")
+        elif strength == _KeyStrength.WEAK:
+            return self._weak_cached
+        else:
+            raise AssertionError("Bad key strength value {}".format(strength))
+
     # PRIVATE METHODS
 
     def _update_weak_cached(self):
diff --git a/buildstream/_cachekey/strictcachekey.py 
b/buildstream/_cachekey/strictcachekey.py
index e984886..3ab54e3 100644
--- a/buildstream/_cachekey/strictcachekey.py
+++ b/buildstream/_cachekey/strictcachekey.py
@@ -48,11 +48,6 @@ class StrictCacheKey(CacheKey):
 
         self._update_strong_cached()
 
-        # TODO: Figure out why _weak_cached is only set if it's identical
-        # NOTE: Elements with no dependencies have identical strict and weak 
keys.
-        if self._strict_key == self._weak_key:
-            self._update_weak_cached()
-
         self._element._check_ready_for_runtime()
 
     def get_key(self, strength):
@@ -75,17 +70,6 @@ class StrictCacheKey(CacheKey):
                 not self._element._pull_pending()):
             self._element._schedule_assemble()
 
-    def is_cached(self, strength):
-        if strength == _KeyStrength.STRONG:
-            return self._strong_cached
-        elif strength == _KeyStrength.STRICT:
-            # TODO: Understand difference between strict cached and strong 
cached
-            raise AssertionError("I have no idea why it's strong_cached and 
not strict_cached")
-        elif strength == _KeyStrength.WEAK:
-            return self._weak_cached
-        else:
-            raise AssertionError("Bad key strength value {}".format(strength))
-
     def tracking_done(self):
         # this generator includes this corresponding element
         for element in self._element._reverse_deps_for_update():
@@ -96,8 +80,6 @@ class StrictCacheKey(CacheKey):
         # Cache keys are already known before this.
         # Element may become cached.
         self._update_strong_cached()
-        if self._weak_key == self._strict_key:
-            self._update_weak_cached()
 
         # If it failed to pull, it should assemble.
         self._element._maybe_schedule_assemble()
@@ -106,5 +88,3 @@ class StrictCacheKey(CacheKey):
         # Cache keys are already known before this.
         # Element may become cached.
         self._update_strong_cached()
-        if self._weak_key == self._strict_key:
-            self._update_weak_cached()

Reply via email to