Qinusty pushed to branch master at BuildStream / buildstream
Commits:
-
18acd3ea
by Valentin David at 2018-08-21T08:44:34Z
-
6bd688cf
by Valentin David at 2018-08-21T08:44:34Z
-
4cab18e3
by Qinusty at 2018-08-21T09:38:39Z
4 changed files:
- buildstream/_includes.py
- buildstream/_loader/loader.py
- buildstream/_project.py
- buildstream/source.py
Changes:
... | ... | @@ -10,11 +10,15 @@ from ._exceptions import LoadError, LoadErrorReason |
10 | 10 |
#
|
11 | 11 |
# Args:
|
12 | 12 |
# loader (Loader): The Loader object
|
13 |
+# copy_tree (bool): Whether to make a copy, of tree in
|
|
14 |
+# provenance. Should be true if intended to be
|
|
15 |
+# serialized.
|
|
13 | 16 |
class Includes:
|
14 | 17 |
|
15 |
- def __init__(self, loader):
|
|
18 |
+ def __init__(self, loader, *, copy_tree=False):
|
|
16 | 19 |
self._loader = loader
|
17 | 20 |
self._loaded = {}
|
21 |
+ self._copy_tree = copy_tree
|
|
18 | 22 |
|
19 | 23 |
# process()
|
20 | 24 |
#
|
... | ... | @@ -96,10 +100,11 @@ class Includes: |
96 | 100 |
directory = project.directory
|
97 | 101 |
file_path = os.path.join(directory, include)
|
98 | 102 |
key = (current_loader, file_path)
|
99 |
- if file_path not in self._loaded:
|
|
103 |
+ if key not in self._loaded:
|
|
100 | 104 |
self._loaded[key] = _yaml.load(os.path.join(directory, include),
|
101 | 105 |
shortname=shortname,
|
102 |
- project=project)
|
|
106 |
+ project=project,
|
|
107 |
+ copy_tree=self._copy_tree)
|
|
103 | 108 |
return self._loaded[key], file_path, current_loader
|
104 | 109 |
|
105 | 110 |
# _process_value()
|
... | ... | @@ -78,7 +78,7 @@ class Loader(): |
78 | 78 |
self._elements = {} # Dict of elements
|
79 | 79 |
self._loaders = {} # Dict of junction loaders
|
80 | 80 |
|
81 |
- self._includes = Includes(self)
|
|
81 |
+ self._includes = Includes(self, copy_tree=True)
|
|
82 | 82 |
|
83 | 83 |
# load():
|
84 | 84 |
#
|
... | ... | @@ -419,7 +419,7 @@ class Project(): |
419 | 419 |
parent=parent_loader,
|
420 | 420 |
tempdir=tempdir)
|
421 | 421 |
|
422 |
- self._project_includes = Includes(self.loader)
|
|
422 |
+ self._project_includes = Includes(self.loader, copy_tree=False)
|
|
423 | 423 |
|
424 | 424 |
project_conf_first_pass = _yaml.node_copy(self._project_conf)
|
425 | 425 |
self._project_includes.process(project_conf_first_pass, only_local=True)
|
... | ... | @@ -794,7 +794,7 @@ class Source(Plugin): |
794 | 794 |
# Save the ref in the originating file
|
795 | 795 |
#
|
796 | 796 |
try:
|
797 |
- _yaml.dump(_yaml.node_sanitize(provenance.toplevel), provenance.filename.name)
|
|
797 |
+ _yaml.dump(provenance.toplevel, provenance.filename.name)
|
|
798 | 798 |
except OSError as e:
|
799 | 799 |
raise SourceError("{}: Error saving source reference to '{}': {}"
|
800 | 800 |
.format(self, provenance.filename.name, e),
|