diff options
author | Darius Makovsky <traveltissues@protonmail.com> | 2019-09-17 18:12:07 +0100 |
---|---|---|
committer | Darius Makovsky <traveltissues@protonmail.com> | 2019-09-18 16:38:19 +0100 |
commit | 47e50b97df7a120f696a7f79f152fd33371a761c (patch) | |
tree | 5e9a5b009746f6a9d9489f0de740a38ffa31345e | |
parent | 6f394a8ca95cdd69e4a58971501a37fb364a857d (diff) | |
download | buildstream-47e50b97df7a120f696a7f79f152fd33371a761c.tar.gz |
workspace.py: add the directory digest attribute
-rw-r--r-- | src/buildstream/plugins/sources/workspace.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/buildstream/plugins/sources/workspace.py b/src/buildstream/plugins/sources/workspace.py index c9afb6b52..c120f07de 100644 --- a/src/buildstream/plugins/sources/workspace.py +++ b/src/buildstream/plugins/sources/workspace.py @@ -39,6 +39,7 @@ import os from buildstream.storage.directory import Directory from buildstream import Source, SourceError, Consistency from buildstream import utils +from buildstream.types import SourceRef class WorkspaceSource(Source): @@ -52,6 +53,7 @@ class WorkspaceSource(Source): # Cached unique key to avoid multiple file system traversal if the unique key is requested multiple times. self.__unique_key = None self.__element_sources = [] + self.__source_digest = None def set_element_sources(self, _element_sources): self.__element_sources = _element_sources @@ -59,17 +61,29 @@ class WorkspaceSource(Source): def get_element_sources(self): return self.__element_sources + def track(self) -> SourceRef: + return self.__source_digest + def configure(self, node): node.validate_keys(['path', 'ref', 'kind']) self.path = self.node_get_project_path(node.get_scalar('path')) - self.ref = node.get_str('ref', None) + self.__source_digest = node.get_str('ref') self.fullpath = os.path.join(self.get_project_directory(), self.path) def preflight(self): return + def get_ref(self): + return str(self.__source_digest) + + def load_ref(self, node): + self.__source_digest = node.get_str('ref', None) + + def set_ref(self, ref, node): + node['ref'] = self.__source_digest = ref + def get_unique_key(self): - return self.__unique_key + return (self.fullpath, self.__source_digest) def init_workspace(self, directory): # for each source held by the workspace we must call init_workspace @@ -81,20 +95,10 @@ class WorkspaceSource(Source): source._init_workspace(directory) def get_consistency(self): - if self.ref is None: + if self.__source_digest is None: return Consistency.INCONSISTENT - return Consistency.RESOLVED - def load_ref(self, node): - self.ref = node.get_str('ref', None) - - def get_ref(self): - return self.ref - - def set_ref(self, ref, node): - node['ref'] = self.ref = ref - def fetch(self): pass # pragma: nocover |