aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-20 09:33:39 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-20 09:33:39 +0000
commit880aa65f4cdc0d583e54225ae3d1d6b52ebe79b6 (patch)
tree5169bd123ba56d80f4b7157ea994b82b56998779
parent54fce48d95fe491f7541e1a834160eebd0e54f4f (diff)
downloadpaludis-880aa65f4cdc0d583e54225ae3d1d6b52ebe79b6.tar.gz
paludis-880aa65f4cdc0d583e54225ae3d1d6b52ebe79b6.tar.xz
Take already taken suggestions
-rw-r--r--src/clients/cave/resolve_common.cc91
1 files changed, 49 insertions, 42 deletions
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 0c9723f..9ff647d 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -853,64 +853,71 @@ namespace
{
bool suggestion(is_suggestion(dep)), recommendation(is_recommendation(dep));
- if (suggestion || recommendation)
+ if (! (suggestion || recommendation))
+ return true;
+
+ for (args::StringSetArg::ConstIterator a(resolution_options.a_take.begin_args()),
+ a_end(resolution_options.a_take.end_args()) ;
+ a != a_end ; ++a)
{
- for (args::StringSetArg::ConstIterator a(resolution_options.a_take.begin_args()),
- a_end(resolution_options.a_take.end_args()) ;
- a != a_end ; ++a)
- {
- PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
- PackageDepSpec spec(*dep.spec().if_package());
- if (match_qpns(*env, user_spec, *spec.package_ptr()))
- return true;
- }
+ PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ PackageDepSpec spec(*dep.spec().if_package());
+ if (match_qpns(*env, user_spec, *spec.package_ptr()))
+ return true;
+ }
- for (args::StringSetArg::ConstIterator a(resolution_options.a_take_from.begin_args()),
- a_end(resolution_options.a_take_from.end_args()) ;
- a != a_end ; ++a)
- {
- PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
- if (match_qpns(*env, user_spec, resolvent.package()))
- return true;
- }
+ for (args::StringSetArg::ConstIterator a(resolution_options.a_take_from.begin_args()),
+ a_end(resolution_options.a_take_from.end_args()) ;
+ a != a_end ; ++a)
+ {
+ PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ if (match_qpns(*env, user_spec, resolvent.package()))
+ return true;
+ }
- for (args::StringSetArg::ConstIterator a(resolution_options.a_ignore.begin_args()),
- a_end(resolution_options.a_ignore.end_args()) ;
- a != a_end ; ++a)
- {
- PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
- PackageDepSpec spec(*dep.spec().if_package());
- if (match_qpns(*env, user_spec, *spec.package_ptr()))
- return false;
- }
+ for (args::StringSetArg::ConstIterator a(resolution_options.a_ignore.begin_args()),
+ a_end(resolution_options.a_ignore.end_args()) ;
+ a != a_end ; ++a)
+ {
+ PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ PackageDepSpec spec(*dep.spec().if_package());
+ if (match_qpns(*env, user_spec, *spec.package_ptr()))
+ return false;
+ }
- for (args::StringSetArg::ConstIterator a(resolution_options.a_ignore_from.begin_args()),
- a_end(resolution_options.a_ignore_from.end_args()) ;
- a != a_end ; ++a)
- {
- PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
- if (match_qpns(*env, user_spec, resolvent.package()))
- return false;
- }
+ for (args::StringSetArg::ConstIterator a(resolution_options.a_ignore_from.begin_args()),
+ a_end(resolution_options.a_ignore_from.end_args()) ;
+ a != a_end ; ++a)
+ {
+ PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ if (match_qpns(*env, user_spec, resolvent.package()))
+ return false;
}
+
if (suggestion)
{
if (resolution_options.a_suggestions.argument() == "take")
- {
return true;
- }
- return false;
}
+
if (recommendation)
{
if (resolution_options.a_recommendations.argument() == "take")
- {
return true;
- }
- return false;
}
- return true;
+ /* we also take suggestions and recommendations that have already been installed */
+ if (dep.spec().if_package())
+ {
+ const std::tr1::shared_ptr<const PackageIDSequence> installed_ids(
+ (*env)[selection::SomeArbitraryVersion(
+ generator::Matches(*dep.spec().if_package(), MatchPackageOptions()) |
+ filter::InstalledAtRoot(FSEntry("/")))]);
+ if (! installed_ids->empty())
+ return true;
+ }
+
+ return false;
}
const std::tr1::shared_ptr<const Repository>