aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-06 16:17:30 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-06 16:17:30 +0000
commit992b06a0a6360dfd0d0788b4b004c9204198e490 (patch)
tree520b8b49b66787b9c8979d72a36a81f1021e51b3
parent9aee48c1986d41476fecce57214b9dff77c5b870 (diff)
downloadpaludis-992b06a0a6360dfd0d0788b4b004c9204198e490.tar.gz
paludis-992b06a0a6360dfd0d0788b4b004c9204198e490.tar.xz
Track reasons for presets
-rw-r--r--paludis/resolver/decider.cc2
-rw-r--r--paludis/resolver/reason.cc37
-rw-r--r--paludis/resolver/reason.hh7
-rw-r--r--src/clients/cave/cmd_display_resolution.cc5
-rw-r--r--src/clients/cave/resolve_common.cc2
5 files changed, 46 insertions, 7 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 79e91b7..d081455 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);
+ const std::tr1::shared_ptr<PresetReason> reason(new PresetReason(c->reason()));
result->reason() = reason;
if (result->spec().if_package())
diff --git a/paludis/resolver/reason.cc b/paludis/resolver/reason.cc
index 67afeb8..6ccbe8b 100644
--- a/paludis/resolver/reason.cc
+++ b/paludis/resolver/reason.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -106,10 +106,40 @@ DependencyReason::serialise(Serialiser & s) const
;
}
+namespace paludis
+{
+ template <>
+ struct Implementation<PresetReason>
+ {
+ const std::tr1::shared_ptr<const Reason> reason_for_preset;
+
+ Implementation(const std::tr1::shared_ptr<const Reason> & r) :
+ reason_for_preset(r)
+ {
+ }
+ };
+}
+
+PresetReason::PresetReason(const std::tr1::shared_ptr<const Reason> & r) :
+ PrivateImplementationPattern<PresetReason>(new Implementation<PresetReason>(r))
+{
+}
+
+PresetReason::~PresetReason()
+{
+}
+
+const std::tr1::shared_ptr<const Reason>
+PresetReason::reason_for_preset() const
+{
+ return _imp->reason_for_preset;
+}
+
void
PresetReason::serialise(Serialiser & s) const
{
s.object("PresetReason")
+ .member(SerialiserFlags<serialise::might_be_null>(), "reason_for_preset", reason_for_preset())
;
}
@@ -170,7 +200,9 @@ Reason::deserialise(Deserialisation & d)
else if (d.class_name() == "PresetReason")
{
Deserialisator v(d, "PresetReason");
- return make_shared_ptr(new PresetReason);
+ return make_shared_ptr(new PresetReason(
+ v.member<std::tr1::shared_ptr<Reason> >("reason_for_preset")
+ ));
}
else if (d.class_name() == "SetReason")
{
@@ -197,4 +229,5 @@ Reason::deserialise(Deserialisation & d)
template class PrivateImplementationPattern<DependencyReason>;
template class PrivateImplementationPattern<SetReason>;
+template class PrivateImplementationPattern<PresetReason>;
diff --git a/paludis/resolver/reason.hh b/paludis/resolver/reason.hh
index 247f32b..31563d8 100644
--- a/paludis/resolver/reason.hh
+++ b/paludis/resolver/reason.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -79,10 +79,15 @@ namespace paludis
};
class PresetReason :
+ private PrivateImplementationPattern<PresetReason>,
public Reason,
public ImplementAcceptMethods<Reason, PresetReason>
{
public:
+ PresetReason(const std::tr1::shared_ptr<const Reason> &);
+ ~PresetReason();
+
+ const std::tr1::shared_ptr<const Reason> reason_for_preset() 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 d8d98b6..3469806 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -160,9 +160,10 @@ namespace
return std::make_pair(rr.first + " (" + stringify(r.set_name()) + ")", rr.second);
}
- std::pair<std::string, bool> visit(const PresetReason &) const
+ std::pair<std::string, bool> visit(const PresetReason & r) const
{
- return std::make_pair("", false);
+ 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);
}
};
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 078b0d5..334b9ea 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -613,7 +613,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)),
+ value_for<n::reason>(make_shared_ptr(new PresetReason(make_shared_ptr(new TargetReason)))),
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)