aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-01 14:55:58 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-01 14:55:58 +0100
commit21e52c4a3b4dcab7202bc60507a8cb4371726d88 (patch)
tree65e8ae8d1fcb3f0c04a8503df222175db44230f3
parent51072c71da09484183734add55c067bf3e7e4e63 (diff)
downloadpaludis-21e52c4a3b4dcab7202bc60507a8cb4371726d88.tar.gz
paludis-21e52c4a3b4dcab7202bc60507a8cb4371726d88.tar.xz
Let origins be filtered too
-rw-r--r--paludis/resolver/decider.cc28
-rw-r--r--paludis/resolver/decider.hh10
-rw-r--r--paludis/resolver/resolver_functions.hh10
-rw-r--r--paludis/resolver/resolver_test.cc13
-rw-r--r--paludis/resolver/resolver_test.hh6
-rw-r--r--src/clients/cave/resolve_common.cc23
6 files changed, 73 insertions, 17 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 6cb4c42..2cdca19 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -512,9 +512,17 @@ Decider::_find_repository_for(
}
FilteredGenerator
-Decider::_make_destination_filtered_generator(const Generator & g, const Resolvent & resolvent) const
+Decider::_make_destination_filtered_generator(const Generator & g,
+ const std::tr1::shared_ptr<const Resolution> & resolution) const
+{
+ return _imp->fns.make_destination_filtered_generator_fn()(g, resolution);
+}
+
+FilteredGenerator
+Decider::_make_origin_filtered_generator(const Generator & g,
+ const std::tr1::shared_ptr<const Resolution> & resolution) const
{
- return _imp->fns.make_destination_filtered_generator_fn()(g, resolvent);
+ return _imp->fns.make_origin_filtered_generator_fn()(g, resolution);
}
const std::tr1::shared_ptr<const PackageIDSequence>
@@ -1404,7 +1412,7 @@ Decider::_try_to_find_decision_for(
if (resolution->constraints()->nothing_is_fine_too())
{
- const std::tr1::shared_ptr<const PackageIDSequence> existing_resolvent_ids(_installed_ids(resolution->resolvent()));
+ const std::tr1::shared_ptr<const PackageIDSequence> existing_resolvent_ids(_installed_ids(resolution));
if (existing_resolvent_ids->empty())
{
/* nothing existing, but nothing's ok */
@@ -1470,7 +1478,7 @@ Decider::_try_to_find_decision_for(
if (resolution->constraints()->nothing_is_fine_too() && _installed_but_allowed_to_remove(resolution))
return make_shared_ptr(new RemoveDecision(
resolution->resolvent(),
- _installed_ids(resolution->resolvent()),
+ _installed_ids(resolution),
! resolution->constraints()->all_untaken()
));
else
@@ -1619,14 +1627,14 @@ Decider::_make_unsuitable_candidate(
const std::tr1::shared_ptr<const PackageID>
Decider::_find_existing_id_for(const std::tr1::shared_ptr<const Resolution> & resolution) const
{
- const std::tr1::shared_ptr<const PackageIDSequence> ids(_installed_ids(resolution->resolvent()));
+ const std::tr1::shared_ptr<const PackageIDSequence> ids(_installed_ids(resolution));
return _find_id_for_from(resolution, ids).first;
}
bool
Decider::_installed_but_allowed_to_remove(const std::tr1::shared_ptr<const Resolution> & resolution) const
{
- const std::tr1::shared_ptr<const PackageIDSequence> ids(_installed_ids(resolution->resolvent()));
+ const std::tr1::shared_ptr<const PackageIDSequence> ids(_installed_ids(resolution));
if (ids->empty())
return false;
@@ -1650,11 +1658,11 @@ Decider::_remove_if_dependent(const std::tr1::shared_ptr<const PackageID> & id)
}
const std::tr1::shared_ptr<const PackageIDSequence>
-Decider::_installed_ids(const Resolvent & resolvent) const
+Decider::_installed_ids(const std::tr1::shared_ptr<const Resolution> & resolution) const
{
return (*_imp->env)[selection::AllVersionsSorted(
- _make_destination_filtered_generator(generator::Package(resolvent.package()), resolvent) |
- make_slot_filter(resolvent)
+ _make_destination_filtered_generator(generator::Package(resolution->resolvent().package()), resolution) |
+ make_slot_filter(resolution->resolvent())
)];
}
@@ -1664,7 +1672,7 @@ Decider::_find_installable_id_candidates_for(
const bool include_errors) const
{
return (*_imp->env)[selection::AllVersionsSorted(
- generator::Package(resolution->resolvent().package()) |
+ _make_origin_filtered_generator(generator::Package(resolution->resolvent().package()), resolution) |
make_slot_filter(resolution->resolvent()) |
filter::SupportsAction<InstallAction>() |
((! include_errors) ? Filter(filter::NotMasked()) : Filter(filter::All()))
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 23e984c..6bbe1c4 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -159,7 +159,13 @@ namespace paludis
const std::tr1::shared_ptr<const Resolution> & resolution,
const ChangesToMakeDecision &) const;
- FilteredGenerator _make_destination_filtered_generator(const Generator &, const Resolvent & resolvent) const;
+ FilteredGenerator _make_destination_filtered_generator(
+ const Generator &,
+ const std::tr1::shared_ptr<const Resolution> &) const;
+
+ FilteredGenerator _make_origin_filtered_generator(
+ const Generator &,
+ const std::tr1::shared_ptr<const Resolution> &) const;
void _decide(const std::tr1::shared_ptr<Resolution> & resolution);
void _copy_other_destination_constraints(const std::tr1::shared_ptr<Resolution> & resolution);
@@ -209,7 +215,7 @@ namespace paludis
const std::tr1::shared_ptr<const Resolution> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
const std::tr1::shared_ptr<const PackageIDSequence> _installed_ids(
- const Resolvent & resolvent) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const Resolution> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
bool _allowed_to_remove(
const std::tr1::shared_ptr<const Resolution> &,
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index 64a3b76..3e69941 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -58,6 +58,7 @@ namespace paludis
typedef Name<struct get_use_existing_fn_name> get_use_existing_fn;
typedef Name<struct interest_in_spec_fn_name> interest_in_spec_fn;
typedef Name<struct make_destination_filtered_generator_fn_name> make_destination_filtered_generator_fn;
+ typedef Name<struct make_origin_filtered_generator_fn_name> make_origin_filtered_generator_fn;
typedef Name<struct order_early_fn_name> order_early_fn;
typedef Name<struct prefer_or_avoid_fn_name> prefer_or_avoid_fn;
typedef Name<struct remove_if_dependent_fn_name> remove_if_dependent_fn;
@@ -125,9 +126,14 @@ namespace paludis
typedef std::tr1::function<FilteredGenerator (
const Generator &,
- const Resolvent &
+ const std::tr1::shared_ptr<const Resolution> &
)> MakeDestinationFilteredGeneratorFunction;
+ typedef std::tr1::function<FilteredGenerator (
+ const Generator &,
+ const std::tr1::shared_ptr<const Resolution> &
+ )> MakeOriginFilteredGeneratorFunction;
+
typedef std::tr1::function<Tribool (
const std::tr1::shared_ptr<const Resolution> &
)> OrderEarlyFunction;
@@ -155,6 +161,8 @@ namespace paludis
NamedValue<n::interest_in_spec_fn, InterestInSpecFunction> interest_in_spec_fn;
NamedValue<n::make_destination_filtered_generator_fn,
MakeDestinationFilteredGeneratorFunction> make_destination_filtered_generator_fn;
+ NamedValue<n::make_origin_filtered_generator_fn,
+ MakeOriginFilteredGeneratorFunction> make_origin_filtered_generator_fn;
NamedValue<n::order_early_fn, OrderEarlyFunction> order_early_fn;
NamedValue<n::prefer_or_avoid_fn, PreferOrAvoidFunction> prefer_or_avoid_fn;
NamedValue<n::remove_if_dependent_fn, RemoveIfDependentFunction> remove_if_dependent_fn;
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 77d72fc..9a87349 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -96,9 +96,10 @@ paludis::resolver::resolver_test::get_resolvents_for_fn(const PackageDepSpec & s
}
FilteredGenerator
-paludis::resolver::resolver_test::make_destination_filtered_generator_fn(const Generator & g, const Resolvent & resolvent)
+paludis::resolver::resolver_test::make_destination_filtered_generator_fn(const Generator & g,
+ const std::tr1::shared_ptr<const Resolution> & resolution)
{
- switch (resolvent.destination_type())
+ switch (resolution->resolvent().destination_type())
{
case dt_install_to_slash:
return g | filter::InstalledAtRoot(FSEntry("/"));
@@ -113,6 +114,13 @@ paludis::resolver::resolver_test::make_destination_filtered_generator_fn(const G
throw InternalError(PALUDIS_HERE, "unhandled dt");
}
+FilteredGenerator
+paludis::resolver::resolver_test::make_origin_filtered_generator_fn(const Generator & g,
+ const std::tr1::shared_ptr<const Resolution> &)
+{
+ return g;
+}
+
DestinationTypes
paludis::resolver::resolver_test::get_destination_types_for_fn(const PackageDepSpec &,
const std::tr1::shared_ptr<const PackageID> &,
@@ -354,6 +362,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
n::get_use_existing_fn() = &get_use_existing_fn,
n::interest_in_spec_fn() = &interest_in_spec_fn,
n::make_destination_filtered_generator_fn() = &make_destination_filtered_generator_fn,
+ n::make_origin_filtered_generator_fn() = &make_origin_filtered_generator_fn,
n::order_early_fn() = &order_early_fn,
n::prefer_or_avoid_fn() = std::tr1::bind(&prefer_or_avoid_fn,
prefer_or_avoid_names, std::tr1::placeholders::_1),
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 9d30961..ab0c0d6 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -92,7 +92,11 @@ namespace paludis
const std::tr1::shared_ptr<const Resolution> &,
const ChangesToMakeDecision &);
- FilteredGenerator make_destination_filtered_generator_fn(const Generator &, const Resolvent &);
+ FilteredGenerator make_destination_filtered_generator_fn(const Generator &,
+ const std::tr1::shared_ptr<const Resolution> &);
+
+ FilteredGenerator make_origin_filtered_generator_fn(const Generator &,
+ const std::tr1::shared_ptr<const Resolution> &);
DestinationTypes get_destination_types_for_fn(const PackageDepSpec &,
const std::tr1::shared_ptr<const PackageID> &,
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 41bc4c4..1009205 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -184,6 +184,25 @@ namespace
throw InternalError(PALUDIS_HERE, stringify(r.destination_type()));
}
+ FilteredGenerator make_destination_filtered_generator_with_resolution(
+ const Environment * const env,
+ const ResolveCommandLineResolutionOptions & resolution_options,
+ const std::tr1::shared_ptr<const Generator> & all_binary_repos_generator,
+ const Generator & g,
+ const std::tr1::shared_ptr<const Resolution> & r)
+ {
+ return make_destination_filtered_generator(env, resolution_options, all_binary_repos_generator, g, r->resolvent());
+ }
+
+ FilteredGenerator make_origin_filtered_generator(
+ const Environment * const,
+ const ResolveCommandLineResolutionOptions &,
+ const Generator & g,
+ const std::tr1::shared_ptr<const Resolution> &)
+ {
+ return g;
+ }
+
const std::tr1::shared_ptr<const Sequence<std::string> > add_resolver_targets(
const std::tr1::shared_ptr<Environment> & env,
const std::tr1::shared_ptr<Resolver> & resolver,
@@ -1699,8 +1718,10 @@ paludis::cave::resolve_common(
env.get(), std::tr1::cref(resolution_options), std::tr1::cref(take), std::tr1::cref(take_from),
std::tr1::cref(ignore), std::tr1::cref(ignore_from), std::tr1::cref(no_blockers_from),
std::tr1::cref(no_dependencies_from), _1, _2),
- n::make_destination_filtered_generator_fn() = std::tr1::bind(&make_destination_filtered_generator,
+ n::make_destination_filtered_generator_fn() = std::tr1::bind(&make_destination_filtered_generator_with_resolution,
env.get(), std::tr1::cref(resolution_options), all_binary_repos_generator, _1, _2),
+ n::make_origin_filtered_generator_fn() = std::tr1::bind(&make_origin_filtered_generator,
+ env.get(), std::tr1::cref(resolution_options), _1, _2),
n::order_early_fn() = std::tr1::bind(&order_early_fn,
env.get(), std::tr1::cref(resolution_options), std::tr1::cref(early), std::tr1::cref(late), _1),
n::prefer_or_avoid_fn() = std::tr1::bind(&prefer_or_avoid_fn,