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 `$/`
This commit is contained in:
parent
5aefaa6ffe
commit
968199de7d
6 changed files with 18 additions and 18 deletions
|
@ -45,7 +45,7 @@ def dependents(parser, args):
|
||||||
tty.die("spack dependents takes only one spec.")
|
tty.die("spack dependents takes only one spec.")
|
||||||
spec = spack.cmd.disambiguate_spec(specs[0])
|
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)
|
deps = spack.store.db.installed_dependents(spec)
|
||||||
if deps:
|
if deps:
|
||||||
spack.cmd.display_specs(deps)
|
spack.cmd.display_specs(deps)
|
||||||
|
|
|
@ -177,7 +177,7 @@ def get_uninstall_list(args):
|
||||||
if dependent_list and not args.dependents and not args.force:
|
if dependent_list and not args.dependents and not args.force:
|
||||||
for spec, lst in dependent_list.items():
|
for spec, lst in dependent_list.items():
|
||||||
tty.error("Will not uninstall %s" %
|
tty.error("Will not uninstall %s" %
|
||||||
spec.format("$_$@$%@$#", color=True))
|
spec.format("$_$@$%@$/", color=True))
|
||||||
print('')
|
print('')
|
||||||
print("The following packages depend on it:")
|
print("The following packages depend on it:")
|
||||||
spack.cmd.display_specs(lst, **display_args)
|
spack.cmd.display_specs(lst, **display_args)
|
||||||
|
|
|
@ -239,7 +239,7 @@ def _assign_dependencies(self, hash_key, installs, data):
|
||||||
if dhash not in data:
|
if dhash not in data:
|
||||||
tty.warn("Missing dependency not in database: ",
|
tty.warn("Missing dependency not in database: ",
|
||||||
"%s needs %s-%s" % (
|
"%s needs %s-%s" % (
|
||||||
spec.format('$_$#'), dname, dhash[:7]))
|
spec.format('$_$/'), dname, dhash[:7]))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
child = data[dhash].spec
|
child = data[dhash].spec
|
||||||
|
|
|
@ -571,7 +571,7 @@ def label(key, label):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
def key_label(s):
|
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):
|
for s in spec.traverse(deptype=deptype):
|
||||||
skey, slabel = key_label(s)
|
skey, slabel = key_label(s)
|
||||||
|
|
|
@ -1145,13 +1145,13 @@ def return_val(dspec):
|
||||||
def short_spec(self):
|
def short_spec(self):
|
||||||
"""Returns a version of the spec with the dependencies hashed
|
"""Returns a version of the spec with the dependencies hashed
|
||||||
instead of completely enumerated."""
|
instead of completely enumerated."""
|
||||||
return self.format('$_$@$%@$+$=$#')
|
return self.format('$_$@$%@$+$=$/')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cshort_spec(self):
|
def cshort_spec(self):
|
||||||
"""Returns a version of the spec with the dependencies hashed
|
"""Returns a version of the spec with the dependencies hashed
|
||||||
instead of completely enumerated."""
|
instead of completely enumerated."""
|
||||||
return self.format('$_$@$%@$+$=$#', color=True)
|
return self.format('$_$@$%@$+$=$/', color=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def prefix(self):
|
def prefix(self):
|
||||||
|
@ -2374,7 +2374,7 @@ def format(self, format_string='$_$@$%@+$+$=', **kwargs):
|
||||||
prefixes as above
|
prefixes as above
|
||||||
$+ Options
|
$+ Options
|
||||||
$= Architecture prefixed by 'arch='
|
$= 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::
|
You can also use full-string versions, which elide the prefixes::
|
||||||
|
@ -2408,7 +2408,7 @@ def format(self, format_string='$_$@$%@+$+$=', **kwargs):
|
||||||
of the package, but no dependencies, arch, or compiler.
|
of the package, but no dependencies, arch, or compiler.
|
||||||
|
|
||||||
TODO: allow, e.g., ``$6#`` to customize short hash length
|
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)
|
color = kwargs.get('color', False)
|
||||||
length = len(format_string)
|
length = len(format_string)
|
||||||
|
@ -2455,8 +2455,8 @@ def write(s, c):
|
||||||
if self.architecture and str(self.architecture):
|
if self.architecture and str(self.architecture):
|
||||||
a_str = ' arch' + c + str(self.architecture) + ' '
|
a_str = ' arch' + c + str(self.architecture) + ' '
|
||||||
write(fmt % (a_str), c)
|
write(fmt % (a_str), c)
|
||||||
elif c == '#':
|
elif c == '/':
|
||||||
out.write('-' + fmt % (self.dag_hash(7)))
|
out.write('/' + fmt % (self.dag_hash(7)))
|
||||||
elif c == '$':
|
elif c == '$':
|
||||||
if fmt != '%s':
|
if fmt != '%s':
|
||||||
raise ValueError("Can't use format width with $$.")
|
raise ValueError("Can't use format width with $$.")
|
||||||
|
@ -2529,7 +2529,7 @@ def write(s, c):
|
||||||
hashlen = int(hashlen)
|
hashlen = int(hashlen)
|
||||||
else:
|
else:
|
||||||
hashlen = None
|
hashlen = None
|
||||||
out.write(fmt % (self.dag_hash(hashlen)))
|
out.write('/' + fmt % (self.dag_hash(hashlen)))
|
||||||
|
|
||||||
named = False
|
named = False
|
||||||
|
|
||||||
|
@ -3161,7 +3161,7 @@ def __init__(self, provided, required):
|
||||||
|
|
||||||
class AmbiguousHashError(SpecError):
|
class AmbiguousHashError(SpecError):
|
||||||
def __init__(self, msg, *specs):
|
def __init__(self, msg, *specs):
|
||||||
specs_str = '\n ' + '\n '.join(spec.format('$.$@$%@+$+$=$#')
|
specs_str = '\n ' + '\n '.join(spec.format('$.$@$%@+$+$=$/')
|
||||||
for spec in specs)
|
for spec in specs)
|
||||||
super(AmbiguousHashError, self).__init__(msg + specs_str)
|
super(AmbiguousHashError, self).__init__(msg + specs_str)
|
||||||
|
|
||||||
|
|
|
@ -84,16 +84,16 @@ def test_dynamic_dot_graph_mpileaks(builtin_mock):
|
||||||
|
|
||||||
dot = stream.getvalue()
|
dot = stream.getvalue()
|
||||||
|
|
||||||
mpileaks_hash, mpileaks_lbl = s.dag_hash(), s.format('$_$#')
|
mpileaks_hash, mpileaks_lbl = s.dag_hash(), s.format('$_$/')
|
||||||
mpi_hash, mpi_lbl = s['mpi'].dag_hash(), s['mpi'].format('$_$#')
|
mpi_hash, mpi_lbl = s['mpi'].dag_hash(), s['mpi'].format('$_$/')
|
||||||
callpath_hash, callpath_lbl = (
|
callpath_hash, callpath_lbl = (
|
||||||
s['callpath'].dag_hash(), s['callpath'].format('$_$#'))
|
s['callpath'].dag_hash(), s['callpath'].format('$_$/'))
|
||||||
dyninst_hash, dyninst_lbl = (
|
dyninst_hash, dyninst_lbl = (
|
||||||
s['dyninst'].dag_hash(), s['dyninst'].format('$_$#'))
|
s['dyninst'].dag_hash(), s['dyninst'].format('$_$/'))
|
||||||
libdwarf_hash, libdwarf_lbl = (
|
libdwarf_hash, libdwarf_lbl = (
|
||||||
s['libdwarf'].dag_hash(), s['libdwarf'].format('$_$#'))
|
s['libdwarf'].dag_hash(), s['libdwarf'].format('$_$/'))
|
||||||
libelf_hash, libelf_lbl = (
|
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' % (mpileaks_hash, mpileaks_lbl) in dot
|
||||||
assert ' "%s" [label="%s"]\n' % (callpath_hash, callpath_lbl) in dot
|
assert ' "%s" [label="%s"]\n' % (callpath_hash, callpath_lbl) in dot
|
||||||
|
|
Loading…
Reference in a new issue