From 1bb7bfaf7f8a2b8725d226f1ea2931c82178a7e9 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Thu, 5 May 2016 17:38:51 -0700 Subject: [PATCH] Versioning the database -- automatic reindex --- lib/spack/spack/database.py | 6 +++++- lib/spack/spack/spec.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py index 5941e1570f..25f4f69a89 100644 --- a/lib/spack/spack/database.py +++ b/lib/spack/spack/database.py @@ -248,15 +248,18 @@ def check(cond, msg): check('installs' in db, "No 'installs' in YAML DB.") check('version' in db, "No 'version' in YAML DB.") + + installs = db['installs'] + # TODO: better version checking semantics. version = Version(db['version']) if version > _db_version: raise InvalidDatabaseVersionError(_db_version, version) elif version < _db_version: self.reindex(spack.install_layout) + installs = dict((k, v.to_dict()) for k, v in self._data.items()) # Iterate through database and check each record. - installs = db['installs'] data = {} for hash_key, rec in installs.items(): try: @@ -293,6 +296,7 @@ def reindex(self, directory_layout): """ with self.write_transaction(): + print "reindex" old_data = self._data try: self._data = {} diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 1d79ae6430..7faefabf00 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -817,8 +817,8 @@ def from_node_dict(node): elif 'variants' in node: for name, value in node['variants'].items(): spec.variants[name] = VariantSpec(name, value) - for name in FlagMap.valid_compiler_flags(): - spec.compiler_flags[name] = [] +# for name in FlagMap.valid_compiler_flags(): +# spec.compiler_flags[name] = [] else: raise SpackRecordError("Did not find a valid format for variants in YAML file")