diff options
author | 2012-04-14 20:21:53 +0100 | |
---|---|---|
committer | 2012-04-14 20:21:53 +0100 | |
commit | f0d23e3bdda8a4b5fab3b200ffc301c0d9c4a478 (patch) | |
tree | dc8b8da7a9f6041cfbc27843c0331e588075cff9 | |
parent | 18c2a993d873b6d8e92988ffc33d7659398e207a (diff) | |
download | paludis-f0d23e3bdda8a4b5fab3b200ffc301c0d9c4a478.tar.gz paludis-f0d23e3bdda8a4b5fab3b200ffc301c0d9c4a478.tar.xz |
Change || scoring
Fixes: ticket:1233
-rw-r--r-- | paludis/resolver/any_child_score.se | 1 | ||||
-rw-r--r-- | paludis/resolver/decider.cc | 54 | ||||
-rw-r--r-- | paludis/resolver/resolver_TEST_any.cc | 24 | ||||
-rwxr-xr-x | paludis/resolver/resolver_TEST_any_setup.sh | 21 |
4 files changed, 85 insertions, 15 deletions
diff --git a/paludis/resolver/any_child_score.se b/paludis/resolver/any_child_score.se index 76700e97b..18a386597 100644 --- a/paludis/resolver/any_child_score.se +++ b/paludis/resolver/any_child_score.se @@ -12,6 +12,7 @@ make_enum_AnyChildScore() key acs_blocks_installed "Blocks a currently-installed package" key acs_could_install "Could install" key acs_already_installed "Already installed" + key acs_could_install_and_installedish "Could install, and already installedish" key acs_vacuous_blocker "Blocker that doesn't match any installable packages" key acs_prefer "Explicitly preferred" key acs_better_than_best "Better than the best option" diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc index 0e1cd4a7e..970b67049 100644 --- a/paludis/resolver/decider.cc +++ b/paludis/resolver/decider.cc @@ -76,6 +76,7 @@ #include <paludis/util/pimp-impl.hh> +#include <list> #include <algorithm> #include <map> #include <set> @@ -1258,16 +1259,50 @@ Decider::find_any_score( our_id, make_null_shared_ptr(), our_resolution->resolvent(), dep, _package_dep_spec_already_met(*dep.spec().if_package(), our_id))); const std::shared_ptr<const Resolvents> resolvents_unless_block(is_block ? make_null_shared_ptr() : _get_resolvents_for(spec, reason_unless_block).first); + std::list<std::shared_ptr<Decision> > could_install_decisions; + for (Resolvents::ConstIterator r(resolvents_unless_block->begin()), r_end(resolvents_unless_block->end()) ; + r != r_end ; ++r) + { + const std::shared_ptr<Resolution> could_install_resolution(_create_resolution_for_resolvent(*r)); + const std::shared_ptr<ConstraintSequence> could_install_constraints(_make_constraints_from_dependency( + our_resolution, dep, reason_unless_block, si_take)); + for (ConstraintSequence::ConstIterator c(could_install_constraints->begin()), c_end(could_install_constraints->end()) ; + c != c_end ; ++c) + could_install_resolution->constraints()->add(*c); + auto could_install_decision(_try_to_find_decision_for(could_install_resolution, false, false, false, false, false)); + if (could_install_decision) + could_install_decisions.push_back(could_install_decision); + } + + /* next: could install, and something similar is installed */ + if (! is_block) + { + static_assert(acs_already_installed < acs_could_install_and_installedish, "acs order changed"); + + Context sub_context("When working out whether it's acs_could_install_and_installedish:"); + + for (auto c(could_install_decisions.begin()), c_end(could_install_decisions.end()) ; + c != c_end ; ++ c) + { + const auto installed_resolvent((*_imp->env)[selection::SomeArbitraryVersion( + generator::Package((*c)->resolvent().package()) | + make_slot_filter((*c)->resolvent()) | + filter::InstalledAtRoot(_imp->env->system_root_key()->parse_value()))]); + if (! installed_resolvent->empty()) + return std::make_pair(acs_could_install_and_installedish, operator_bias); + } + } /* next: already installed */ static_assert(acs_already_installed < acs_vacuous_blocker, "acs order changed"); { Context sub_context("When working out whether it's acs_already_installed:"); - const std::shared_ptr<const PackageIDSequence> installed_ids((*_imp->env)[selection::BestVersionOnly( + const std::shared_ptr<const PackageIDSequence> installed_id((*_imp->env)[selection::BestVersionOnly( generator::Matches(spec, our_id, { }) | filter::InstalledAtRoot(_imp->env->system_root_key()->parse_value()))]); - if (! installed_ids->empty() ^ is_block) + + if (! installed_id->empty() ^ is_block) return std::make_pair(acs_already_installed, operator_bias); } @@ -1275,19 +1310,8 @@ Decider::find_any_score( if (! is_block) { static_assert(acs_could_install < acs_already_installed, "acs order changed"); - for (Resolvents::ConstIterator r(resolvents_unless_block->begin()), r_end(resolvents_unless_block->end()) ; - r != r_end ; ++r) - { - const std::shared_ptr<Resolution> resolution(_create_resolution_for_resolvent(*r)); - const std::shared_ptr<ConstraintSequence> constraints(_make_constraints_from_dependency( - our_resolution, dep, reason_unless_block, si_take)); - for (ConstraintSequence::ConstIterator c(constraints->begin()), c_end(constraints->end()) ; - c != c_end ; ++c) - resolution->constraints()->add(*c); - const std::shared_ptr<Decision> decision(_try_to_find_decision_for(resolution, false, false, false, false, false)); - if (decision) - return std::make_pair(acs_could_install, operator_bias); - } + if (! could_install_decisions.empty()) + return std::make_pair(acs_could_install, operator_bias); } /* next: blocks installed package */ diff --git a/paludis/resolver/resolver_TEST_any.cc b/paludis/resolver/resolver_TEST_any.cc index 72422283c..03d86025e 100644 --- a/paludis/resolver/resolver_TEST_any.cc +++ b/paludis/resolver/resolver_TEST_any.cc @@ -320,3 +320,27 @@ TEST_F(ResolverAnyTestCase, SelfOrOther) ); } +TEST_F(ResolverAnyTestCase, UpgradeOverAny) +{ + data->install("upgrade-over-any", "dep", "1"); + + std::shared_ptr<const Resolved> resolved(data->get_resolved("upgrade-over-any/target")); + + check_resolved(resolved, + n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks() + .change(QualifiedPackageName("upgrade-over-any/dep")) + .change(QualifiedPackageName("upgrade-over-any/target")) + .finished()), + n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks() + .finished()), + n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks() + .finished()), + n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks() + .finished()), + n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks() + .finished()), + n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks() + .finished()) + ); +} + diff --git a/paludis/resolver/resolver_TEST_any_setup.sh b/paludis/resolver/resolver_TEST_any_setup.sh index 50ec27ce4..5630934f2 100755 --- a/paludis/resolver/resolver_TEST_any_setup.sh +++ b/paludis/resolver/resolver_TEST_any_setup.sh @@ -155,5 +155,26 @@ SLOT="0" DEPENDENCIES="" END +# upgrade-over-any +echo 'upgrade-over-any' >> metadata/categories.conf + +mkdir -p 'packages/upgrade-over-any/target' +cat <<END > packages/upgrade-over-any/target/target-1.exheres-0 +SUMMARY="target" +PLATFORMS="test" +SLOT="0" +DEPENDENCIES=" + || ( upgrade-over-any/dep[>=2] upgrade-over-any/dep[<2] ) + " +END + +mkdir -p 'packages/upgrade-over-any/dep' +cat <<END > packages/upgrade-over-any/dep/dep-2.exheres-0 +SUMMARY="dep" +PLATFORMS="test" +SLOT="0" +DEPENDENCIES="" +END + cd .. |