aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-07 14:42:16 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 10:53:07 +0100
commit4f3ae9c127c9865056a598b46716c8d12cdd6676 (patch)
tree330e43d8da8c2d50a413016652ee2a926341946b
parentb7d4756232923e0c4c97f8d56f3c47a3b950d62b (diff)
downloadpaludis-4f3ae9c127c9865056a598b46716c8d12cdd6676.tar.gz
paludis-4f3ae9c127c9865056a598b46716c8d12cdd6676.tar.xz
RemoveIfDependentHelper
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/remove_if_dependent_helper-fwd.hh31
-rw-r--r--paludis/resolver/remove_if_dependent_helper.cc68
-rw-r--r--paludis/resolver/remove_if_dependent_helper.hh53
-rw-r--r--paludis/resolver/resolver_TEST_continue_on_failure.cc3
-rw-r--r--paludis/resolver/resolver_TEST_uninstalls.cc2
-rw-r--r--paludis/resolver/resolver_test.cc15
-rw-r--r--paludis/resolver/resolver_test.hh7
-rw-r--r--src/clients/cave/resolve_common.cc26
9 files changed, 171 insertions, 36 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 4fedc61..93acab3 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -58,6 +58,7 @@ noinst_HEADERS = \
orderer_notes.hh orderer_notes-fwd.hh \
package_or_block_dep_spec.hh package_or_block_dep_spec-fwd.hh \
reason.hh reason-fwd.hh \
+ remove_if_dependent_helper.hh remove_if_dependent_helper-fwd.hh \
required_confirmations.hh required_confirmations-fwd.hh \
resolution.hh resolution-fwd.hh \
resolutions_by_resolvent.hh resolutions_by_resolvent-fwd.hh \
@@ -104,6 +105,7 @@ libpaludisresolver_a_SOURCES = \
orderer_notes.cc \
package_or_block_dep_spec.cc \
reason.cc \
+ remove_if_dependent_helper.cc \
required_confirmations.cc \
resolution.cc \
resolutions_by_resolvent.cc \
diff --git a/paludis/resolver/remove_if_dependent_helper-fwd.hh b/paludis/resolver/remove_if_dependent_helper-fwd.hh
new file mode 100644
index 0000000..769d46b
--- /dev/null
+++ b/paludis/resolver/remove_if_dependent_helper-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_REMOVE_IF_DEPENDENT_HELPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_REMOVE_IF_DEPENDENT_HELPER_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct RemoveIfDependentHelper;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/remove_if_dependent_helper.cc b/paludis/resolver/remove_if_dependent_helper.cc
new file mode 100644
index 0000000..7a8baa0
--- /dev/null
+++ b/paludis/resolver/remove_if_dependent_helper.cc
@@ -0,0 +1,68 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/resolver/remove_if_dependent_helper.hh>
+#include <paludis/resolver/reason.hh>
+#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/resolvent.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/package_dep_spec_collection.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Imp<RemoveIfDependentHelper>
+ {
+ const Environment * const env;
+ PackageDepSpecCollection remove_if_dependent_specs;
+
+ Imp(const Environment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+RemoveIfDependentHelper::RemoveIfDependentHelper(const Environment * const e) :
+ Pimp<RemoveIfDependentHelper>(e)
+{
+}
+
+RemoveIfDependentHelper::~RemoveIfDependentHelper() = default;
+
+void
+RemoveIfDependentHelper::add_remove_if_dependent_spec(const PackageDepSpec & spec)
+{
+ _imp->remove_if_dependent_specs.insert(spec);
+}
+
+bool
+RemoveIfDependentHelper::operator() (
+ const std::shared_ptr<const PackageID> & id) const
+{
+ return _imp->remove_if_dependent_specs.match_any(_imp->env, id, { });
+}
+
+template class Pimp<RemoveIfDependentHelper>;
+
diff --git a/paludis/resolver/remove_if_dependent_helper.hh b/paludis/resolver/remove_if_dependent_helper.hh
new file mode 100644
index 0000000..c479407
--- /dev/null
+++ b/paludis/resolver/remove_if_dependent_helper.hh
@@ -0,0 +1,53 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_REMOVE_IF_DEPENDENT_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_REMOVE_IF_DEPENDENT_HELPER_HH 1
+
+#include <paludis/resolver/remove_if_dependent_helper-fwd.hh>
+#include <paludis/resolver/resolution-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE RemoveIfDependentHelper :
+ private Pimp<RemoveIfDependentHelper>
+ {
+ public:
+ explicit RemoveIfDependentHelper(const Environment * const);
+ ~RemoveIfDependentHelper();
+
+ void add_remove_if_dependent_spec(const PackageDepSpec &);
+
+ bool operator() (
+ const std::shared_ptr<const PackageID> &) const;
+ };
+ }
+
+ extern template class Pimp<resolver::RemoveIfDependentHelper>;
+}
+
+#endif
diff --git a/paludis/resolver/resolver_TEST_continue_on_failure.cc b/paludis/resolver/resolver_TEST_continue_on_failure.cc
index 90d061d..10a9119 100644
--- a/paludis/resolver/resolver_TEST_continue_on_failure.cc
+++ b/paludis/resolver/resolver_TEST_continue_on_failure.cc
@@ -174,7 +174,8 @@ namespace test_cases
get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/target", &env, { }));
allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/needs-target", &env, { }));
- remove_if_dependent_names->insert(QualifiedPackageName("continue-on-failure-uninstall/needs-target"));
+
+ remove_if_dependent_helper.add_remove_if_dependent_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/needs-target", &env, { }));
}
void run()
diff --git a/paludis/resolver/resolver_TEST_uninstalls.cc b/paludis/resolver/resolver_TEST_uninstalls.cc
index fe1bffb..ac4c1c2 100644
--- a/paludis/resolver/resolver_TEST_uninstalls.cc
+++ b/paludis/resolver/resolver_TEST_uninstalls.cc
@@ -83,7 +83,7 @@ namespace test_cases
allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("breaking/target", &env, { }));
if (allowed_to_remove)
{
- remove_if_dependent_names->insert(QualifiedPackageName("breaking/dep"));
+ remove_if_dependent_helper.add_remove_if_dependent_spec(parse_user_package_dep_spec("breaking/dep", &env, { }));
allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("breaking/dep", &env, { }));
}
}
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 45b7318..c2f586b 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -188,14 +188,6 @@ paludis::resolver::resolver_test::get_use_existing_nothing_fn(
return std::make_pair(ue_never, false);
}
-bool
-paludis::resolver::resolver_test::remove_if_dependent_fn(
- const std::shared_ptr<const QualifiedPackageNameSet> & s,
- const std::shared_ptr<const PackageID> & i)
-{
- return s->end() != s->find(i->name());
-}
-
Tribool
paludis::resolver::resolver_test::prefer_or_avoid_fn(
const std::shared_ptr<const Map<QualifiedPackageName, bool> > & s,
@@ -218,7 +210,6 @@ paludis::resolver::resolver_test::order_early_fn(
ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s, const std::string & e,
const std::string & l) :
TestCase(s),
- remove_if_dependent_names(std::make_shared<QualifiedPackageNameSet>()),
prefer_or_avoid_names(std::make_shared<Map<QualifiedPackageName, bool>>()),
allow_choice_changes_helper(&env),
allowed_to_remove_helper(&env),
@@ -229,7 +220,8 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s,
get_constraints_for_dependent_helper(&env),
get_constraints_for_purge_helper(&env),
get_constraints_for_via_binary_helper(&env),
- get_destination_types_for_error_helper(&env)
+ get_destination_types_for_error_helper(&env),
+ remove_if_dependent_helper(&env)
{
std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
keys->insert("format", "e");
@@ -298,8 +290,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
n::order_early_fn() = &order_early_fn,
n::prefer_or_avoid_fn() = std::bind(&prefer_or_avoid_fn,
prefer_or_avoid_names, std::placeholders::_1),
- n::remove_if_dependent_fn() = std::bind(&remove_if_dependent_fn,
- remove_if_dependent_names, std::placeholders::_1)
+ n::remove_if_dependent_fn() = std::cref(remove_if_dependent_helper)
);
}
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 537e0f7..ff28bf8 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -45,6 +45,7 @@
#include <paludis/resolver/get_constraints_for_purge_helper.hh>
#include <paludis/resolver/get_constraints_for_via_binary_helper.hh>
#include <paludis/resolver/get_destination_types_for_error_helper.hh>
+#include <paludis/resolver/remove_if_dependent_helper.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -103,10 +104,6 @@ namespace paludis
Filter make_unmaskable_filter_fn(
const std::shared_ptr<const Resolution> &);
- bool remove_if_dependent_fn(
- const std::shared_ptr<const QualifiedPackageNameSet> &,
- const std::shared_ptr<const PackageID> &);
-
Tribool prefer_or_avoid_fn(
const std::shared_ptr<const Map<QualifiedPackageName, bool> > &,
const QualifiedPackageName &);
@@ -119,7 +116,6 @@ namespace paludis
TestEnvironment env;
std::shared_ptr<Repository> repo, inst_repo;
std::shared_ptr<FakeInstalledRepository> fake_inst_repo;
- std::shared_ptr<QualifiedPackageNameSet> remove_if_dependent_names;
std::shared_ptr<Map<QualifiedPackageName, bool> > prefer_or_avoid_names;
AllowChoiceChangesHelper allow_choice_changes_helper;
@@ -132,6 +128,7 @@ namespace paludis
GetConstraintsForPurgeHelper get_constraints_for_purge_helper;
GetConstraintsForViaBinaryHelper get_constraints_for_via_binary_helper;
GetDestinationTypesForErrorHelper get_destination_types_for_error_helper;
+ RemoveIfDependentHelper remove_if_dependent_helper;
ResolverTestCase(const std::string & group, const std::string & test_name, const std::string & eapi,
const std::string & layout);
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index d8cb260..9522df6 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -75,6 +75,7 @@
#include <paludis/resolver/get_constraints_for_purge_helper.hh>
#include <paludis/resolver/get_constraints_for_via_binary_helper.hh>
#include <paludis/resolver/get_destination_types_for_error_helper.hh>
+#include <paludis/resolver/remove_if_dependent_helper.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
@@ -1063,14 +1064,6 @@ namespace
return false;
}
- bool remove_if_dependent_fn(
- const Environment * const env,
- const PackageDepSpecList & list,
- const std::shared_ptr<const PackageID> & i)
- {
- return match_any(env, list, i);
- }
-
bool prefer_or_avoid_one(const Environment * const, const QualifiedPackageName & q, const PackageDepSpec & s)
{
Context context("When working out whether we favour or avoid '" + stringify(q) + "' due to '"
@@ -1483,15 +1476,9 @@ paludis::cave::resolve_common(
int retcode(0);
InitialConstraints initial_constraints;
- PackageDepSpecList remove_if_dependent_specs, with, without, take, take_from, ignore, ignore_from,
+ PackageDepSpecList with, without, take, take_from, ignore, ignore_from,
favour, avoid, early, late, no_dependencies_from, no_blockers_from;
- for (args::StringSetArg::ConstIterator i(resolution_options.a_remove_if_dependent.begin_args()),
- i_end(resolution_options.a_remove_if_dependent.end_args()) ;
- i != i_end ; ++i)
- remove_if_dependent_specs.push_back(parse_user_package_dep_spec(*i, env.get(),
- { updso_allow_wildcards }));
-
for (args::StringSetArg::ConstIterator i(resolution_options.a_without.begin_args()),
i_end(resolution_options.a_without.end_args()) ;
i != i_end ; ++i)
@@ -1689,6 +1676,12 @@ paludis::cave::resolve_common(
throw args::DoHelp("Don't understand argument '" + resolution_options.a_make.argument() + "' to '--"
+ resolution_options.a_make.long_name() + "'");
+ RemoveIfDependentHelper remove_if_dependent_helper(env.get());
+ for (args::StringSetArg::ConstIterator i(resolution_options.a_remove_if_dependent.begin_args()),
+ i_end(resolution_options.a_remove_if_dependent.end_args()) ;
+ i != i_end ; ++i)
+ remove_if_dependent_helper.add_remove_if_dependent_spec(parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
n::allow_choice_changes_fn() = std::cref(allow_choice_changes_helper),
n::allowed_to_remove_fn() = std::cref(allowed_to_remove_helper),
@@ -1721,8 +1714,7 @@ paludis::cave::resolve_common(
env.get(), std::cref(resolution_options), std::cref(early), std::cref(late), _1),
n::prefer_or_avoid_fn() = std::bind(&prefer_or_avoid_fn,
env.get(), std::cref(resolution_options), std::cref(favour), std::cref(avoid), _1),
- n::remove_if_dependent_fn() = std::bind(&remove_if_dependent_fn,
- env.get(), std::cref(remove_if_dependent_specs), _1)
+ n::remove_if_dependent_fn() = std::cref(remove_if_dependent_helper)
));
ScopedSelectionCache selection_cache(env.get());