spack diff any specs you want (#32737)

Resolves #31782

With this change, if a spec is concrete after parsing (e.g. spec.yaml
or /hash-based), then it is not disambiguated (a process which requires
(a) that the spec be installed and (b) that it be part of the
currently-active environment).

This commit allows you to:

* Diff specs from an environment regardless of whether they have
  been installed (more useful for projection/matrix-based envs)
* Diff specs read from .yaml files which may or may not be entirely
  different installations of Spack

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
Peter Scheibel 2022-10-11 10:03:31 -06:00 committed by GitHub
parent 8e3c088a7a
commit b594c0aee0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -198,10 +198,12 @@ def diff(parser, args):
if len(args.specs) != 2:
tty.die("You must provide two specs to diff.")
specs = [
spack.cmd.disambiguate_spec(spec, env, first=args.load_first)
for spec in spack.cmd.parse_specs(args.specs)
]
specs = []
for spec in spack.cmd.parse_specs(args.specs):
if spec.concrete:
specs.append(spec)
else:
specs.append(spack.cmd.disambiguate_spec(spec, env, first=args.load_first))
# Calculate the comparison (c)
color = False if args.dump_json else get_color_when()