environment view use new traversal (#34662)

This commit is contained in:
Harmen Stoppels 2023-01-02 19:04:55 +01:00 committed by GitHub
parent 6984ee291a
commit 2e8d165120
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -532,18 +532,18 @@ def specs_for_view(self, concretized_root_specs):
From the list of concretized user specs in the environment, flatten
the dags, and filter selected, installed specs, remove duplicates on dag hash.
"""
specs = []
dag_hash = lambda spec: spec.dag_hash()
for s in concretized_root_specs:
if self.link == "all":
specs.extend(s.traverse(deptype=("link", "run")))
elif self.link == "run":
specs.extend(s.traverse(deptype=("run")))
# With deps, requires traversal
if self.link == "all" or self.link == "run":
deptype = ("run") if self.link == "run" else ("link", "run")
specs = list(
spack.traverse.traverse_nodes(
concretized_root_specs, deptype=deptype, key=dag_hash
)
)
else:
specs.append(s)
# De-dupe by dag hash
specs = dedupe(specs, key=lambda s: s.dag_hash())
specs = list(dedupe(concretized_root_specs, key=dag_hash))
# Filter selected, installed specs
with spack.store.db.read_transaction():