From d93f9b82acd8559a1512e0abf3b48ae2268b1cf0 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 17 Feb 2022 11:06:32 +0100 Subject: Reduce verbosity of patches=... variant (#29015) * reduce verbosity of patches=... variant * Special-case prefix-matches for satisfies of patches variant --- lib/spack/spack/variant.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/variant.py b/lib/spack/spack/variant.py index 13c8354ea9..ff0f910adc 100644 --- a/lib/spack/spack/variant.py +++ b/lib/spack/spack/variant.py @@ -403,15 +403,32 @@ class MultiValuedVariant(AbstractVariant): """ super_sat = super(MultiValuedVariant, self).satisfies(other) + if not super_sat: + return False + + if '*' in other or '*' in self: + return True + + # allow prefix find on patches + if self.name == 'patches': + return all(any(w.startswith(v) for w in self.value) for v in other.value) + # Otherwise we want all the values in `other` to be also in `self` - return super_sat and (all(v in self.value for v in other.value) or - '*' in other or '*' in self) + return all(v in self.value for v in other.value) def append(self, value): """Add another value to this multi-valued variant.""" self._value = tuple(sorted((value,) + self._value)) self._original_value = ",".join(self._value) + def __str__(self): + # Special-case patches to not print the full 64 character hashes + if self.name == 'patches': + values_str = ','.join(x[:7] for x in self.value) + else: + values_str = ','.join(str(x) for x in self.value) + return '{0}={1}'.format(self.name, values_str) + class SingleValuedVariant(AbstractVariant): """A variant that can hold multiple values, but one at a time.""" -- cgit v1.2.3-70-g09d2