aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-16 16:44:12 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-16 16:44:12 +0000
commit6458a000d4f6bff1ce7e5bebdfb5315a21975a2c (patch)
treea1bde7f2a98c1246fd566c89a52f41a015c12a1d
parent4eab7d7e2b713d92e7f3d050bd2f38c23fedeb5f (diff)
downloadpaludis-6458a000d4f6bff1ce7e5bebdfb5315a21975a2c.tar.gz
paludis-6458a000d4f6bff1ce7e5bebdfb5315a21975a2c.tar.xz
Allow pretends to be run with required confirmations
Fixes: ticket:1066
-rw-r--r--src/clients/cave/resolve_common.cc66
1 files changed, 62 insertions, 4 deletions
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 32a7c42..6ff20f4 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -65,6 +65,7 @@
#include <paludis/resolver/decisions.hh>
#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/resolutions_by_resolvent.hh>
+#include <paludis/resolver/required_confirmations.hh>
#include <paludis/resolver/allow_choice_changes_helper.hh>
#include <paludis/resolver/allowed_to_remove_helper.hh>
@@ -358,7 +359,8 @@ namespace
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)
+ 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<std::string>::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<bool>(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<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);
+ is_set, unconfirmed_but_allow_pretend);
}
catch (...)
{