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

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

commit b0c1d591f57661a782568fd755097f239b274b55
Author: Raoul Hidalgo Charman <[email protected]>
AuthorDate: Fri Apr 12 12:08:35 2019 +0100

    Remove excluded_subdir/subdir options
    
    With artifact as a proto, it doesn't make sense to do it this way, bits
    of code can be removed.
    
    Part of #974
---
 buildstream/_artifactcache.py |  8 ++-----
 buildstream/_cas/cascache.py  | 10 +++-----
 buildstream/element.py        | 53 +++++++++----------------------------------
 3 files changed, 16 insertions(+), 55 deletions(-)

diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py
index e54449d..a42e2dd 100644
--- a/buildstream/_artifactcache.py
+++ b/buildstream/_artifactcache.py
@@ -247,7 +247,6 @@ class ArtifactCache(BaseCache):
     #     element (Element): The element whose artifacts to compare
     #     key_a (str): The first artifact key
     #     key_b (str): The second artifact key
-    #     subdir (str): A subdirectory to limit the comparison to
     #
     def diff(self, element, key_a, key_b, *, subdir=None):
         context = self.context
@@ -314,17 +313,14 @@ class ArtifactCache(BaseCache):
     #     element (Element): The Element whose artifact is to be fetched
     #     key (str): The cache key to use
     #     progress (callable): The progress callback, if any
-    #     subdir (str): The optional specific subdir to pull
-    #     excluded_subdirs (list): The optional list of subdirs to not pull
+    #     pull_buildtrees (bool): Whether to pull buildtrees or not
     #
     # Returns:
     #   (bool): True if pull was successful, False if artifact was not 
available
     #
-    def pull(self, element, key, *, progress=None, subdir=None, 
excluded_subdirs=None):
+    def pull(self, element, key, *, progress=None, pull_buildtrees=False):
         display_key = key[:self.context.log_key_length]
-
         project = element._get_project()
-        pull_buildtrees = "buildtree" not in excluded_subdirs if 
excluded_subdirs else True
 
         for remote in self._remotes[project]:
             remote.init()
diff --git a/buildstream/_cas/cascache.py b/buildstream/_cas/cascache.py
index c45f56f..0bdb206 100644
--- a/buildstream/_cas/cascache.py
+++ b/buildstream/_cas/cascache.py
@@ -232,14 +232,10 @@ class CASCache():
     #     ref_b (str): The second ref
     #     subdir (str): A subdirectory to limit the comparison to
     #
-    def diff(self, ref_a, ref_b, *, subdir=None):
+    def diff(self, ref_a, ref_b):
         tree_a = self.resolve_ref(ref_a)
         tree_b = self.resolve_ref(ref_b)
 
-        if subdir:
-            tree_a = self._get_subdir(tree_a, subdir)
-            tree_b = self._get_subdir(tree_b, subdir)
-
         added = []
         removed = []
         modified = []
@@ -262,7 +258,7 @@ class CASCache():
     # Returns:
     #   (bool): True if pull was successful, False if ref was not available
     #
-    def pull(self, ref, remote, *, progress=None, subdir=None, 
excluded_subdirs=None):
+    def pull(self, ref, remote, *, progress=None):
         try:
             remote.init()
 
@@ -276,7 +272,7 @@ class CASCache():
             self._fetch_directory(remote, tree)
 
             # Fetch files, excluded_subdirs determined in pullqueue
-            required_blobs = self.required_blobs_for_directory(tree, 
excluded_subdirs=excluded_subdirs)
+            required_blobs = self.required_blobs_for_directory(tree)
             missing_blobs = self.local_missing_blobs(required_blobs)
             if missing_blobs:
                 self.fetch_blobs(remote, missing_blobs)
diff --git a/buildstream/element.py b/buildstream/element.py
index b465693..913f36b 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1873,9 +1873,9 @@ class Element(Plugin):
 
         # Check whether the pull has been invoked with a specific subdir 
requested
         # in user context, as to complete a partial artifact
