aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-14 21:58:06 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-14 21:58:06 +0100
commit43cee0ec965e0456738b33d764711b8829af7055 (patch)
tree5360b298993bfb1999823a25faca32ed54c063c1
parentc84c91aed69c43772e0684cd4d05a638f80e44ac (diff)
downloadpaludis-43cee0ec965e0456738b33d764711b8829af7055.tar.gz
paludis-43cee0ec965e0456738b33d764711b8829af7055.tar.xz
RequiredConfirmations on ChangeOrRemoveDecision
-rw-r--r--paludis/resolver/decider.cc40
-rw-r--r--paludis/resolver/decider.hh3
-rw-r--r--paludis/resolver/decision.cc69
-rw-r--r--paludis/resolver/decision.hh9
-rw-r--r--paludis/resolver/lineariser.cc2
-rw-r--r--paludis/resolver/resolved.cc9
-rw-r--r--paludis/resolver/resolved.hh2
-rw-r--r--paludis/resolver/resolver.cc1
8 files changed, 130 insertions, 5 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index db9bde2..faf0a5f 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -31,6 +31,7 @@
#include <paludis/resolver/unsuitable_candidates.hh>
#include <paludis/resolver/resolver.hh>
#include <paludis/resolver/resolver_lists.hh>
+#include <paludis/resolver/required_confirmations.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_named_values.hh>
@@ -40,6 +41,7 @@
#include <paludis/util/enum_iterator.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/tribool.hh>
+#include <paludis/util/simple_visitor_cast.hh>
#include <paludis/environment.hh>
#include <paludis/notifier_callback.hh>
#include <paludis/repository.hh>
@@ -372,6 +374,17 @@ Decider::_resolve_destinations()
_do_destination_if_necessary(*i);
}
+void
+Decider::_resolve_confirmations()
+{
+ Context context("When resolving confirmations:");
+
+ for (ResolutionsByResolvent::ConstIterator i(_imp->resolutions_by_resolvent->begin()),
+ i_end(_imp->resolutions_by_resolvent->end()) ;
+ i != i_end ; ++i)
+ _confirm(*i);
+}
+
namespace
{
struct DoDestinationIfNecessaryVisitor
@@ -1766,6 +1779,9 @@ Decider::resolve()
_imp->env->trigger_notifier_callback(NotifierCallbackResolverStageEvent("Finding Destinations"));
_resolve_destinations();
+
+ _imp->env->trigger_notifier_callback(NotifierCallbackResolverStageEvent("Confirming"));
+ _resolve_confirmations();
}
bool
@@ -1783,3 +1799,27 @@ Decider::_already_met(const SanitisedDependency & dep) const
return dep.spec().if_package();
}
+void
+Decider::_confirm(
+ const std::tr1::shared_ptr<const Resolution> & resolution)
+{
+ ChangesToMakeDecision * const changes_to_make_decision(simple_visitor_cast<ChangesToMakeDecision>(*resolution->decision()));
+ if (! changes_to_make_decision)
+ return;
+
+ if (! changes_to_make_decision->best())
+ {
+ const std::tr1::shared_ptr<RequiredConfirmation> c(new NotBestConfirmation);
+ if (! _imp->fns.confirm_fn()(resolution, c))
+ changes_to_make_decision->add_required_confirmation(c);
+ }
+
+ if (ct_downgrade == changes_to_make_decision->change_type())
+ {
+ const std::tr1::shared_ptr<DowngradeConfirmation> c(new DowngradeConfirmation);
+ if (! _imp->fns.confirm_fn()(resolution, c))
+ changes_to_make_decision->add_required_confirmation(c);
+ }
+}
+
+
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 5e2630b..ff9d161 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -132,6 +132,7 @@ namespace paludis
void _resolve_decide_with_dependencies();
bool _resolve_dependents() PALUDIS_ATTRIBUTE((warn_unused_result));
void _resolve_destinations();
+ void _resolve_confirmations();
const std::tr1::shared_ptr<Destination> _make_destination_for(
const std::tr1::shared_ptr<const Resolution> & resolution,
@@ -212,6 +213,8 @@ namespace paludis
const std::tr1::shared_ptr<const PackageIDSequence> &,
const std::tr1::shared_ptr<const PackageIDSequence> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ void _confirm(const std::tr1::shared_ptr<const Resolution> & resolution);
+
public:
Decider(const Environment * const,
const ResolverFunctions &,
diff --git a/paludis/resolver/decision.cc b/paludis/resolver/decision.cc
index 09427a5..ac3e3ba 100644
--- a/paludis/resolver/decision.cc
+++ b/paludis/resolver/decision.cc
@@ -21,6 +21,7 @@
#include <paludis/resolver/destination.hh>
#include <paludis/resolver/unsuitable_candidates.hh>
#include <paludis/resolver/resolvent.hh>
+#include <paludis/resolver/required_confirmations.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
@@ -98,7 +99,7 @@ const std::tr1::shared_ptr<ChangesToMakeDecision>
ChangesToMakeDecision::deserialise(Deserialisation & d)
{
Deserialisator v(d, "ChangesToMakeDecision");
- return make_shared_ptr(new ChangesToMakeDecision(
+ std::tr1::shared_ptr<ChangesToMakeDecision> result(new ChangesToMakeDecision(
v.member<Resolvent>("resolvent"),
v.member<std::tr1::shared_ptr<const PackageID> >("origin_id"),
v.member<bool>("best"),
@@ -106,6 +107,18 @@ ChangesToMakeDecision::deserialise(Deserialisation & d)
v.member<bool>("taken"),
v.member<std::tr1::shared_ptr<const Destination> >("destination")
));
+
+ {
+ const std::tr1::shared_ptr<Deserialisation> dn(v.find_remove_member("required_confirmations_if_any"));
+ if (! dn->null())
+ {
+ Deserialisator vv(*dn, "c");
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ result->add_required_confirmation(vv.member<std::tr1::shared_ptr<RequiredConfirmation> >(stringify(n)));
+ }
+ }
+
+ return result;
}
const std::tr1::shared_ptr<UnableToMakeDecision>
@@ -131,15 +144,29 @@ RemoveDecision::deserialise(Deserialisation & d)
Deserialisator v(d, "RemoveDecision");
std::tr1::shared_ptr<PackageIDSequence> ids(new PackageIDSequence);
- Deserialisator vv(*v.find_remove_member("ids"), "c");
- for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
- ids->push_back(vv.member<std::tr1::shared_ptr<const PackageID> >(stringify(n)));
+ {
+ Deserialisator vv(*v.find_remove_member("ids"), "c");
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ ids->push_back(vv.member<std::tr1::shared_ptr<const PackageID> >(stringify(n)));
+ }
- return make_shared_ptr(new RemoveDecision(
+ const std::tr1::shared_ptr<RemoveDecision> result(new RemoveDecision(
v.member<Resolvent>("resolvent"),
ids,
v.member<bool>("taken")
));
+
+ {
+ const std::tr1::shared_ptr<Deserialisation> dn(v.find_remove_member("required_confirmations_if_any"));
+ if (! dn->null())
+ {
+ Deserialisator vv(*dn, "c");
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ result->add_required_confirmation(vv.member<std::tr1::shared_ptr<RequiredConfirmation> >(stringify(n)));
+ }
+ }
+
+ return result;
}
namespace paludis
@@ -293,6 +320,7 @@ namespace paludis
ChangeType change_type;
const bool taken;
std::tr1::shared_ptr<const Destination> destination;
+ std::tr1::shared_ptr<RequiredConfirmations> required_confirmations;
Implementation(
const Resolvent & l,
@@ -343,6 +371,20 @@ ChangesToMakeDecision::set_destination(const std::tr1::shared_ptr<const Destinat
_imp->destination = d;
}
+const std::tr1::shared_ptr<const RequiredConfirmations>
+ChangesToMakeDecision::required_confirmations_if_any() const
+{
+ return _imp->required_confirmations;
+}
+
+void
+ChangesToMakeDecision::add_required_confirmation(const std::tr1::shared_ptr<const RequiredConfirmation> & r)
+{
+ if (! _imp->required_confirmations)
+ _imp->required_confirmations.reset(new RequiredConfirmations);
+ _imp->required_confirmations->push_back(r);
+}
+
const std::tr1::shared_ptr<const PackageID>
ChangesToMakeDecision::origin_id() const
{
@@ -389,6 +431,7 @@ ChangesToMakeDecision::serialise(Serialiser & s) const
.member(SerialiserFlags<>(), "change_type", stringify(change_type()))
.member(SerialiserFlags<serialise::might_be_null>(), "destination", destination())
.member(SerialiserFlags<>(), "taken", taken())
+ .member(SerialiserFlags<serialise::might_be_null, serialise::container>(), "required_confirmations_if_any", required_confirmations_if_any())
;
}
@@ -463,6 +506,7 @@ namespace paludis
const Resolvent resolvent;
const std::tr1::shared_ptr<const PackageIDSequence> ids;
const bool taken;
+ std::tr1::shared_ptr<RequiredConfirmations> required_confirmations;
Implementation(const Resolvent & l, const std::tr1::shared_ptr<const PackageIDSequence> & i, const bool t) :
resolvent(l),
@@ -504,6 +548,20 @@ RemoveDecision::ids() const
return _imp->ids;
}
+const std::tr1::shared_ptr<const RequiredConfirmations>
+RemoveDecision::required_confirmations_if_any() const
+{
+ return _imp->required_confirmations;
+}
+
+void
+RemoveDecision::add_required_confirmation(const std::tr1::shared_ptr<const RequiredConfirmation> & r)
+{
+ if (! _imp->required_confirmations)
+ _imp->required_confirmations.reset(new RequiredConfirmations);
+ _imp->required_confirmations->push_back(r);
+}
+
void
RemoveDecision::serialise(Serialiser & s) const
{
@@ -511,6 +569,7 @@ RemoveDecision::serialise(Serialiser & s) const
.member(SerialiserFlags<>(), "resolvent", resolvent())
.member(SerialiserFlags<>(), "taken", taken())
.member(SerialiserFlags<serialise::might_be_null, serialise::container>(), "ids", ids())
+ .member(SerialiserFlags<serialise::might_be_null, serialise::container>(), "required_confirmations_if_any", required_confirmations_if_any())
;
}
diff --git a/paludis/resolver/decision.hh b/paludis/resolver/decision.hh
index 2afa959..f17d37d 100644
--- a/paludis/resolver/decision.hh
+++ b/paludis/resolver/decision.hh
@@ -25,6 +25,7 @@
#include <paludis/resolver/unsuitable_candidates-fwd.hh>
#include <paludis/resolver/change_type-fwd.hh>
#include <paludis/resolver/resolvent-fwd.hh>
+#include <paludis/resolver/required_confirmations-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/simple_visitor.hh>
#include <paludis/util/type_list.hh>
@@ -103,6 +104,8 @@ namespace paludis
public:
static const std::tr1::shared_ptr<ChangeOrRemoveDecision> deserialise(
Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<const RequiredConfirmations> required_confirmations_if_any() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
};
class PALUDIS_VISIBLE ChangesToMakeDecision :
@@ -140,6 +143,9 @@ namespace paludis
virtual const Resolvent resolvent() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool taken() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<const RequiredConfirmations> required_confirmations_if_any() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ void add_required_confirmation(const std::tr1::shared_ptr<const RequiredConfirmation> &);
+
virtual void serialise(Serialiser &) const;
static const std::tr1::shared_ptr<ChangesToMakeDecision> deserialise(
@@ -165,6 +171,9 @@ namespace paludis
const std::tr1::shared_ptr<const PackageIDSequence> ids() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<const RequiredConfirmations> required_confirmations_if_any() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ void add_required_confirmation(const std::tr1::shared_ptr<const RequiredConfirmation> &);
+
virtual void serialise(Serialiser &) const;
static const std::tr1::shared_ptr<RemoveDecision> deserialise(
diff --git a/paludis/resolver/lineariser.cc b/paludis/resolver/lineariser.cc
index 32315ba..67b4ea3 100644
--- a/paludis/resolver/lineariser.cc
+++ b/paludis/resolver/lineariser.cc
@@ -465,5 +465,7 @@ void
Lineariser::schedule(const std::tr1::shared_ptr<const ChangeOrRemoveDecision> & d)
{
_imp->resolved->taken_change_or_remove_decisions()->push_back(d);
+ if (d->required_confirmations_if_any())
+ _imp->resolved->taken_unconfirmed_change_or_remove_decisions()->push_back(d);
}
diff --git a/paludis/resolver/resolved.cc b/paludis/resolver/resolved.cc
index 9be43f5..ef389c0 100644
--- a/paludis/resolver/resolved.cc
+++ b/paludis/resolver/resolved.cc
@@ -34,6 +34,7 @@ Resolved::serialise(Serialiser & s) const
.member(SerialiserFlags<serialise::might_be_null>(), "resolutions_by_resolvent", resolutions_by_resolvent())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "taken_change_or_remove_decisions", taken_change_or_remove_decisions())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "taken_unable_to_make_decisions", taken_unable_to_make_decisions())
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "taken_unconfirmed_change_or_remove_decisions", taken_unconfirmed_change_or_remove_decisions())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "untaken_change_or_remove_decisions", untaken_change_or_remove_decisions())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "untaken_unable_to_make_decisions", untaken_unable_to_make_decisions())
;
@@ -51,6 +52,13 @@ Resolved::deserialise(Deserialisation & d)
taken_change_or_remove_decisions->push_back(vv.member<std::tr1::shared_ptr<ChangeOrRemoveDecision> >(stringify(n)));
}
+ std::tr1::shared_ptr<Decisions<ChangeOrRemoveDecision> > taken_unconfirmed_change_or_remove_decisions(new Decisions<ChangeOrRemoveDecision>);
+ {
+ Deserialisator vv(*v.find_remove_member("taken_unconfirmed_change_or_remove_decisions"), "c");
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ taken_unconfirmed_change_or_remove_decisions->push_back(vv.member<std::tr1::shared_ptr<ChangeOrRemoveDecision> >(stringify(n)));
+ }
+
std::tr1::shared_ptr<Decisions<UnableToMakeDecision> > taken_unable_to_make_decisions(new Decisions<UnableToMakeDecision>);
{
Deserialisator vv(*v.find_remove_member("taken_unable_to_make_decisions"), "c");
@@ -76,6 +84,7 @@ Resolved::deserialise(Deserialisation & d)
n::resolutions_by_resolvent() = v.member<std::tr1::shared_ptr<ResolutionsByResolvent> >("resolutions_by_resolvent"),
n::taken_change_or_remove_decisions() = taken_change_or_remove_decisions,
n::taken_unable_to_make_decisions() = taken_unable_to_make_decisions,
+ n::taken_unconfirmed_change_or_remove_decisions() = taken_unconfirmed_change_or_remove_decisions,
n::untaken_change_or_remove_decisions() = untaken_change_or_remove_decisions,
n::untaken_unable_to_make_decisions() = untaken_unable_to_make_decisions
);
diff --git a/paludis/resolver/resolved.hh b/paludis/resolver/resolved.hh
index f4ff2c6..757063d 100644
--- a/paludis/resolver/resolved.hh
+++ b/paludis/resolver/resolved.hh
@@ -35,6 +35,7 @@ namespace paludis
typedef Name<struct resolutions_by_resolvent_name> resolutions_by_resolvent;
typedef Name<struct taken_change_or_remove_decisions_name> taken_change_or_remove_decisions;
typedef Name<struct taken_unable_to_make_decisions_name> taken_unable_to_make_decisions;
+ typedef Name<struct taken_unconfirmed_change_or_remove_decisions_name> taken_unconfirmed_change_or_remove_decisions;
typedef Name<struct untaken_change_or_remove_decisions_name> untaken_change_or_remove_decisions;
typedef Name<struct untaken_unable_to_make_decisions_name> untaken_unable_to_make_decisions;
}
@@ -46,6 +47,7 @@ namespace paludis
NamedValue<n::resolutions_by_resolvent, std::tr1::shared_ptr<ResolutionsByResolvent> > resolutions_by_resolvent;
NamedValue<n::taken_change_or_remove_decisions, std::tr1::shared_ptr<Decisions<ChangeOrRemoveDecision> > > taken_change_or_remove_decisions;
NamedValue<n::taken_unable_to_make_decisions, std::tr1::shared_ptr<Decisions<UnableToMakeDecision> > > taken_unable_to_make_decisions;
+ NamedValue<n::taken_unconfirmed_change_or_remove_decisions, std::tr1::shared_ptr<Decisions<ChangeOrRemoveDecision> > > taken_unconfirmed_change_or_remove_decisions;
NamedValue<n::untaken_change_or_remove_decisions, std::tr1::shared_ptr<Decisions<ChangeOrRemoveDecision> > > untaken_change_or_remove_decisions;
NamedValue<n::untaken_unable_to_make_decisions, std::tr1::shared_ptr<Decisions<UnableToMakeDecision> > > untaken_unable_to_make_decisions;
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index f983498..386edf9 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -79,6 +79,7 @@ namespace paludis
n::resolutions_by_resolvent() = lists->resolutions_by_resolvent(),
n::taken_change_or_remove_decisions() = make_shared_ptr(new Decisions<ChangeOrRemoveDecision>),
n::taken_unable_to_make_decisions() = make_shared_ptr(new Decisions<UnableToMakeDecision>),
+ n::taken_unconfirmed_change_or_remove_decisions() = make_shared_ptr(new Decisions<ChangeOrRemoveDecision>),
n::untaken_change_or_remove_decisions() = make_shared_ptr(new Decisions<ChangeOrRemoveDecision>),
n::untaken_unable_to_make_decisions() = make_shared_ptr(new Decisions<UnableToMakeDecision>)
))),