aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-04 20:47:22 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-04 20:47:22 +0100
commit7602f5dd93d8d9eb6f37787e7c2a45c7fc01bcc6 (patch)
tree4a549d3c5e0656ff7574be8fee0d0de09afd20bc
parent63559a5cc9adcfee5ac079066963ed13f85aec2c (diff)
downloadpaludis-7602f5dd93d8d9eb6f37787e7c2a45c7fc01bcc6.tar.gz
paludis-7602f5dd93d8d9eb6f37787e7c2a45c7fc01bcc6.tar.xz
Get [foo=] deps for changed choices right
-rw-r--r--paludis/resolver/decider.cc76
-rw-r--r--paludis/resolver/reason.cc15
-rw-r--r--paludis/resolver/reason.hh3
3 files changed, 84 insertions, 10 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 165f844..0e81eb1 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -819,10 +819,14 @@ namespace
struct CheckConstraintVisitor
{
const Environment * const env;
+ const std::shared_ptr<const ChangedChoices> changed_choices_for_constraint;
const Constraint constraint;
- CheckConstraintVisitor(const Environment * const e, const Constraint & c) :
+ CheckConstraintVisitor(const Environment * const e,
+ const std::shared_ptr<const ChangedChoices> & h,
+ const Constraint & c) :
env(e),
+ changed_choices_for_constraint(h),
constraint(c)
{
}
@@ -832,12 +836,14 @@ namespace
{
if (constraint.spec().if_package())
{
- if (! match_package_with_maybe_changes(*env, *constraint.spec().if_package(), 0, *chosen_id, changed_choices.get(), { }))
+ if (! match_package_with_maybe_changes(*env, *constraint.spec().if_package(),
+ changed_choices_for_constraint.get(), *chosen_id, changed_choices.get(), { }))
return false;
}
else
{
- if (match_package_with_maybe_changes(*env, constraint.spec().if_block()->blocking(), 0, *chosen_id, changed_choices.get(), { }))
+ if (match_package_with_maybe_changes(*env, constraint.spec().if_block()->blocking(),
+ changed_choices_for_constraint.get(), *chosen_id, changed_choices.get(), { }))
return false;
}
@@ -939,6 +945,55 @@ namespace
return true;
}
};
+
+ struct GetChangedChoices
+ {
+ const std::shared_ptr<const ChangedChoices> visit(const TargetReason &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const DependentReason &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const PresetReason &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const DependencyReason & r) const
+ {
+ return r.from_id_changed_choices();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const ViaBinaryReason &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const WasUsedByReason &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const LikeOtherDestinationTypeReason &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const SetReason & r) const
+ {
+ return r.reason_for_set()->accept_returning<std::shared_ptr<const ChangedChoices> >(*this);
+ }
+ };
+
+ std::shared_ptr<const ChangedChoices> get_changed_choices_for(
+ const std::shared_ptr<const Constraint> & constraint)
+ {
+ return constraint->reason()->accept_returning<std::shared_ptr<const ChangedChoices> >(GetChangedChoices());
+ }
}
bool
@@ -946,7 +1001,7 @@ Decider::_check_constraint(
const std::shared_ptr<const Constraint> & constraint,
const std::shared_ptr<const Decision> & decision) const
{
- if (! decision->accept_returning<bool>(CheckConstraintVisitor(_imp->env, *constraint)))
+ if (! decision->accept_returning<bool>(CheckConstraintVisitor(_imp->env, get_changed_choices_for(constraint), *constraint)))
return false;
if (! decision->accept_returning<bool>(CheckUseExistingVisitor(constraint)))
@@ -1203,7 +1258,7 @@ Decider::_add_dependencies_if_necessary(
}
const std::shared_ptr<DependencyReason> reason(std::make_shared<DependencyReason>(
- package_id, our_resolution->resolvent(), *s, _already_met(*s)));
+ package_id, changed_choices, our_resolution->resolvent(), *s, _already_met(*s)));
std::shared_ptr<const Resolvents> resolvents;
@@ -1364,7 +1419,7 @@ Decider::find_any_score(
}
const std::shared_ptr<DependencyReason> reason(std::make_shared<DependencyReason>(
- our_id, our_resolution->resolvent(), dep, _already_met(dep)));
+ our_id, make_null_shared_ptr(), our_resolution->resolvent(), dep, _already_met(dep)));
const std::shared_ptr<const Resolvents> resolvents(_get_resolvents_for(spec, reason));
/* next: will already be installing */
@@ -1881,7 +1936,8 @@ 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, 0, *i, *changed_choices))
+ if (! (*a)->accumulate_changes_to_make_met(_imp->env,
+ get_changed_choices_for(*c).get(), *i, *changed_choices))
{
ok = false;
break;
@@ -1899,9 +1955,11 @@ Decider::_find_id_for_from(
break;
if ((*c)->spec().if_package())
- ok = ok && match_package_with_maybe_changes(*_imp->env, *(*c)->spec().if_package(), 0, **i, changed_choices.get(), { });
+ ok = ok && match_package_with_maybe_changes(*_imp->env, *(*c)->spec().if_package(),
+ get_changed_choices_for(*c).get(), **i, changed_choices.get(), { });
else
- ok = ok && ! match_package_with_maybe_changes(*_imp->env, (*c)->spec().if_block()->blocking(), 0, **i, changed_choices.get(), { });
+ ok = ok && ! match_package_with_maybe_changes(*_imp->env, (*c)->spec().if_block()->blocking(),
+ get_changed_choices_for(*c).get(), **i, changed_choices.get(), { });
}
if (ok)
diff --git a/paludis/resolver/reason.cc b/paludis/resolver/reason.cc
index bf999b2..94057d7 100644
--- a/paludis/resolver/reason.cc
+++ b/paludis/resolver/reason.cc
@@ -24,6 +24,7 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/serialise-impl.hh>
+#include <paludis/changed_choices.hh>
using namespace paludis;
using namespace paludis::resolver;
@@ -75,13 +76,16 @@ namespace paludis
struct Imp<DependencyReason>
{
const std::shared_ptr<const PackageID> from_id;
+ const std::shared_ptr<const ChangedChoices> changed_choices;
const Resolvent from_resolvent;
const SanitisedDependency dep;
const bool already_met;
Imp(const std::shared_ptr<const PackageID> & i,
+ const std::shared_ptr<const ChangedChoices> & c,
const Resolvent & r, const SanitisedDependency & d, const bool a) :
from_id(i),
+ changed_choices(c),
from_resolvent(r),
dep(d),
already_met(a)
@@ -91,10 +95,11 @@ namespace paludis
}
DependencyReason::DependencyReason(const std::shared_ptr<const PackageID> & i,
+ const std::shared_ptr<const ChangedChoices> & c,
const Resolvent & r,
const SanitisedDependency & d,
const bool a) :
- Pimp<DependencyReason>(i, r, d, a)
+ Pimp<DependencyReason>(i, c, r, d, a)
{
}
@@ -108,6 +113,12 @@ DependencyReason::from_id() const
return _imp->from_id;
}
+const std::shared_ptr<const ChangedChoices>
+DependencyReason::from_id_changed_choices() const
+{
+ return _imp->changed_choices;
+}
+
const Resolvent
DependencyReason::from_resolvent() const
{
@@ -132,6 +143,7 @@ DependencyReason::serialise(Serialiser & s) const
s.object("DependencyReason")
.member(SerialiserFlags<>(), "already_met", already_met())
.member(SerialiserFlags<serialise::might_be_null>(), "from_id", from_id())
+ .member(SerialiserFlags<serialise::might_be_null>(), "from_id_changed_choices", from_id_changed_choices())
.member(SerialiserFlags<>(), "from_resolvent", from_resolvent())
.member(SerialiserFlags<>(), "sanitised_dependency", sanitised_dependency())
;
@@ -416,6 +428,7 @@ Reason::deserialise(Deserialisation & d)
const std::shared_ptr<const PackageID> from_id(v.member<std::shared_ptr<const PackageID> >("from_id"));
return std::make_shared<DependencyReason>(
from_id,
+ v.member<std::shared_ptr<const ChangedChoices> >("from_id_changed_choices"),
v.member<Resolvent>("from_resolvent"),
SanitisedDependency::deserialise(*v.find_remove_member("sanitised_dependency"), from_id),
v.member<bool>("already_met")
diff --git a/paludis/resolver/reason.hh b/paludis/resolver/reason.hh
index 91565f2..f91d5c3 100644
--- a/paludis/resolver/reason.hh
+++ b/paludis/resolver/reason.hh
@@ -30,6 +30,7 @@
#include <paludis/name-fwd.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/serialise-fwd.hh>
+#include <paludis/changed_choices-fwd.hh>
#include <memory>
namespace paludis
@@ -72,6 +73,7 @@ namespace paludis
public:
DependencyReason(
const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const ChangedChoices> &,
const Resolvent &,
const SanitisedDependency & s,
const bool already_met);
@@ -79,6 +81,7 @@ namespace paludis
~DependencyReason();
const std::shared_ptr<const PackageID> from_id() const;
+ const std::shared_ptr<const ChangedChoices> from_id_changed_choices() const;
const Resolvent from_resolvent() const;
const SanitisedDependency & sanitised_dependency() const;
bool already_met() const PALUDIS_ATTRIBUTE((warn_unused_result));