aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-04 21:44:16 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-04 21:44:16 +0100
commit8fda0e9d7f09861c7e544dfef569e9c0a181a81a (patch)
tree14c6b50010f733cc0792efb228852b4ca5ee2500
parent1b2a9c10febe9212baf92dcefd87f295e45c5219 (diff)
downloadpaludis-8fda0e9d7f09861c7e544dfef569e9c0a181a81a.tar.gz
paludis-8fda0e9d7f09861c7e544dfef569e9c0a181a81a.tar.xz
Get restarts right for changed choices
-rw-r--r--paludis/changed_choices.cc17
-rw-r--r--paludis/changed_choices.hh3
-rw-r--r--paludis/resolver/decider.cc58
-rw-r--r--paludis/resolver/decider.hh4
4 files changed, 75 insertions, 7 deletions
diff --git a/paludis/changed_choices.cc b/paludis/changed_choices.cc
index 462d110..f4a11d6 100644
--- a/paludis/changed_choices.cc
+++ b/paludis/changed_choices.cc
@@ -22,6 +22,8 @@
#include <paludis/util/tribool.hh>
#include <paludis/choice.hh>
#include <paludis/serialise-impl.hh>
+#include <paludis/elike_use_requirement-fwd.hh>
+#include <paludis/dep_spec.hh>
#include <map>
using namespace paludis;
@@ -55,6 +57,21 @@ ChangedChoices::empty() const
return _imp->overrides.empty();
}
+void
+ChangedChoices::add_additional_requirements_to(PartiallyMadePackageDepSpec & spec) const
+{
+ for (auto o(_imp->overrides.begin()), o_end(_imp->overrides.end()) ;
+ o != o_end ; ++o)
+ {
+ if (o->second)
+ spec.additional_requirement(parse_elike_use_requirement("" + stringify(o->first) + "(-)",
+ make_null_shared_ptr(), { euro_allow_default_values }));
+ else
+ spec.additional_requirement(parse_elike_use_requirement("-" + stringify(o->first) + "(-)",
+ make_null_shared_ptr(), { euro_allow_default_values }));
+ }
+}
+
Tribool
ChangedChoices::overridden_value(const ChoiceNameWithPrefix & c) const
{
diff --git a/paludis/changed_choices.hh b/paludis/changed_choices.hh
index 18bd479..1efb83f 100644
--- a/paludis/changed_choices.hh
+++ b/paludis/changed_choices.hh
@@ -26,6 +26,7 @@
#include <paludis/util/attributes.hh>
#include <paludis/choice-fwd.hh>
#include <paludis/serialise-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
#include <memory>
namespace paludis
@@ -43,6 +44,8 @@ namespace paludis
bool empty() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ void add_additional_requirements_to(PartiallyMadePackageDepSpec &) const;
+
void serialise(Serialiser &) const;
static const std::shared_ptr<ChangedChoices> deserialise(
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index fa9f8c1..9d861cc 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -946,7 +946,7 @@ namespace
}
};
- struct GetChangedChoices
+ struct GetConstraintChangedChoices
{
const std::shared_ptr<const ChangedChoices> visit(const TargetReason &) const
{
@@ -992,7 +992,46 @@ namespace
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());
+ return constraint->reason()->accept_returning<std::shared_ptr<const ChangedChoices> >(GetConstraintChangedChoices());
+ }
+
+ struct GetDecisionChangedChoices
+ {
+ const std::shared_ptr<const ChangedChoices> visit(const ChangesToMakeDecision & d) const
+ {
+ return d.if_changed_choices();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const ExistingNoChangeDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const NothingNoChangeDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const UnableToMakeDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const RemoveDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::shared_ptr<const ChangedChoices> visit(const BreakDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+ };
+
+ std::shared_ptr<const ChangedChoices> get_changed_choices_for(
+ const std::shared_ptr<const Decision> & decision)
+ {
+ return decision->accept_returning<std::shared_ptr<const ChangedChoices> >(GetDecisionChangedChoices());
}
}
@@ -1099,7 +1138,7 @@ Decider::_suggest_restart_with(
const std::shared_ptr<const Constraint>
Decider::_make_constraint_for_preloading(
- const std::shared_ptr<const Decision> &,
+ const std::shared_ptr<const Decision> & decision,
const std::shared_ptr<const Constraint> & c) const
{
const std::shared_ptr<Constraint> result(std::make_shared<Constraint>(*c));
@@ -1107,14 +1146,16 @@ Decider::_make_constraint_for_preloading(
const std::shared_ptr<PresetReason> reason(std::make_shared<PresetReason>("restarted because of", c->reason()));
result->reason() = reason;
+ const std::shared_ptr<const ChangedChoices> changed_choices(get_changed_choices_for(decision));
+
if (result->spec().if_package())
{
- PackageDepSpec s(_make_spec_for_preloading(*result->spec().if_package()));
+ PackageDepSpec s(_make_spec_for_preloading(*result->spec().if_package(), changed_choices));
result->spec().if_package() = std::make_shared<PackageDepSpec>(s);
}
else
{
- PackageDepSpec s(_make_spec_for_preloading(result->spec().if_block()->blocking()));
+ PackageDepSpec s(_make_spec_for_preloading(result->spec().if_block()->blocking(), changed_choices));
result->spec().if_block() = std::make_shared<BlockDepSpec>(
"!" + stringify(s),
s,
@@ -1125,7 +1166,8 @@ Decider::_make_constraint_for_preloading(
}
const PackageDepSpec
-Decider::_make_spec_for_preloading(const PackageDepSpec & spec) const
+Decider::_make_spec_for_preloading(const PackageDepSpec & spec,
+ const std::shared_ptr<const ChangedChoices> & changed_choices) const
{
PartiallyMadePackageDepSpec result(spec);
@@ -1133,6 +1175,10 @@ Decider::_make_spec_for_preloading(const PackageDepSpec & spec) const
* [foo?] start to get weird when there's no longer an associated ID. */
result.clear_additional_requirements();
+ /* but we do want to impose our own ChangedChoices if necessary. */
+ if (changed_choices)
+ changed_choices->add_additional_requirements_to(result);
+
return result;
}
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index ded7b64..ca495b5 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -138,7 +138,9 @@ namespace paludis
const std::shared_ptr<const Decision> & d,
const std::shared_ptr<const Constraint> & c) const;
- const PackageDepSpec _make_spec_for_preloading(const PackageDepSpec & spec) const;
+ const PackageDepSpec _make_spec_for_preloading(
+ const PackageDepSpec & spec,
+ const std::shared_ptr<const ChangedChoices> &) const;
const std::shared_ptr<const PackageIDSequence> _find_replacing(
const std::shared_ptr<const PackageID> &,