summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Becker <becker33@llnl.gov>2016-05-06 12:05:27 -0700
committerGregory Becker <becker33@llnl.gov>2016-05-06 12:05:27 -0700
commitaddcde4f358061053b013374bcf7400ef28acd4f (patch)
tree829274f303014d4812d349fd129ac03cb82742ff
parent2f821b9e9b7ff1c2cceae2b55a7049309e6ae9c3 (diff)
downloadspack-addcde4f358061053b013374bcf7400ef28acd4f.tar.gz
spack-addcde4f358061053b013374bcf7400ef28acd4f.tar.bz2
spack-addcde4f358061053b013374bcf7400ef28acd4f.tar.xz
spack-addcde4f358061053b013374bcf7400ef28acd4f.zip
Made spec hashes immutable once concrete
-rw-r--r--lib/spack/spack/spec.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 8ff8281d5e..b71c1d680c 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -486,6 +486,7 @@ class Spec(object):
self.variants = other.variants
self.variants.spec = self
self.namespace = other.namespace
+ self.hash = other.hash
# Specs are by default not assumed to be normal, but in some
# cases we've read them from a file want to assume normal.
@@ -754,12 +755,16 @@ class Spec(object):
"""
Return a hash of the entire spec DAG, including connectivity.
"""
- yaml_text = yaml.dump(
- self.to_node_dict(), default_flow_style=True, width=sys.maxint)
-# print yaml_text
- sha = hashlib.sha1(yaml_text)
- return base64.b32encode(sha.digest()).lower()[:length]
-
+ if self.hash:
+ return self.hash
+ else:
+ yaml_text = yaml.dump(
+ self.to_node_dict(), default_flow_style=True, width=sys.maxint)
+ sha = hashlib.sha1(yaml_text)
+ b32_hash = base64.b32encode(sha.digest()).lower()[:length]
+ if self._concrete:
+ self.hash = b32_hash
+ return b32_hash
def to_node_dict(self):
params = dict( (name, v.value) for name, v in self.variants.items() )
@@ -2128,6 +2133,7 @@ class SpecParser(spack.parse.Parser):
spec.dependents = DependencyMap()
spec.dependencies = DependencyMap()
spec.namespace = spec_namespace
+ spec.hash = None
spec._normal = False
spec._concrete = False