From 23963779f415697682485029e4334ca48656062b Mon Sep 17 00:00:00 2001 From: Aiden Grossman <39388941+boomanaiden154@users.noreply.github.com> Date: Thu, 10 Aug 2023 01:09:00 -0700 Subject: Prefix conflict messages with package name (#39106) * Prefix conflict messages with package name This patch prefixes all conflict messages with the package name to alleviate what was otherwise a very manual process. Note that this patch is a one line change but has a fairly outsized impact. * same for requires directive --------- Co-authored-by: Harmen Stoppels --- lib/spack/spack/directives.py | 6 ++++-- lib/spack/spack/solver/asp.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py index e1bb4d73e3..acb2af1a62 100644 --- a/lib/spack/spack/directives.py +++ b/lib/spack/spack/directives.py @@ -520,7 +520,8 @@ def conflicts(conflict_spec, when=None, msg=None): # Save in a list the conflicts and the associated custom messages when_spec_list = pkg.conflicts.setdefault(conflict_spec, []) - when_spec_list.append((when_spec, msg)) + msg_with_name = f"{pkg.name}: {msg}" if msg is not None else msg + when_spec_list.append((when_spec, msg_with_name)) return _execute_conflicts @@ -896,7 +897,8 @@ def requires(*requirement_specs, policy="one_of", when=None, msg=None): # Save in a list the requirements and the associated custom messages when_spec_list = pkg.requirements.setdefault(tuple(requirement_specs), []) - when_spec_list.append((when_spec, policy, msg)) + msg_with_name = f"{pkg.name}: {msg}" if msg is not None else msg + when_spec_list.append((when_spec, policy, msg_with_name)) return _execute_requires diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 7a4117667b..acfd0326b1 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -956,8 +956,8 @@ class SpackSolverSetup: return [fn.attr("node_target_satisfies", spec.name, target)] def conflict_rules(self, pkg): - default_msg = "{0} '{1}' conflicts with '{2}'" - no_constraint_msg = "{0} conflicts with '{1}'" + default_msg = "{0}: '{1}' conflicts with '{2}'" + no_constraint_msg = "{0}: conflicts with '{1}'" for trigger, constraints in pkg.conflicts.items(): trigger_msg = "conflict trigger %s" % str(trigger) trigger_id = self.condition(spack.spec.Spec(trigger), name=pkg.name, msg=trigger_msg) -- cgit v1.2.3-60-g2f50