summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2022-02-17 11:06:32 +0100
committerGitHub <noreply@github.com>2022-02-17 11:06:32 +0100
commitd93f9b82acd8559a1512e0abf3b48ae2268b1cf0 (patch)
tree100276f1de709d876143a7b4576395320b23da5e /lib
parentfa132614e09204238d9a95cb61cfe3b852877bdc (diff)
downloadspack-d93f9b82acd8559a1512e0abf3b48ae2268b1cf0.tar.gz
spack-d93f9b82acd8559a1512e0abf3b48ae2268b1cf0.tar.bz2
spack-d93f9b82acd8559a1512e0abf3b48ae2268b1cf0.tar.xz
spack-d93f9b82acd8559a1512e0abf3b48ae2268b1cf0.zip
Reduce verbosity of patches=... variant (#29015)
* reduce verbosity of patches=... variant * Special-case prefix-matches for satisfies of patches variant
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/variant.py21
1 files changed, 19 insertions, 2 deletions
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."""