Valentin David pushed to branch bst-1.2 at BuildStream / buildstream
Commits:
-
83f4403d
by Valentin David at 2018-08-20T15:39:06Z
-
d25b7d77
by Valentin David at 2018-08-20T15:39:07Z
-
ce6d5f8c
by Valentin David at 2018-08-20T17:02:58Z
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 |
#
|
| ... | ... | @@ -416,7 +416,7 @@ class Project(): |
| 416 | 416 |
parent=parent_loader,
|
| 417 | 417 |
tempdir=tempdir)
|
| 418 | 418 |
|
| 419 |
- self._project_includes = Includes(self.loader)
|
|
| 419 |
+ self._project_includes = Includes(self.loader, copy_tree=False)
|
|
| 420 | 420 |
|
| 421 | 421 |
project_conf_first_pass = _yaml.node_copy(self._project_conf)
|
| 422 | 422 |
self._project_includes.process(project_conf_first_pass, only_local=True)
|
| ... | ... | @@ -752,7 +752,7 @@ class Source(Plugin): |
| 752 | 752 |
# Save the ref in the originating file
|
| 753 | 753 |
#
|
| 754 | 754 |
try:
|
| 755 |
- _yaml.dump(_yaml.node_sanitize(provenance.toplevel), provenance.filename.name)
|
|
| 755 |
+ _yaml.dump(provenance.toplevel, provenance.filename.name)
|
|
| 756 | 756 |
except OSError as e:
|
| 757 | 757 |
raise SourceError("{}: Error saving source reference to '{}': {}"
|
| 758 | 758 |
.format(self, provenance.filename.name, e),
|
