From 6458a000d4f6bff1ce7e5bebdfb5315a21975a2c Mon Sep 17 00:00:00 2001 From: Ciaran McCreesh Date: Thu, 16 Dec 2010 16:44:12 +0000 Subject: Allow pretends to be run with required confirmations Fixes: ticket:1066 --- src/clients/cave/resolve_common.cc | 66 +++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc index 32a7c425e..6ff20f44e 100644 --- a/src/clients/cave/resolve_common.cc +++ b/src/clients/cave/resolve_common.cc @@ -65,6 +65,7 @@ #include #include #include +#include #include #include @@ -358,7 +359,8 @@ namespace const std::shared_ptr > > & targets, const std::shared_ptr > & world_specs, const std::shared_ptr > & removed_if_dependent_names, - const bool is_set) + const bool is_set, + const bool pretend_only) { Context context("When performing chosen resolution:"); @@ -391,7 +393,7 @@ namespace } } - if (! resolution_options.a_execute.specified()) + if (pretend_only || ! resolution_options.a_execute.specified()) args->push_back("--pretend"); for (Sequence::ConstIterator p(world_specs->begin()), p_end(world_specs->end()) ; @@ -656,6 +658,49 @@ namespace else return env->package_database()->fetch_unique_qualified_package_name(PackageNamePart(s)); } + + struct AllowPretend + { + bool visit(const ChangedChoicesConfirmation &) const + { + return false; + } + + bool visit(const BreakConfirmation &) const + { + return true; + } + + bool visit(const DowngradeConfirmation &) const + { + return true; + } + + bool visit(const NotBestConfirmation &) const + { + return true; + } + + bool visit(const RemoveDecision &) const + { + return true; + } + + bool visit(const BreakDecision &) const + { + return true; + } + + bool visit(const MaskedConfirmation &) const + { + return true; + } + + bool visit(const RemoveSystemPackageConfirmation &) const + { + return true; + } + }; } int @@ -1041,20 +1086,33 @@ paludis::cave::resolve_common( if (! resolver->resolved()->taken_unable_to_make_decisions()->empty()) retcode |= 1; + bool unconfirmed_but_allow_pretend(false); if (! resolver->resolved()->taken_unconfirmed_decisions()->empty()) + { + unconfirmed_but_allow_pretend = true; + for (auto c(resolver->resolved()->taken_unconfirmed_decisions()->begin()), + c_end(resolver->resolved()->taken_unconfirmed_decisions()->end()) ; + c != c_end && unconfirmed_but_allow_pretend ; ++c) + if ((*c)->required_confirmations_if_any()) + for (auto r((*c)->required_confirmations_if_any()->begin()), + r_end((*c)->required_confirmations_if_any()->end()) ; + r != r_end && unconfirmed_but_allow_pretend ; ++r) + unconfirmed_but_allow_pretend &= (*r)->accept_returning(AllowPretend()); + retcode |= 2; + } if (! resolution_options.a_ignore_unorderable_jobs.specified()) if (! resolver->resolved()->taken_unorderable_decisions()->empty()) retcode |= 4; - if (0 == retcode) + if (0 == retcode || (2 == retcode && unconfirmed_but_allow_pretend)) return perform_resolution(env, resolver->resolved(), resolution_options, execution_options, program_options, keys_if_import, purge ? std::make_shared > >() : 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); + is_set, unconfirmed_but_allow_pretend); } catch (...) { -- cgit v1.2.1