aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-05 11:38:06 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-05 12:11:47 +0100
commit15946c2ee45cb169c0e85da18f4cccc4fad3ca8c (patch)
tree378cbf6c275b97f86409247ec58364a7d0bc7dcf
parent7e6a6b75c37cde0050e004df37871f0697a0321b (diff)
downloadpaludis-15946c2ee45cb169c0e85da18f4cccc4fad3ca8c.tar.gz
paludis-15946c2ee45cb169c0e85da18f4cccc4fad3ca8c.tar.xz
cave resolve --no-override-flags
-rw-r--r--paludis/resolver/decider.cc12
-rw-r--r--paludis/resolver/decider.hh3
-rw-r--r--paludis/resolver/resolver_functions.hh6
-rw-r--r--paludis/resolver/resolver_test.cc2
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc4
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh1
-rw-r--r--src/clients/cave/resolve_common.cc3
7 files changed, 29 insertions, 2 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 9aeb06b..5f5e874 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -646,6 +646,12 @@ Decider::_make_unmaskable_filter(const std::shared_ptr<const Resolution> & resol
return _imp->fns.make_unmaskable_filter_fn()(resolution);
}
+bool
+Decider::_allow_choice_changes_for(const std::shared_ptr<const Resolution> & resolution) const
+{
+ return _imp->fns.allow_choice_changes_fn()(resolution);
+}
+
const std::shared_ptr<const PackageIDSequence>
Decider::_find_replacing(
const std::shared_ptr<const PackageID> & id,
@@ -1118,7 +1124,8 @@ Decider::_made_wrong_decision(
std::shared_ptr<Resolution> adapted_resolution(std::make_shared<Resolution>(*resolution));
adapted_resolution->constraints()->add(constraint);
- const std::shared_ptr<Decision> decision(_try_to_find_decision_for(adapted_resolution, true, false, true, false));
+ const std::shared_ptr<Decision> decision(_try_to_find_decision_for(
+ adapted_resolution, _allow_choice_changes_for(resolution), false, true, false));
if (decision)
{
resolution->decision()->accept(WrongDecisionVisitor(std::bind(
@@ -1192,7 +1199,8 @@ Decider::_decide(const std::shared_ptr<Resolution> & resolution)
_copy_other_destination_constraints(resolution);
- std::shared_ptr<Decision> decision(_try_to_find_decision_for(resolution, true, false, true, false));
+ std::shared_ptr<Decision> decision(_try_to_find_decision_for(
+ resolution, _allow_choice_changes_for(resolution), false, true, false));
if (decision)
resolution->decision() = decision;
else
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index ca495b5..90299c8 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -183,6 +183,9 @@ namespace paludis
Filter _make_unmaskable_filter(
const std::shared_ptr<const Resolution> &) const;
+ bool _allow_choice_changes_for(
+ const std::shared_ptr<const Resolution> &) const;
+
void _decide(const std::shared_ptr<Resolution> & resolution);
void _copy_other_destination_constraints(const std::shared_ptr<Resolution> & resolution);
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index 5993efa..e129256 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -46,6 +46,7 @@ namespace paludis
{
namespace n
{
+ typedef Name<struct allow_choice_changes_fn_name> allow_choice_changes_fn;
typedef Name<struct allowed_to_remove_fn_name> allowed_to_remove_fn;
typedef Name<struct always_via_binary_fn_name> always_via_binary_fn;
typedef Name<struct can_use_fn_name> can_use_fn;
@@ -70,6 +71,10 @@ namespace paludis
namespace resolver
{
typedef std::function<bool (
+ const std::shared_ptr<const Resolution> &
+ )> AllowChoiceChangesFunction;
+
+ typedef std::function<bool (
const std::shared_ptr<const Resolution> &,
const std::shared_ptr<const PackageID> &
)> AllowedToRemoveFunction;
@@ -163,6 +168,7 @@ namespace paludis
struct ResolverFunctions
{
+ NamedValue<n::allow_choice_changes_fn, AllowChoiceChangesFunction> allow_choice_changes_fn;
NamedValue<n::allowed_to_remove_fn, AllowedToRemoveFunction> allowed_to_remove_fn;
NamedValue<n::always_via_binary_fn, AlwaysViaBinaryFunction> always_via_binary_fn;
NamedValue<n::can_use_fn, CanUseFunction> can_use_fn;
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 12a5682..5bd0ad2 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -39,6 +39,7 @@
#include <paludis/util/set-impl.hh>
#include <paludis/util/tribool.hh>
#include <paludis/util/simple_visitor_cast.hh>
+#include <paludis/util/return_literal_function.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repository_factory.hh>
#include <paludis/package_database.hh>
@@ -394,6 +395,7 @@ ResolverFunctions
ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraints)
{
return make_named_values<ResolverFunctions>(
+ n::allow_choice_changes_fn() = std::bind(return_literal_function(true)),
n::allowed_to_remove_fn() = std::bind(&allowed_to_remove_fn,
allowed_to_remove_names, std::placeholders::_1, std::placeholders::_2),
n::always_via_binary_fn() = &always_via_binary_fn,
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index c1438c2..1a4f6f7 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -73,6 +73,10 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
a_no_override_masks(&g_resolution_options, "no-override-masks", '\0',
"If otherwise unable to make a decision, unless this option is specified the resolver "
"will try packages that are weakly masked too.", true),
+ a_no_override_flags(&g_resolution_options, "no-override-flags", '\0',
+ "If otherwise unable to make a decision, unless this option is specified the resolver "
+ "will try selecting packages using different options to the ones specified in the user's "
+ "configuration.", true),
g_dependent_options(this, "Dependent Options", "Dependent options. A package is dependent if it "
"requires (or looks like it might require) a package which is being removed. By default, "
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index a2adadb..079414d 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -49,6 +49,7 @@ namespace paludis
args::StringSetArg a_permit_old_version;
args::StringSetArg a_purge;
args::SwitchArg a_no_override_masks;
+ args::SwitchArg a_no_override_flags;
args::ArgsGroup g_dependent_options;
args::StringSetArg a_uninstalls_may_break;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index f6afd6b..6d4dbdd 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -44,6 +44,7 @@
#include <paludis/util/set-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/util/return_literal_function.hh>
#include <paludis/args/do_help.hh>
#include <paludis/args/escape.hh>
#include <paludis/resolver/resolver.hh>
@@ -1941,6 +1942,8 @@ paludis::cave::resolve_common(
using std::placeholders::_4;
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
+ n::allow_choice_changes_fn() = std::bind(return_literal_function(
+ ! resolution_options.a_no_override_flags.specified())),
n::allowed_to_remove_fn() = std::bind(&allowed_to_remove_fn,
env.get(), std::cref(allowed_to_remove_specs), _1, _2),
n::always_via_binary_fn() = std::bind(&always_via_binary_fn,