aboutsummaryrefslogtreecommitdiff
path: root/src/clients/cave/resolve_common.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-23 11:08:08 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-23 11:08:08 +0100
commit7eab297e804d73548ac4c2cb6ad9145d095cdb34 (patch)
treeeed8e3a9d92e72686be411c9ef05d40c6a7df249 /src/clients/cave/resolve_common.cc
parent7be6e2a6a627f001d26784fc514f462d6bfb7a82 (diff)
downloadpaludis-7eab297e804d73548ac4c2cb6ad9145d095cdb34.tar.gz
paludis-7eab297e804d73548ac4c2cb6ad9145d095cdb34.tar.xz
Remove remove-if-dependent specs from world
Fixes: ticket:971
Diffstat (limited to 'src/clients/cave/resolve_common.cc')
-rw-r--r--src/clients/cave/resolve_common.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index eb87b4942..4b0fa66d0 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -62,6 +62,8 @@
#include <paludis/resolver/constraint.hh>
#include <paludis/resolver/resolver_functions.hh>
#include <paludis/resolver/decisions.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/resolutions_by_resolvent.hh>
#include <paludis/resolver/allow_choice_changes_helper.hh>
#include <paludis/resolver/allowed_to_remove_helper.hh>
@@ -268,6 +270,7 @@ namespace
const std::shared_ptr<const Map<std::string, std::string> > & keys_if_import,
const std::shared_ptr<const Sequence<std::pair<std::string, std::string> > > & targets,
const std::shared_ptr<const Sequence<std::string> > & world_specs,
+ const std::shared_ptr<const Sequence<std::string> > & removed_if_dependent_names,
const bool is_set)
{
Context context("When performing chosen resolution:");
@@ -311,6 +314,13 @@ namespace
args->push_back(*p);
}
+ for (auto p(removed_if_dependent_names->begin()), p_end(removed_if_dependent_names->end()) ;
+ p != p_end ; ++p)
+ {
+ args->push_back("--removed-if-dependent-names");
+ args->push_back(*p);
+ }
+
for (Sequence<std::pair<std::string, std::string> >::ConstIterator p(targets->begin()), p_end(targets->end()) ;
p != p_end ; ++p)
args->push_back(p->first);
@@ -521,6 +531,35 @@ namespace
throw args::DoHelp("Don't understand argument '" + arg.argument() + "' to '--"
+ arg.long_name() + "'");
}
+
+ std::shared_ptr<const QualifiedPackageName> name_if_dependent_remove(
+ const std::shared_ptr<const Resolution> & resolution)
+ {
+ const RemoveDecision * const remove_decision(simple_visitor_cast<const RemoveDecision>(*resolution->decision()));
+ if (remove_decision)
+ for (auto r(resolution->constraints()->begin()), r_end(resolution->constraints()->end()) ;
+ r != r_end ; ++r)
+ if (simple_visitor_cast<const DependentReason>(*(*r)->reason()))
+ return make_shared_copy((*remove_decision->ids()->begin())->name());
+ return make_null_shared_ptr();
+ }
+
+ std::shared_ptr<Sequence<std::string> > get_removed_if_dependent_names(
+ const Environment * const,
+ const std::shared_ptr<const Resolved> & resolved)
+ {
+ auto result(std::make_shared<Sequence<std::string> >());
+ for (auto d(resolved->taken_change_or_remove_decisions()->begin()),
+ d_end(resolved->taken_change_or_remove_decisions()->end()) ;
+ d != d_end ; ++d)
+ {
+ auto n(name_if_dependent_remove(*resolved->resolutions_by_resolvent()->find(d->first->resolvent())));
+ if (n)
+ result->push_back(stringify(*n));
+ }
+
+ return result;
+ }
}
int
@@ -861,6 +900,7 @@ paludis::cave::resolve_common(
execution_options, program_options, keys_if_import,
purge ? std::make_shared<const Sequence<std::pair<std::string, std::string> > >() : targets_if_not_purge,
world_specs_if_not_auto ? world_specs_if_not_auto : targets_cleaned_up,
+ get_removed_if_dependent_names(env.get(), resolver->resolved()),
is_set);
}
catch (...)