summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-07-10 16:54:06 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2019-07-15 07:40:32 +0000
commit54e4f26a23055ebfea3133bbb1b4e3982df27e19 (patch)
treebbd139de7e882e856e6d3e90310c2b59920683f0
parent9f446dd1e26f13e34d566ed543775a595c3fa275 (diff)
downloadbuildstream-54e4f26a23055ebfea3133bbb1b4e3982df27e19.tar.gz
node: Rename 'copy' to 'clone'
A 'clone' operation has an implicit understanding that it is expensive, which is not the case of a 'copy' operation, which is more usually a shallow copy. Therefore renaming to 'clone'
-rw-r--r--src/buildstream/_includes.py2
-rw-r--r--src/buildstream/_project.py12
-rw-r--r--src/buildstream/_yaml.pyx2
-rw-r--r--src/buildstream/element.py26
-rw-r--r--src/buildstream/node.pxd2
-rw-r--r--src/buildstream/node.pyx12
-rw-r--r--src/buildstream/source.py2
-rw-r--r--tests/internals/yaml.py2
8 files changed, 30 insertions, 30 deletions
diff --git a/src/buildstream/_includes.py b/src/buildstream/_includes.py
index c3bef1ce6..75d748723 100644
--- a/src/buildstream/_includes.py
+++ b/src/buildstream/_includes.py
@@ -73,7 +73,7 @@ class Includes:
# Because the included node will be modified, we need
# to copy it so that we do not modify the toplevel
# node of the provenance.
- include_node = include_node.copy()
+ include_node = include_node.clone()
try:
included.add(file_path)
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index eb2a078f2..97a2c4f77 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -575,7 +575,7 @@ class Project():
else:
raise
- pre_config_node = self._default_config_node.copy()
+ pre_config_node = self._default_config_node.clone()
self._project_conf._composite(pre_config_node)
# Assert project's format version early, before validating toplevel keys
@@ -619,9 +619,9 @@ class Project():
self._project_includes = Includes(self.loader, copy_tree=False)
- project_conf_first_pass = self._project_conf.copy()
+ project_conf_first_pass = self._project_conf.clone()
self._project_includes.process(project_conf_first_pass, only_local=True)
- config_no_include = self._default_config_node.copy()
+ config_no_include = self._default_config_node.clone()
project_conf_first_pass._composite(config_no_include)
self._load_pass(config_no_include, self.first_pass_config,
@@ -644,9 +644,9 @@ class Project():
# Process the second pass of loading the project configuration.
#
def _load_second_pass(self):
- project_conf_second_pass = self._project_conf.copy()
+ project_conf_second_pass = self._project_conf.clone()
self._project_includes.process(project_conf_second_pass)
- config = self._default_config_node.copy()
+ config = self._default_config_node.clone()
project_conf_second_pass._composite(config)
self._load_pass(config, self.config)
@@ -945,7 +945,7 @@ class Project():
"Unexpected plugin group: {}, expecting {}"
.format(plugin_group, expected_groups))
if plugin_group in origin.keys():
- origin_node = origin.copy()
+ origin_node = origin.clone()
plugins = origin.get_mapping(plugin_group, default={})
origin_node['plugins'] = plugins.keys()
diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx
index 66f71d97a..a9ed2309b 100644
--- a/src/buildstream/_yaml.pyx
+++ b/src/buildstream/_yaml.pyx
@@ -325,7 +325,7 @@ cpdef MappingNode load_data(str data, int file_index=node._SYNTHETIC_FILE_INDEX,
node._set_root_node_for_file(file_index, contents)
if copy_tree:
- contents = contents.copy()
+ contents = contents.clone()
return contents
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 4c6160c0f..8b4a52e85 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -852,7 +852,7 @@ class Element(Plugin):
data = self.__dynamic_public.get_mapping(domain, default=None)
if data is not None:
- data = data.copy()
+ data = data.clone()
return data
@@ -872,7 +872,7 @@ class Element(Plugin):
self.__load_public_data()
if data is not None:
- data = data.copy()
+ data = data.clone()
self.__dynamic_public[domain] = data
@@ -1632,7 +1632,7 @@ class Element(Plugin):
# By default, the dynamic public data is the same as the static public data.
# The plugin's assemble() method may modify this, though.
- self.__dynamic_public = self.__public.copy()
+ self.__dynamic_public = self.__public.clone()
# Call the abstract plugin methods
@@ -2494,11 +2494,11 @@ class Element(Plugin):
element_splits = element_bst.get_mapping("split-rules", default={})
if is_junction:
- splits = element_splits.copy()
+ splits = element_splits.clone()
else:
assert project._splits is not None
- splits = project._splits.copy()
+ splits = project._splits.clone()
# Extend project wide split rules with any split rules defined by the element
element_splits._composite(splits)
@@ -2548,7 +2548,7 @@ class Element(Plugin):
if meta.is_junction:
environment = Node.from_dict({})
else:
- environment = project.base_environment.copy()
+ environment = project.base_environment.clone()
default_env._composite(environment)
meta.environment._composite(environment)
@@ -2592,9 +2592,9 @@ class Element(Plugin):
default_vars = cls.__defaults.get_mapping('variables', default={})
if meta.is_junction:
- variables = project.first_pass_config.base_variables.copy()
+ variables = project.first_pass_config.base_variables.clone()
else:
- variables = project.base_variables.copy()
+ variables = project.base_variables.clone()
default_vars._composite(variables)
meta.variables._composite(variables)
@@ -2622,7 +2622,7 @@ class Element(Plugin):
# The default config is already composited with the project overrides
config = cls.__defaults.get_mapping('config', default={})
- config = config.copy()
+ config = config.clone()
meta.config._composite(config)
config._assert_fully_composited()
@@ -2639,7 +2639,7 @@ class Element(Plugin):
'build-gid': 0
})
else:
- sandbox_config = project._sandbox.copy()
+ sandbox_config = project._sandbox.clone()
# Get the platform to ask for host architecture
platform = Platform.get_platform()
@@ -2648,7 +2648,7 @@ class Element(Plugin):
# The default config is already composited with the project overrides
sandbox_defaults = cls.__defaults.get_mapping('sandbox', default={})
- sandbox_defaults = sandbox_defaults.copy()
+ sandbox_defaults = sandbox_defaults.clone()
sandbox_defaults._composite(sandbox_config)
meta.sandbox._composite(sandbox_config)
@@ -2675,12 +2675,12 @@ class Element(Plugin):
@classmethod
def __extract_public(cls, meta):
base_public = cls.__defaults.get_mapping('public', default={})
- base_public = base_public.copy()
+ base_public = base_public.clone()
base_bst = base_public.get_mapping('bst', default={})
base_splits = base_bst.get_mapping('split-rules', default={})
- element_public = meta.public.copy()
+ element_public = meta.public.clone()
element_bst = element_public.get_mapping('bst', default={})
element_splits = element_bst.get_mapping('split-rules', default={})
diff --git a/src/buildstream/node.pxd b/src/buildstream/node.pxd
index 19f0a223e..39538da0a 100644
--- a/src/buildstream/node.pxd
+++ b/src/buildstream/node.pxd
@@ -27,7 +27,7 @@ cdef class Node:
cdef int column
# Public Methods
- cpdef Node copy(self)
+ cpdef Node clone(self)
cpdef ProvenanceInformation get_provenance(self)
# Private Methods used in BuildStream
diff --git a/src/buildstream/node.pyx b/src/buildstream/node.pyx
index ca2782166..5c4db051b 100644
--- a/src/buildstream/node.pyx
+++ b/src/buildstream/node.pyx
@@ -62,7 +62,7 @@ cdef class Node:
# Abstract Public Methods #
#############################################################
- cpdef Node copy(self):
+ cpdef Node clone(self):
raise NotImplementedError()
#############################################################
@@ -202,7 +202,7 @@ cdef class ScalarNode(Node):
# Public Methods implementations #
#############################################################
- cpdef ScalarNode copy(self):
+ cpdef ScalarNode clone(self):
return self
#############################################################
@@ -391,13 +391,13 @@ cdef class MappingNode(Node):
# Public Methods implementations #
#############################################################
- cpdef MappingNode copy(self):
+ cpdef MappingNode clone(self):
cdef dict copy = {}
cdef str key
cdef Node value
for key, value in self.value.items():
- copy[key] = value.copy()
+ copy[key] = value.clone()
return MappingNode.__new__(MappingNode, self.file_index, self.line, self.column, copy)
@@ -726,12 +726,12 @@ cdef class SequenceNode(Node):
# Public Methods implementations #
#############################################################
- cpdef SequenceNode copy(self):
+ cpdef SequenceNode clone(self):
cdef list copy = []
cdef Node entry
for entry in self.value:
- copy.append(entry.copy())
+ copy.append(entry.clone())
return SequenceNode.__new__(SequenceNode, self.file_index, self.line, self.column, copy)
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index 2cfc23c58..43957378d 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -1282,7 +1282,7 @@ class Source(Plugin):
@classmethod
def __extract_config(cls, meta):
config = cls.__defaults.get_mapping('config', default={})
- config = config.copy()
+ config = config.clone()
meta.config._composite(config)
config._assert_fully_composited()
diff --git a/tests/internals/yaml.py b/tests/internals/yaml.py
index bf7ccf98d..d94d006e3 100644
--- a/tests/internals/yaml.py
+++ b/tests/internals/yaml.py
@@ -182,7 +182,7 @@ def test_composite_preserve_originals(datafiles):
base = _yaml.load(filename)
overlay = _yaml.load(overlayfile)
- base_copy = base.copy()
+ base_copy = base.clone()
overlay._composite(base_copy)
copy_extra = base_copy.get_mapping('extra')