summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-09-02 01:26:19 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-09-02 01:26:19 -0700
commit9268b7aa7c6dee44433c1cbf6780fe9f84158011 (patch)
tree1d6701753e69e893911f39161387cbe037400036 /lib
parent69d45b49e9b9a589b1e8ae782a3c726eb2cad343 (diff)
downloadspack-9268b7aa7c6dee44433c1cbf6780fe9f84158011.tar.gz
spack-9268b7aa7c6dee44433c1cbf6780fe9f84158011.tar.bz2
spack-9268b7aa7c6dee44433c1cbf6780fe9f84158011.tar.xz
spack-9268b7aa7c6dee44433c1cbf6780fe9f84158011.zip
Fix hash copying in _dup.
- Spec._dup() incorrectly copied cached hashes and normal/concrete values even when dependency structure was not preserved. - Now these are only copied when *all* dependencies are copied.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/spec.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 99446d21dd..f742ca4616 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -1911,8 +1911,9 @@ class Spec(object):
self.external = other.external
self.external_module = other.external_module
self.namespace = other.namespace
- self._hash = other._hash
- self._cmp_key_cache = other._cmp_key_cache
+
+ self.external = other.external
+ self.external_module = other.external_module
# If we copy dependencies, preserve DAG structure in the new spec
if deps:
@@ -1940,11 +1941,20 @@ class Spec(object):
new_spec._add_dependency(
new_nodes[depspec.spec.name], depspec.deptypes)
- # Since we preserved structure, we can copy _normal safely.
- self._normal = other._normal
- self._concrete = other._concrete
- self.external = other.external
- self.external_module = other.external_module
+ # These fields are all cached results of expensive operations.
+ # If we preserved the original structure, we can copy them
+ # safely. If not, they need to be recomputed.
+ if deps == True or deps == alldeps:
+ self._hash = other._hash
+ self._cmp_key_cache = other._cmp_key_cache
+ self._normal = other._normal
+ self._concrete = other._concrete
+ else:
+ self._hash = None
+ self._cmp_key_cache = None
+ self._normal = False
+ self._concrete = False
+
return changed
def copy(self, deps=True):