aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-06 23:23:51 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-06 23:23:51 +0100
commit64413ad87a8eb2828e75627be1167df32f524771 (patch)
tree97e7845aed6ee17b176396c3c36d25ee582c61ae
parent3f942756991bd32971caad8e77940cdc2e50ea3f (diff)
downloadpaludis-64413ad87a8eb2828e75627be1167df32f524771.tar.gz
paludis-64413ad87a8eb2828e75627be1167df32f524771.tar.xz
Move some qpn:s ick into the resolver
-rw-r--r--paludis/resolver/resolver.cc31
-rw-r--r--paludis/resolver/resolver.hh4
-rw-r--r--src/clients/cave/cmd_resolve.cc108
3 files changed, 70 insertions, 73 deletions
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 88e6329..fe3ca88 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -262,7 +262,7 @@ Resolver::add_target_with_reason(const PackageDepSpec & spec, const std::tr1::sh
_imp->env->trigger_notifier_callback(NotifierCallbackResolverStepEvent());
- const std::tr1::shared_ptr<const QPN_S_Sequence> qpn_s_s(_imp->fns.get_qpn_s_s_for_fn()(spec, reason));
+ const std::tr1::shared_ptr<const QPN_S_Sequence> qpn_s_s(_get_qpn_s_s_for(spec, reason));
if (qpn_s_s->empty())
throw InternalError(PALUDIS_HERE, "not implemented: no slot for " + stringify(spec));
@@ -566,7 +566,7 @@ Resolver::_add_dependencies(const QPN_S & our_qpn_s, const std::tr1::shared_ptr<
std::tr1::shared_ptr<const QPN_S_Sequence> qpn_s_s;
if (s->spec().if_package())
- qpn_s_s = _imp->fns.get_qpn_s_s_for_fn()(*s->spec().if_package(), reason);
+ qpn_s_s = _get_qpn_s_s_for(*s->spec().if_package(), reason);
else
qpn_s_s = _get_qpn_s_s_for_blocker(*s->spec().if_block());
@@ -972,7 +972,7 @@ Resolver::find_any_score(const QPN_S & our_qpn_s, const SanitisedDependency & de
const std::tr1::shared_ptr<DependencyReason> reason(new DependencyReason(
_resolution_for_qpn_s(our_qpn_s)->decision()->if_package_id(), dep));
- const std::tr1::shared_ptr<const QPN_S_Sequence> qpn_s_s(_imp->fns.get_qpn_s_s_for_fn()(spec, reason));
+ const std::tr1::shared_ptr<const QPN_S_Sequence> qpn_s_s(_get_qpn_s_s_for(spec, reason));
/* next: will already be installing */
{
@@ -1105,6 +1105,31 @@ Resolver::_get_qpn_s_s_for_blocker(const BlockDepSpec & spec) const
return result;
}
+const std::tr1::shared_ptr<QPN_S_Sequence>
+Resolver::_get_qpn_s_s_for(
+ const PackageDepSpec & spec,
+ const std::tr1::shared_ptr<const Reason> & reason) const
+{
+ Context context("When finding slots for '" + stringify(spec) + "':");
+
+ std::tr1::shared_ptr<SlotName> exact_slot;
+
+ if (spec.slot_requirement_ptr())
+ {
+ SlotNameFinder f;
+ exact_slot = spec.slot_requirement_ptr()->accept_returning<std::tr1::shared_ptr<SlotName> >(f);
+ }
+
+ if (exact_slot)
+ {
+ std::tr1::shared_ptr<QPN_S_Sequence> result(new QPN_S_Sequence);
+ result->push_back(QPN_S(spec, exact_slot));
+ return result;
+ }
+ else
+ return _imp->fns.get_qpn_s_s_for_fn()(spec, reason);
+}
+
const std::tr1::shared_ptr<Decision>
Resolver::_try_to_find_decision_for(
const QPN_S & qpn_s,
diff --git a/paludis/resolver/resolver.hh b/paludis/resolver/resolver.hh
index 3d1ac0d..6cbbc46 100644
--- a/paludis/resolver/resolver.hh
+++ b/paludis/resolver/resolver.hh
@@ -56,6 +56,10 @@ namespace paludis
const std::tr1::shared_ptr<const QPN_S_Sequence> _get_qpn_s_s_for_blocker(const BlockDepSpec &) const;
+ const std::tr1::shared_ptr<QPN_S_Sequence> _get_qpn_s_s_for(
+ const PackageDepSpec & spec,
+ const std::tr1::shared_ptr<const Reason> & reason) const;
+
const std::tr1::shared_ptr<Constraint> _make_constraint_from_target(
const QPN_S &,
const PackageDepSpec &,
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index 436241f..c0e0fd0 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -305,24 +305,6 @@ namespace
return reason->accept_returning<bool>(v);
}
- struct SlotNameFinder
- {
- std::tr1::shared_ptr<SlotName> visit(const SlotExactRequirement & s)
- {
- return make_shared_ptr(new SlotName(s.slot()));
- }
-
- std::tr1::shared_ptr<SlotName> visit(const SlotAnyUnlockedRequirement &)
- {
- return make_null_shared_ptr();
- }
-
- std::tr1::shared_ptr<SlotName> visit(const SlotAnyLockedRequirement &)
- {
- return make_null_shared_ptr();
- }
- };
-
const std::tr1::shared_ptr<QPN_S_Sequence>
get_qpn_s_s_for_fn(const Environment * const env,
const ResolveCommandLine & cmdline,
@@ -330,68 +312,54 @@ namespace
const std::tr1::shared_ptr<const Reason> & reason)
{
std::tr1::shared_ptr<QPN_S_Sequence> result(new QPN_S_Sequence);
+ std::tr1::shared_ptr<QPN_S> best;
+ std::list<QPN_S> installed;
- std::tr1::shared_ptr<SlotName> exact_slot;
+ const std::tr1::shared_ptr<const PackageIDSequence> ids((*env)[selection::BestVersionOnly(
+ generator::Matches(spec, MatchPackageOptions() + mpo_ignore_additional_requirements) |
+ filter::SupportsAction<InstallAction>() |
+ filter::NotMasked())]);
- if (spec.slot_requirement_ptr())
- {
- SlotNameFinder f;
- exact_slot = spec.slot_requirement_ptr()->accept_returning<std::tr1::shared_ptr<SlotName> >(f);
- }
+ if (! ids->empty())
+ best = make_shared_ptr(new QPN_S(*ids->begin()));
- if (exact_slot)
- result->push_back(QPN_S(spec, exact_slot));
- else
- {
- std::tr1::shared_ptr<QPN_S> best;
- std::list<QPN_S> installed;
-
- const std::tr1::shared_ptr<const PackageIDSequence> ids((*env)[selection::BestVersionOnly(
- generator::Matches(spec, MatchPackageOptions() + mpo_ignore_additional_requirements) |
- filter::SupportsAction<InstallAction>() |
- filter::NotMasked())]);
-
- if (! ids->empty())
- best = make_shared_ptr(new QPN_S(*ids->begin()));
-
- const std::tr1::shared_ptr<const PackageIDSequence> installed_ids((*env)[selection::BestVersionInEachSlot(
- generator::Matches(spec, MatchPackageOptions()) |
- filter::SupportsAction<InstalledAction>())]);
+ const std::tr1::shared_ptr<const PackageIDSequence> installed_ids((*env)[selection::BestVersionInEachSlot(
+ generator::Matches(spec, MatchPackageOptions()) |
+ filter::SupportsAction<InstalledAction>())]);
- for (PackageIDSequence::ConstIterator i(installed_ids->begin()), i_end(installed_ids->end()) ;
- i != i_end ; ++i)
- installed.push_back(QPN_S(*i));
+ for (PackageIDSequence::ConstIterator i(installed_ids->begin()), i_end(installed_ids->end()) ;
+ i != i_end ; ++i)
+ installed.push_back(QPN_S(*i));
- const args::EnumArg & arg(is_target(reason) ? cmdline.resolution_options.a_target_slots : cmdline.resolution_options.a_slots);
+ const args::EnumArg & arg(is_target(reason) ? cmdline.resolution_options.a_target_slots : cmdline.resolution_options.a_slots);
- if (! best)
- std::copy(installed.begin(), installed.end(), result->back_inserter());
- else if (arg.argument() == "best-or-installed")
- {
- if (installed.end() == std::find(installed.begin(), installed.end(), *best))
- result->push_back(*best);
- else
- std::copy(installed.begin(), installed.end(), result->back_inserter());
- }
- else if (arg.argument() == "installed-or-best")
- {
- if (installed.empty())
- result->push_back(*best);
- else
- std::copy(installed.begin(), installed.end(), result->back_inserter());
- }
- else if (arg.argument() == "all")
- {
- if (installed.end() == std::find(installed.begin(), installed.end(), *best))
- result->push_back(*best);
+ if (! best)
+ std::copy(installed.begin(), installed.end(), result->back_inserter());
+ else if (arg.argument() == "best-or-installed")
+ {
+ if (installed.end() == std::find(installed.begin(), installed.end(), *best))
+ result->push_back(*best);
+ else
std::copy(installed.begin(), installed.end(), result->back_inserter());
- }
- else if (arg.argument() == "best")
+ }
+ else if (arg.argument() == "installed-or-best")
+ {
+ if (installed.empty())
result->push_back(*best);
else
- throw args::DoHelp("Don't understand argument '" + arg.argument() + "' to '--"
- + arg.long_name() + "'");
+ std::copy(installed.begin(), installed.end(), result->back_inserter());
}
+ else if (arg.argument() == "all")
+ {
+ if (installed.end() == std::find(installed.begin(), installed.end(), *best))
+ result->push_back(*best);
+ std::copy(installed.begin(), installed.end(), result->back_inserter());
+ }
+ else if (arg.argument() == "best")
+ result->push_back(*best);
+ else
+ throw args::DoHelp("Don't understand argument '" + arg.argument() + "' to '--"
+ + arg.long_name() + "'");
return result;
}