diff options
author | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-11-01 13:29:08 +0000 |
---|---|---|
committer | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-11-09 14:58:22 +0000 |
commit | b93100ec47abcf10b355c0d1d4fd9a502e343c52 (patch) | |
tree | 8062041ca440da0a31d6b39a70a37924ec4464e3 /buildstream | |
parent | 35ec6b6a86c68ea7c60c58ed0b981189e6ced59b (diff) | |
download | buildstream-b93100ec47abcf10b355c0d1d4fd9a502e343c52.tar.gz |
_casbaseddirectory: Fix order of list_modified_paths
This will now return paths in the same order as list_relative_paths.
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/storage/_casbaseddirectory.py | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/buildstream/storage/_casbaseddirectory.py b/buildstream/storage/_casbaseddirectory.py index e24995da7..700257139 100644 --- a/buildstream/storage/_casbaseddirectory.py +++ b/buildstream/storage/_casbaseddirectory.py @@ -762,6 +762,28 @@ class CasBasedDirectory(Directory): else: self._mark_directory_unmodified() + def _lightweight_resolve_to_index(self, path): + """A lightweight function for transforming paths into IndexEntry + objects. This does not follow symlinks. + + path: The string to resolve. This should be a series of path + components separated by the protocol buffer path separator + _pb2_path_sep. + + Returns: the IndexEntry found, or None if any of the path components were not present. + + """ + directory = self + path_components = path.split(CasBasedDirectory._pb2_path_sep) + for component in path_components[:-1]: + if component not in directory.index: + return None + if isinstance(directory.index[component].buildstream_object, CasBasedDirectory): + directory = directory.index[component].buildstream_object + else: + return None + return directory.index.get(path_components[-1], None) + def list_modified_paths(self): """Provide a list of relative paths which have been modified since the last call to mark_unmodified. @@ -769,19 +791,14 @@ class CasBasedDirectory(Directory): Return value: List(str) - list of modified paths """ - filelist = [] - for (k, v) in self.index.items(): - if isinstance(v.buildstream_object, CasBasedDirectory): - filelist.extend([k + os.path.sep + x for x in v.buildstream_object.list_modified_paths()]) - elif isinstance(v.pb_object, remote_execution_pb2.FileNode) and v.modified: - filelist.append(k) - return filelist + for p in self.list_relative_paths(): + i = self._lightweight_resolve_to_index(p) + if i and i.modified: + yield p def list_relative_paths(self, relpath=""): """Provide a list of all relative paths. - NOTE: This list is not in the same order as utils.list_relative_paths. - Return value: List(str) - list of all paths """ |