aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-10 15:35:26 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-10 15:35:26 +0000
commitf9d42cd1deff8a2a8fb2d175f6f1d914e73505b3 (patch)
tree25b4281217f5b83b7832bf73b3465ba448559435
parent82644188160641c6f9a5fcb573e9a0aa0726b8b2 (diff)
downloadpaludis-f9d42cd1deff8a2a8fb2d175f6f1d914e73505b3.tar.gz
paludis-f9d42cd1deff8a2a8fb2d175f6f1d914e73505b3.tar.xz
Better preset descriptions
-rw-r--r--paludis/resolver/decider.cc2
-rw-r--r--paludis/resolver/reason.cc22
-rw-r--r--paludis/resolver/reason.hh9
-rw-r--r--src/clients/cave/cmd_display_resolution.cc10
-rw-r--r--src/clients/cave/resolve_common.cc4
5 files changed, 34 insertions, 13 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 295e814..fc22335 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -629,7 +629,7 @@ Decider::_make_constraint_for_preloading(
{
const std::tr1::shared_ptr<Constraint> result(new Constraint(*c));
- const std::tr1::shared_ptr<PresetReason> reason(new PresetReason(c->reason()));
+ const std::tr1::shared_ptr<PresetReason> reason(new PresetReason("restarted because of ", c->reason()));
result->reason() = reason;
if (result->spec().if_package())
diff --git a/paludis/resolver/reason.cc b/paludis/resolver/reason.cc
index 6ccbe8b..6191782 100644
--- a/paludis/resolver/reason.cc
+++ b/paludis/resolver/reason.cc
@@ -111,17 +111,19 @@ namespace paludis
template <>
struct Implementation<PresetReason>
{
+ const std::string explanation;
const std::tr1::shared_ptr<const Reason> reason_for_preset;
- Implementation(const std::tr1::shared_ptr<const Reason> & r) :
+ Implementation(const std::string & m, const std::tr1::shared_ptr<const Reason> & r) :
+ explanation(m),
reason_for_preset(r)
{
}
};
}
-PresetReason::PresetReason(const std::tr1::shared_ptr<const Reason> & r) :
- PrivateImplementationPattern<PresetReason>(new Implementation<PresetReason>(r))
+PresetReason::PresetReason(const std::string & m, const std::tr1::shared_ptr<const Reason> & r) :
+ PrivateImplementationPattern<PresetReason>(new Implementation<PresetReason>(m, r))
{
}
@@ -130,16 +132,23 @@ PresetReason::~PresetReason()
}
const std::tr1::shared_ptr<const Reason>
-PresetReason::reason_for_preset() const
+PresetReason::maybe_reason_for_preset() const
{
return _imp->reason_for_preset;
}
+const std::string
+PresetReason::maybe_explanation() const
+{
+ return _imp->explanation;
+}
+
void
PresetReason::serialise(Serialiser & s) const
{
s.object("PresetReason")
- .member(SerialiserFlags<serialise::might_be_null>(), "reason_for_preset", reason_for_preset())
+ .member(SerialiserFlags<>(), "maybe_explanation", maybe_explanation())
+ .member(SerialiserFlags<serialise::might_be_null>(), "maybe_reason_for_preset", maybe_reason_for_preset())
;
}
@@ -201,7 +210,8 @@ Reason::deserialise(Deserialisation & d)
{
Deserialisator v(d, "PresetReason");
return make_shared_ptr(new PresetReason(
- v.member<std::tr1::shared_ptr<Reason> >("reason_for_preset")
+ v.member<std::string>("maybe_explanation"),
+ v.member<std::tr1::shared_ptr<Reason> >("maybe_reason_for_preset")
));
}
else if (d.class_name() == "SetReason")
diff --git a/paludis/resolver/reason.hh b/paludis/resolver/reason.hh
index 31563d8..a48e84e 100644
--- a/paludis/resolver/reason.hh
+++ b/paludis/resolver/reason.hh
@@ -84,10 +84,15 @@ namespace paludis
public ImplementAcceptMethods<Reason, PresetReason>
{
public:
- PresetReason(const std::tr1::shared_ptr<const Reason> &);
+ PresetReason(
+ const std::string &,
+ const std::tr1::shared_ptr<const Reason> &);
~PresetReason();
- const std::tr1::shared_ptr<const Reason> reason_for_preset() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const Reason> maybe_reason_for_preset() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ const std::string maybe_explanation() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
virtual void serialise(Serialiser &) const;
};
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index 7601ee3..53b224c 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -162,8 +162,14 @@ namespace
std::pair<std::string, bool> visit(const PresetReason & r) const
{
- std::pair<std::string, bool> rr(r.reason_for_preset()->accept_returning<std::pair<std::string, bool> >(*this));
- return std::make_pair("preset (" + rr.first + ")", rr.second);
+ std::pair<std::string, bool> rr("", false);
+ if (r.maybe_reason_for_preset())
+ rr = r.maybe_reason_for_preset()->accept_returning<std::pair<std::string, bool> >(*this);
+
+ rr.first = r.maybe_explanation() + (r.maybe_explanation().empty() || rr.first.empty() ? "" : " ")
+ + rr.first;
+
+ return rr;
}
};
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 6e65cc2..a6fded9 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -619,7 +619,7 @@ namespace
result->add(make_shared_ptr(new Constraint(make_named_values<Constraint>(
value_for<n::destination_type>(resolvent.destination_type()),
value_for<n::nothing_is_fine_too>(false),
- value_for<n::reason>(make_shared_ptr(new PresetReason(make_shared_ptr(new TargetReason)))),
+ value_for<n::reason>(make_shared_ptr(new PresetReason("is scm", make_null_shared_ptr()))),
value_for<n::spec>(make_package_dep_spec(PartiallyMadePackageDepSpecOptions()).package(resolvent.package())),
value_for<n::untaken>(false),
value_for<n::use_existing>(ue_only_if_transient)
@@ -1261,7 +1261,7 @@ paludis::cave::resolve_common(
i_end(resolution_options.a_preset.end_args()) ;
i != i_end ; ++i)
{
- const std::tr1::shared_ptr<const Reason> reason(new PresetReason(make_shared_ptr(new TargetReason)));
+ const std::tr1::shared_ptr<const Reason> reason(new PresetReason("preset", make_null_shared_ptr()));
PackageDepSpec spec(parse_user_package_dep_spec(*i, env.get(), UserPackageDepSpecOptions()));
const std::tr1::shared_ptr<const Resolvents> resolvents(get_resolvents_for_fn(
env.get(), resolution_options, spec, make_null_shared_ptr(), reason));