aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-01 21:33:48 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-01 21:33:48 +0000
commit9b2bf67bde2d38555e9c17305da932a379f61adf (patch)
tree97f4fe40f1f6c4660d39033acb5ee6a4d9574a2a
parentc62994832bf483e9974eec057d9d8d13f9b202ed (diff)
downloadpaludis-9b2bf67bde2d38555e9c17305da932a379f61adf.tar.gz
paludis-9b2bf67bde2d38555e9c17305da932a379f61adf.tar.xz
Track which reasons need changes
-rw-r--r--paludis/resolver/Makefile.am6
-rw-r--r--paludis/resolver/decider.cc33
-rw-r--r--paludis/resolver/decider.hh3
-rw-r--r--paludis/resolver/decision.cc11
-rw-r--r--paludis/resolver/decision.hh5
-rw-r--r--paludis/resolver/reason-fwd.hh4
-rw-r--r--paludis/resolver/reason.cc5
-rw-r--r--paludis/resolver/why_changed_choices-fwd.hh31
-rw-r--r--paludis/resolver/why_changed_choices.cc59
-rw-r--r--paludis/resolver/why_changed_choices.hh52
-rwxr-xr-xsrc/clients/cave/cmd_display_resolution.cc5
11 files changed, 192 insertions, 22 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index d7034fa..2116c8d 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -92,7 +92,8 @@ noinst_HEADERS = \
strongly_connected_component.hh strongly_connected_component-fwd.hh \
suggest_restart.hh suggest_restart-fwd.hh \
unsuitable_candidates.hh unsuitable_candidates-fwd.hh \
- use_existing.hh use_existing-fwd.hh use_existing-se.hh
+ use_existing.hh use_existing-fwd.hh use_existing-se.hh \
+ why_changed_choices.hh why_changed_choices-fwd.hh
libpaludisresolver_a_SOURCES = \
accumulate_deps_and_provides.cc \
@@ -159,7 +160,8 @@ libpaludisresolver_a_SOURCES = \
strongly_connected_component.cc \
suggest_restart.cc \
unsuitable_candidates.cc \
- use_existing.cc
+ use_existing.cc \
+ why_changed_choices.cc
if ENABLE_VIRTUALS_REPOSITORY
virtuals_tests = resolver_TEST_virtuals
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index d99b767..eda0b99 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -36,6 +36,7 @@
#include <paludis/resolver/collect_installed.hh>
#include <paludis/resolver/collect_purges.hh>
#include <paludis/resolver/accumulate_deps_and_provides.hh>
+#include <paludis/resolver/why_changed_choices.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_named_values.hh>
@@ -752,7 +753,8 @@ namespace
bool visit(const ChangesToMakeDecision & decision) const
{
- return ok(decision.origin_id(), decision.if_changed_choices());
+ return ok(decision.origin_id(),
+ decision.if_changed_choices() ? decision.if_changed_choices()->changed_choices() : make_null_shared_ptr());
}
bool visit(const ExistingNoChangeDecision & decision) const
@@ -902,7 +904,7 @@ namespace
{
const std::shared_ptr<const ChangedChoices> visit(const ChangesToMakeDecision & d) const
{
- return d.if_changed_choices();
+ return d.if_changed_choices() ? d.if_changed_choices()->changed_choices() : make_null_shared_ptr();
}
const std::shared_ptr<const ChangedChoices> visit(const ExistingNoChangeDecision &) const
@@ -1160,7 +1162,8 @@ namespace
const std::pair<std::shared_ptr<const PackageID>, std::shared_ptr<const ChangedChoices> > visit(const ChangesToMakeDecision & decision) const
{
if (decision.taken())
- return std::make_pair(decision.origin_id(), decision.if_changed_choices());
+ return std::make_pair(decision.origin_id(),
+ decision.if_changed_choices() ? decision.if_changed_choices()->changed_choices() : make_null_shared_ptr());
else
return std::make_pair(make_null_shared_ptr(), make_null_shared_ptr());
}
@@ -1543,7 +1546,7 @@ Decider::_try_to_find_decision_for(
const std::shared_ptr<const PackageID> existing_id(_find_existing_id_for(resolution));
std::shared_ptr<const PackageID> installable_id;
- std::shared_ptr<const ChangedChoices> changed_choices;
+ std::shared_ptr<const WhyChangedChoices> changed_choices;
bool best;
std::tie(installable_id, changed_choices, best) = _find_installable_id_for(resolution, try_option_changes_this_time, try_masked_this_time);
@@ -1865,7 +1868,10 @@ Decider::_find_id_for_from(
if (ok)
{
- std::shared_ptr<ChangedChoices> changed_choices(std::make_shared<ChangedChoices>());
+ auto why_changed_choices(std::make_shared<WhyChangedChoices>(WhyChangedChoices(make_named_values<WhyChangedChoices>(
+ n::changed_choices() = std::make_shared<ChangedChoices>(),
+ n::reasons() = std::make_shared<Reasons>()
+ ))));
if (trying_changing_choices)
{
for (Constraints::ConstIterator c(resolution->constraints()->begin()),
@@ -1895,12 +1901,17 @@ Decider::_find_id_for_from(
for (auto a((*c)->spec().if_package()->additional_requirements_ptr()->begin()),
a_end((*c)->spec().if_package()->additional_requirements_ptr()->end()) ;
a != a_end ; ++a)
- if ((*a)->accumulate_changes_to_make_met(_imp->env,
- get_changed_choices_for(*c).get(), *i, *changed_choices).is_false())
+ {
+ auto b((*a)->accumulate_changes_to_make_met(_imp->env,
+ get_changed_choices_for(*c).get(), *i, *why_changed_choices->changed_choices()));
+ if (b.is_false())
{
ok = false;
break;
}
+ else if (b.is_true())
+ why_changed_choices->reasons()->push_back((*c)->reason());
+ }
}
}
@@ -1915,14 +1926,16 @@ Decider::_find_id_for_from(
if ((*c)->spec().if_package())
ok = ok && match_package_with_maybe_changes(*_imp->env, *(*c)->spec().if_package(),
- get_changed_choices_for(*c).get(), **i, changed_choices.get(), { });
+ get_changed_choices_for(*c).get(), **i, why_changed_choices->changed_choices().get(), { });
else
ok = ok && ! match_package_with_maybe_changes(*_imp->env, (*c)->spec().if_block()->blocking(),
- get_changed_choices_for(*c).get(), **i, changed_choices.get(), { });
+ get_changed_choices_for(*c).get(), **i, why_changed_choices->changed_choices().get(), { });
}
if (ok)
- return FoundID(*i, changed_choices->empty() ? make_null_shared_ptr() : changed_choices, (*i)->version() == best_version->version());
+ return FoundID(*i,
+ why_changed_choices->changed_choices()->empty() ? make_null_shared_ptr() : why_changed_choices,
+ (*i)->version() == best_version->version());
}
}
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 93a7a4f..4cab575 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -38,6 +38,7 @@
#include <paludis/resolver/package_or_block_dep_spec-fwd.hh>
#include <paludis/resolver/resolutions_by_resolvent-fwd.hh>
#include <paludis/resolver/change_by_resolvent-fwd.hh>
+#include <paludis/resolver/why_changed_choices-fwd.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/pimp.hh>
#include <paludis/util/tribool-fwd.hh>
@@ -57,7 +58,7 @@ namespace paludis
private Pimp<Decider>
{
private:
- typedef std::tuple<std::shared_ptr<const PackageID>, std::shared_ptr<const ChangedChoices>, bool> FoundID;
+ typedef std::tuple<std::shared_ptr<const PackageID>, std::shared_ptr<const WhyChangedChoices>, bool> FoundID;
const std::shared_ptr<Resolution> _create_resolution_for_resolvent(const Resolvent &) const;
const std::shared_ptr<Resolution> _resolution_for_resolvent(const Resolvent &, const Tribool);
diff --git a/paludis/resolver/decision.cc b/paludis/resolver/decision.cc
index 842de00..8bc1987 100644
--- a/paludis/resolver/decision.cc
+++ b/paludis/resolver/decision.cc
@@ -22,6 +22,7 @@
#include <paludis/resolver/unsuitable_candidates.hh>
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/required_confirmations.hh>
+#include <paludis/resolver/why_changed_choices.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/stringify.hh>
@@ -122,7 +123,7 @@ ChangesToMakeDecision::deserialise(Deserialisation & d)
std::shared_ptr<ChangesToMakeDecision> result(std::make_shared<ChangesToMakeDecision>(
v.member<Resolvent>("resolvent"),
v.member<std::shared_ptr<const PackageID> >("origin_id"),
- v.member<std::shared_ptr<const ChangedChoices> >("if_changed_choices"),
+ v.member<std::shared_ptr<const WhyChangedChoices> >("if_changed_choices"),
v.member<bool>("best"),
destringify<ChangeType>(v.member<std::string>("change_type")),
v.member<bool>("taken"),
@@ -331,7 +332,7 @@ namespace paludis
{
const Resolvent resolvent;
const std::shared_ptr<const PackageID> origin_id;
- const std::shared_ptr<const ChangedChoices> changed_choices;
+ const std::shared_ptr<const WhyChangedChoices> changed_choices;
const bool best;
ChangeType change_type;
const bool taken;
@@ -342,7 +343,7 @@ namespace paludis
Imp(
const Resolvent & l,
const std::shared_ptr<const PackageID> & o,
- const std::shared_ptr<const ChangedChoices> & h,
+ const std::shared_ptr<const WhyChangedChoices> & h,
const bool b,
const ChangeType c,
const bool t,
@@ -362,7 +363,7 @@ namespace paludis
ChangesToMakeDecision::ChangesToMakeDecision(
const Resolvent & r,
const std::shared_ptr<const PackageID> & o,
- const std::shared_ptr<const ChangedChoices> & h,
+ const std::shared_ptr<const WhyChangedChoices> & h,
const bool b,
const ChangeType c,
const bool t,
@@ -408,7 +409,7 @@ ChangesToMakeDecision::origin_id() const
return _imp->origin_id;
}
-const std::shared_ptr<const ChangedChoices>
+const std::shared_ptr<const WhyChangedChoices>
ChangesToMakeDecision::if_changed_choices() const
{
return _imp->changed_choices;
diff --git a/paludis/resolver/decision.hh b/paludis/resolver/decision.hh
index eab8fee..81dbe9e 100644
--- a/paludis/resolver/decision.hh
+++ b/paludis/resolver/decision.hh
@@ -26,6 +26,7 @@
#include <paludis/resolver/change_type-fwd.hh>
#include <paludis/resolver/resolvent-fwd.hh>
#include <paludis/resolver/required_confirmations-fwd.hh>
+#include <paludis/resolver/why_changed_choices-fwd.hh>
#include <paludis/util/pimp.hh>
#include <paludis/util/simple_visitor.hh>
#include <paludis/util/type_list.hh>
@@ -152,7 +153,7 @@ namespace paludis
ChangesToMakeDecision(
const Resolvent &,
const std::shared_ptr<const PackageID> &,
- const std::shared_ptr<const ChangedChoices> &,
+ const std::shared_ptr<const WhyChangedChoices> &,
const bool best,
const ChangeType,
const bool taken,
@@ -170,7 +171,7 @@ namespace paludis
const std::shared_ptr<const PackageID> origin_id() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- const std::shared_ptr<const ChangedChoices> if_changed_choices() const
+ const std::shared_ptr<const WhyChangedChoices> if_changed_choices() const
PALUDIS_ATTRIBUTE((warn_unused_result));
const std::shared_ptr<const RepositoryName> if_via_new_binary_in() const
diff --git a/paludis/resolver/reason-fwd.hh b/paludis/resolver/reason-fwd.hh
index cbe8cd5..b6c6bdb 100644
--- a/paludis/resolver/reason-fwd.hh
+++ b/paludis/resolver/reason-fwd.hh
@@ -21,6 +21,8 @@
#define PALUDIS_GUARD_PALUDIS_RESOLVER_REASON_FWD_HH 1
#include <paludis/util/attributes.hh>
+#include <paludis/util/sequence-fwd.hh>
+#include <memory>
namespace paludis
{
@@ -35,6 +37,8 @@ namespace paludis
struct WasUsedByReason;
struct LikeOtherDestinationTypeReason;
struct ViaBinaryReason;
+
+ typedef Sequence<std::shared_ptr<const Reason> > Reasons;
}
}
diff --git a/paludis/resolver/reason.cc b/paludis/resolver/reason.cc
index 94057d7..a0ec6cd 100644
--- a/paludis/resolver/reason.cc
+++ b/paludis/resolver/reason.cc
@@ -23,6 +23,8 @@
#include <paludis/resolver/change_by_resolvent.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/sequence-impl.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/serialise-impl.hh>
#include <paludis/changed_choices.hh>
@@ -478,3 +480,6 @@ template class Pimp<WasUsedByReason>;
template class Pimp<LikeOtherDestinationTypeReason>;
template class Pimp<ViaBinaryReason>;
+template class Sequence<std::shared_ptr<const Reason> >;
+template class WrappedForwardIterator<Reasons::ConstIteratorTag, const std::shared_ptr<const Reason> >;
+
diff --git a/paludis/resolver/why_changed_choices-fwd.hh b/paludis/resolver/why_changed_choices-fwd.hh
new file mode 100644
index 0000000..fdbedc4
--- /dev/null
+++ b/paludis/resolver/why_changed_choices-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_WHY_CHANGED_CHOICES_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_WHY_CHANGED_CHOICES_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct WhyChangedChoices;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/why_changed_choices.cc b/paludis/resolver/why_changed_choices.cc
new file mode 100644
index 0000000..13a3b06
--- /dev/null
+++ b/paludis/resolver/why_changed_choices.cc
@@ -0,0 +1,59 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/resolver/why_changed_choices.hh>
+#include <paludis/resolver/reason.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/serialise-impl.hh>
+#include <paludis/changed_choices.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+void
+WhyChangedChoices::serialise(Serialiser & s) const
+{
+ auto ss(s.object("WhyChangedChoices"));
+
+ ss.member(SerialiserFlags<serialise::might_be_null>(), "changed_choices", changed_choices());
+
+ int n(0);
+ for (auto o(reasons()->begin()), o_end(reasons()->end()) ;
+ o != o_end ; ++o)
+ ss.member(SerialiserFlags<>(), stringify(++n), **o);
+ ss.member(SerialiserFlags<>(), "reasons_count", stringify(n));
+}
+
+const std::shared_ptr<WhyChangedChoices>
+WhyChangedChoices::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "WhyChangedChoices");
+ auto result(std::make_shared<WhyChangedChoices>(make_named_values<WhyChangedChoices>(
+ n::changed_choices() = v.member<std::shared_ptr<ChangedChoices> >("changed_choices"),
+ n::reasons() = std::make_shared<Reasons>()
+ )));
+
+ for (int n(1), n_end(v.member<int>("reasons_count") + 1) ; n != n_end ; ++n)
+ result->reasons()->push_back(v.member<std::shared_ptr<Reason> >(stringify(n)));
+
+ return result;
+}
+
diff --git a/paludis/resolver/why_changed_choices.hh b/paludis/resolver/why_changed_choices.hh
new file mode 100644
index 0000000..e1ceebd
--- /dev/null
+++ b/paludis/resolver/why_changed_choices.hh
@@ -0,0 +1,52 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_WHY_CHANGED_CHOICES_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_WHY_CHANGED_CHOICES_HH 1
+
+#include <paludis/resolver/why_changed_choices-fwd.hh>
+#include <paludis/resolver/reason-fwd.hh>
+#include <paludis/util/named_value.hh>
+#include <paludis/changed_choices-fwd.hh>
+#include <paludis/serialise-fwd.hh>
+
+namespace paludis
+{
+ namespace n
+ {
+ typedef Name<struct changed_choices_name> changed_choices;
+ typedef Name<struct reasons_name> reasons;
+ }
+
+ namespace resolver
+ {
+ struct WhyChangedChoices
+ {
+ NamedValue<n::changed_choices, std::shared_ptr<ChangedChoices> > changed_choices;
+ NamedValue<n::reasons, std::shared_ptr<Reasons> > reasons;
+
+ void serialise(Serialiser &) const;
+
+ static const std::shared_ptr<WhyChangedChoices> deserialise(
+ Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+ }
+}
+
+#endif
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index 612c585..e6e6991 100755
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -57,6 +57,7 @@
#include <paludis/resolver/orderer_notes.hh>
#include <paludis/resolver/change_by_resolvent.hh>
#include <paludis/resolver/match_qpns.hh>
+#include <paludis/resolver/why_changed_choices.hh>
#include <paludis/package_id.hh>
#include <paludis/version_spec.hh>
#include <paludis/metadata_key.hh>
@@ -523,7 +524,7 @@ namespace
const std::shared_ptr<Environment> &,
const DisplayResolutionCommandLine & cmdline,
const std::shared_ptr<const PackageID> & id,
- const std::shared_ptr<const ChangedChoices> & changed_choices,
+ const std::shared_ptr<const WhyChangedChoices> & changed_choices,
const std::shared_ptr<const PackageID> & old_id,
ChoicesToExplain & choices_to_explain
)
@@ -554,7 +555,7 @@ namespace
Tribool changed_state(indeterminate);
if (changed_choices)
- changed_state = changed_choices->overridden_value((*i)->name_with_prefix());
+ changed_state = changed_choices->changed_choices()->overridden_value((*i)->name_with_prefix());
auto & s_prefix(changed_state.is_indeterminate() ? unchanged_s_prefix : changed_s_prefix);
auto & shown_prefix(changed_state.is_indeterminate() ? shown_prefix_unchanged : shown_prefix_changed);