-        subdir, _ = self.__pull_directories()
+        pull_buildtrees = self._get_context().pull_buildtrees
 
-        if self.__strong_cached and subdir == 'buildtree':
+        if self.__strong_cached and pull_buildtrees:
             # If we've specified a subdir, check if the subdir is cached 
locally
             if self.__artifact.cached_buildtree():
                 return False
@@ -1915,13 +1915,13 @@ class Element(Plugin):
 
         # Get optional specific subdir to pull and optional list to not pull
         # based off of user context
-        subdir, excluded_subdirs = self.__pull_directories()
+        pull_buildtrees = context.pull_buildtrees
 
         # Attempt to pull artifact without knowing whether it's available
-        pulled = self.__pull_strong(progress=progress, subdir=subdir, 
excluded_subdirs=excluded_subdirs)
+        pulled = self.__pull_strong(progress=progress, 
pull_buildtrees=pull_buildtrees)
 
         if not pulled and not self._cached() and not context.get_strict():
-            pulled = self.__pull_weak(progress=progress, subdir=subdir, 
excluded_subdirs=excluded_subdirs)
+            pulled = self.__pull_weak(progress=progress, 
pull_buildtrees=pull_buildtrees)
 
         if not pulled:
             return False
@@ -2860,11 +2860,11 @@ class Element(Plugin):
     # Returns:
     #     (bool): Whether or not the pull was successful
     #
-    def __pull_strong(self, *, progress=None, subdir=None, 
excluded_subdirs=None):
+    def __pull_strong(self, *, progress=None, pull_buildtrees):
         weak_key = self._get_cache_key(strength=_KeyStrength.WEAK)
         key = self.__strict_cache_key
-        if not self.__artifacts.pull(self, key, progress=progress, 
subdir=subdir,
-                                     excluded_subdirs=excluded_subdirs):
+        if not self.__artifacts.pull(self, key, progress=progress,
+                                     pull_buildtrees=pull_buildtrees):
             return False
 
         # update weak ref by pointing it to this newly fetched artifact
@@ -2885,10 +2885,10 @@ class Element(Plugin):
     # Returns:
     #     (bool): Whether or not the pull was successful
     #
-    def __pull_weak(self, *, progress=None, subdir=None, 
excluded_subdirs=None):
+    def __pull_weak(self, *, progress=None, pull_buildtrees):
         weak_key = self._get_cache_key(strength=_KeyStrength.WEAK)
-        if not self.__artifacts.pull(self, weak_key, progress=progress, 
subdir=subdir,
-                                     excluded_subdirs=excluded_subdirs):
+        if not self.__artifacts.pull(self, weak_key, progress=progress,
+                                     pull_buildtrees=pull_buildtrees):
             return False
 
         # extract strong cache key from this newly fetched artifact
@@ -2900,37 +2900,6 @@ class Element(Plugin):
 
         return True
 
-    # __pull_directories():
-    #
-    # Which directories to include or exclude given the current
-    # context
-    #
-    # Returns:
-    #     subdir (str): The optional specific subdir to include, based
-    #                   on user context
-    #     excluded_subdirs (list): The optional list of subdirs to not
-    #                              pull, referenced against subdir value
-    #
-    def __pull_directories(self):
-        context = self._get_context()
-
-        # Current default exclusions on pull
-        excluded_subdirs = ["buildtree"]
-        subdir = ''
-
-        # If buildtrees are to be pulled, remove the value from exclusion list
-        # and set specific subdir
-        if context.pull_buildtrees:
-            subdir = "buildtree"
-            excluded_subdirs.remove(subdir)
-
-        # If file contents are not required for this element, don't pull them.
-        # The directories themselves will always be pulled.
-        if not context.require_artifact_files and not 
self._artifact_files_required():
-            excluded_subdirs.append("files")
-
-        return (subdir, excluded_subdirs)
-
     # __cache_sources():
     #
     # Caches the sources into the local CAS

Reply via email to