From 83f4403d2b0c1ad3ac3c3740738d6f113b535690 Mon Sep 17 00:00:00 2001 From: Valentin David Date: Wed, 8 Aug 2018 16:49:19 +0200 Subject: Fix broken indentation after tracking. Issue was introduced by 171e803f (include directive) and the fix was found courtesy of @Qinusty. This fixes also the include feature. Because elements are to be serialized, the included fragments need to use copy_tree when loaded. Related to #470. --- buildstream/_includes.py | 9 +++++++-- buildstream/_loader/loader.py | 2 +- buildstream/_project.py | 2 +- buildstream/source.py | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/buildstream/_includes.py b/buildstream/_includes.py index e4afeaf82..acecd5e47 100644 --- a/buildstream/_includes.py +++ b/buildstream/_includes.py @@ -10,11 +10,15 @@ from ._exceptions import LoadError, LoadErrorReason # # Args: # loader (Loader): The Loader object +# copy_tree (bool): Whether to make a copy, of tree in +# provenance. Should be true if intended to be +# serialized. class Includes: - def __init__(self, loader): + def __init__(self, loader, *, copy_tree=False): self._loader = loader self._loaded = {} + self._copy_tree = copy_tree # process() # @@ -99,7 +103,8 @@ class Includes: if file_path not in self._loaded: self._loaded[key] = _yaml.load(os.path.join(directory, include), shortname=shortname, - project=project) + project=project, + copy_tree=self._copy_tree) return self._loaded[key], file_path, current_loader # _process_value() diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py index 6e46197ab..c6bc87726 100644 --- a/buildstream/_loader/loader.py +++ b/buildstream/_loader/loader.py @@ -78,7 +78,7 @@ class Loader(): self._elements = {} # Dict of elements self._loaders = {} # Dict of junction loaders - self._includes = Includes(self) + self._includes = Includes(self, copy_tree=True) # load(): # diff --git a/buildstream/_project.py b/buildstream/_project.py index 951662e2b..873f3387e 100644 --- a/buildstream/_project.py +++ b/buildstream/_project.py @@ -416,7 +416,7 @@ class Project(): parent=parent_loader, tempdir=tempdir) - self._project_includes = Includes(self.loader) + self._project_includes = Includes(self.loader, copy_tree=False) project_conf_first_pass = _yaml.node_copy(self._project_conf) self._project_includes.process(project_conf_first_pass, only_local=True) diff --git a/buildstream/source.py b/buildstream/source.py index f2694fd38..18a9c2e61 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -752,7 +752,7 @@ class Source(Plugin): # Save the ref in the originating file # try: - _yaml.dump(_yaml.node_sanitize(provenance.toplevel), provenance.filename.name) + _yaml.dump(provenance.toplevel, provenance.filename.name) except OSError as e: raise SourceError("{}: Error saving source reference to '{}': {}" .format(self, provenance.filename.name, e), -- cgit v1.2.1 From d25b7d77f4db739b04ac4224c9d8aa9db31aebea Mon Sep 17 00:00:00 2001 From: Valentin David Date: Wed, 8 Aug 2018 16:54:48 +0200 Subject: buildstream/_includes.py: Fix caching of included fragments. --- buildstream/_includes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildstream/_includes.py b/buildstream/_includes.py index acecd5e47..e30003630 100644 --- a/buildstream/_includes.py +++ b/buildstream/_includes.py @@ -100,7 +100,7 @@ class Includes: directory = project.directory file_path = os.path.join(directory, include) key = (current_loader, file_path) - if file_path not in self._loaded: + if key not in self._loaded: self._loaded[key] = _yaml.load(os.path.join(directory, include), shortname=shortname, project=project, -- cgit v1.2.1