From 968199de7d15fa6150c26f94100c19f4202f139b Mon Sep 17 00:00:00 2001 From: becker33 Date: Fri, 3 Feb 2017 18:27:34 -0800 Subject: Fix spec hash printing (#2941) - Fix format printing to match command line for hashes and full name formats - Update spack graph to use new format - Changed format string signifier for hashes from `$#` to `$/` --- lib/spack/spack/cmd/dependents.py | 2 +- lib/spack/spack/cmd/uninstall.py | 2 +- lib/spack/spack/database.py | 2 +- lib/spack/spack/graph.py | 2 +- lib/spack/spack/spec.py | 16 ++++++++-------- lib/spack/spack/test/graph.py | 12 ++++++------ 6 files changed, 18 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/cmd/dependents.py b/lib/spack/spack/cmd/dependents.py index 8c533561e3..42181b5502 100644 --- a/lib/spack/spack/cmd/dependents.py +++ b/lib/spack/spack/cmd/dependents.py @@ -45,7 +45,7 @@ def dependents(parser, args): tty.die("spack dependents takes only one spec.") spec = spack.cmd.disambiguate_spec(specs[0]) - tty.msg("Dependents of %s" % spec.format('$_$@$%@$#', color=True)) + tty.msg("Dependents of %s" % spec.format('$_$@$%@$/', color=True)) deps = spack.store.db.installed_dependents(spec) if deps: spack.cmd.display_specs(deps) diff --git a/lib/spack/spack/cmd/uninstall.py b/lib/spack/spack/cmd/uninstall.py index f8b5408ba1..fb9094f1b4 100644 --- a/lib/spack/spack/cmd/uninstall.py +++ b/lib/spack/spack/cmd/uninstall.py @@ -177,7 +177,7 @@ def get_uninstall_list(args): if dependent_list and not args.dependents and not args.force: for spec, lst in dependent_list.items(): tty.error("Will not uninstall %s" % - spec.format("$_$@$%@$#", color=True)) + spec.format("$_$@$%@$/", color=True)) print('') print("The following packages depend on it:") spack.cmd.display_specs(lst, **display_args) diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py index ff55223351..d3fc03fb40 100644 --- a/lib/spack/spack/database.py +++ b/lib/spack/spack/database.py @@ -239,7 +239,7 @@ class Database(object): if dhash not in data: tty.warn("Missing dependency not in database: ", "%s needs %s-%s" % ( - spec.format('$_$#'), dname, dhash[:7])) + spec.format('$_$/'), dname, dhash[:7])) continue child = data[dhash].spec diff --git a/lib/spack/spack/graph.py b/lib/spack/spack/graph.py index 7cc2046b9d..91230263f1 100644 --- a/lib/spack/spack/graph.py +++ b/lib/spack/spack/graph.py @@ -571,7 +571,7 @@ def graph_dot(specs, deptype=None, static=False, out=None): else: def key_label(s): - return s.dag_hash(), "%s-%s" % (s.name, s.dag_hash(7)) + return s.dag_hash(), "%s/%s" % (s.name, s.dag_hash(7)) for s in spec.traverse(deptype=deptype): skey, slabel = key_label(s) diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 36806b757d..0df0ff71ea 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -1145,13 +1145,13 @@ class Spec(object): def short_spec(self): """Returns a version of the spec with the dependencies hashed instead of completely enumerated.""" - return self.format('$_$@$%@$+$=$#') + return self.format('$_$@$%@$+$=$/') @property def cshort_spec(self): """Returns a version of the spec with the dependencies hashed instead of completely enumerated.""" - return self.format('$_$@$%@$+$=$#', color=True) + return self.format('$_$@$%@$+$=$/', color=True) @property def prefix(self): @@ -2374,7 +2374,7 @@ class Spec(object): prefixes as above $+ Options $= Architecture prefixed by 'arch=' - $# 7-char prefix of DAG hash with '-' prefix + $/ 7-char prefix of DAG hash with '-' prefix $$ $ You can also use full-string versions, which elide the prefixes:: @@ -2408,7 +2408,7 @@ class Spec(object): of the package, but no dependencies, arch, or compiler. TODO: allow, e.g., ``$6#`` to customize short hash length - TODO: allow, e.g., ``$##`` for full hash. + TODO: allow, e.g., ``$//`` for full hash. """ color = kwargs.get('color', False) length = len(format_string) @@ -2455,8 +2455,8 @@ class Spec(object): if self.architecture and str(self.architecture): a_str = ' arch' + c + str(self.architecture) + ' ' write(fmt % (a_str), c) - elif c == '#': - out.write('-' + fmt % (self.dag_hash(7))) + elif c == '/': + out.write('/' + fmt % (self.dag_hash(7))) elif c == '$': if fmt != '%s': raise ValueError("Can't use format width with $$.") @@ -2529,7 +2529,7 @@ class Spec(object): hashlen = int(hashlen) else: hashlen = None - out.write(fmt % (self.dag_hash(hashlen))) + out.write('/' + fmt % (self.dag_hash(hashlen))) named = False @@ -3161,7 +3161,7 @@ class UnsatisfiableDependencySpecError(UnsatisfiableSpecError): class AmbiguousHashError(SpecError): def __init__(self, msg, *specs): - specs_str = '\n ' + '\n '.join(spec.format('$.$@$%@+$+$=$#') + specs_str = '\n ' + '\n '.join(spec.format('$.$@$%@+$+$=$/') for spec in specs) super(AmbiguousHashError, self).__init__(msg + specs_str) diff --git a/lib/spack/spack/test/graph.py b/lib/spack/spack/test/graph.py index 09dbcd0548..ce7b07ed86 100644 --- a/lib/spack/spack/test/graph.py +++ b/lib/spack/spack/test/graph.py @@ -84,16 +84,16 @@ def test_dynamic_dot_graph_mpileaks(builtin_mock): dot = stream.getvalue() - mpileaks_hash, mpileaks_lbl = s.dag_hash(), s.format('$_$#') - mpi_hash, mpi_lbl = s['mpi'].dag_hash(), s['mpi'].format('$_$#') + mpileaks_hash, mpileaks_lbl = s.dag_hash(), s.format('$_$/') + mpi_hash, mpi_lbl = s['mpi'].dag_hash(), s['mpi'].format('$_$/') callpath_hash, callpath_lbl = ( - s['callpath'].dag_hash(), s['callpath'].format('$_$#')) + s['callpath'].dag_hash(), s['callpath'].format('$_$/')) dyninst_hash, dyninst_lbl = ( - s['dyninst'].dag_hash(), s['dyninst'].format('$_$#')) + s['dyninst'].dag_hash(), s['dyninst'].format('$_$/')) libdwarf_hash, libdwarf_lbl = ( - s['libdwarf'].dag_hash(), s['libdwarf'].format('$_$#')) + s['libdwarf'].dag_hash(), s['libdwarf'].format('$_$/')) libelf_hash, libelf_lbl = ( - s['libelf'].dag_hash(), s['libelf'].format('$_$#')) + s['libelf'].dag_hash(), s['libelf'].format('$_$/')) assert ' "%s" [label="%s"]\n' % (mpileaks_hash, mpileaks_lbl) in dot assert ' "%s" [label="%s"]\n' % (callpath_hash, callpath_lbl) in dot -- cgit v1.2.3-60-g2f50