aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-03 19:24:16 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-04 19:28:57 +0100
commit63559a5cc9adcfee5ac079066963ed13f85aec2c (patch)
treeac12faed4f96ffa25cb7c881ea2b0ece34874bf5
parentd4ba35d4f1c5077a5da393b12a3a03e0d4fcbdb4 (diff)
downloadpaludis-63559a5cc9adcfee5ac079066963ed13f85aec2c.tar.gz
paludis-63559a5cc9adcfee5ac079066963ed13f85aec2c.tar.xz
Show changed choices
-rw-r--r--src/clients/cave/cmd_display_resolution.cc20
-rw-r--r--src/clients/cave/resolve_common.cc50
2 files changed, 47 insertions, 23 deletions
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index 134cf94..7b6f74e 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -75,6 +75,7 @@
#include <paludis/action.hh>
#include <paludis/output_manager_from_environment.hh>
#include <paludis/output_manager.hh>
+#include <paludis/changed_choices.hh>
#include <set>
#include <iterator>
@@ -512,6 +513,7 @@ namespace
const std::shared_ptr<Environment> &,
const DisplayResolutionCommandLine & cmdline,
const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const ChangedChoices> & changed_choices,
const std::shared_ptr<const PackageID> & old_id,
ChoicesToExplain & choices_to_explain
)
@@ -555,8 +557,12 @@ namespace
if (! s.empty())
s.append(" ");
+ Tribool changed_state(indeterminate);
+ if (changed_choices)
+ changed_state = changed_choices->overridden_value((*i)->name_with_prefix());
+
std::string t;
- if ((*i)->enabled())
+ if ((changed_state.is_indeterminate() && (*i)->enabled()) || (changed_state.is_true()))
{
if ((*i)->locked())
t = formatter.format(**i, format::Forced());
@@ -597,6 +603,9 @@ namespace
t = formatter.decorate(**i, t, format::Added());
}
+ if (! changed_state.is_indeterminate())
+ t = t + c::bold_red() + " (!)" + c::normal();
+
s.append(t);
bool show_description;
@@ -623,7 +632,10 @@ namespace
if (s.empty())
return;
- cout << " " << s << endl;
+ if (changed_choices)
+ cout << " " << c::bold_red() << "Changes needed: " << c::normal() << s << endl;
+ else
+ cout << " " << s << endl;
}
void display_reasons(
@@ -1078,7 +1090,7 @@ namespace
if (! decision.best())
x = "-" + x;
- if (decision.origin_id()->masked())
+ if (decision.origin_id()->masked() || decision.if_changed_choices())
c = c::red();
else
do
@@ -1192,7 +1204,7 @@ namespace
old_id = *decision.destination()->replacing()->begin();
display_one_description(env, cmdline, decision.origin_id(), ! old_id);
- display_choices(env, cmdline, decision.origin_id(), old_id, choices_to_explain);
+ display_choices(env, cmdline, decision.origin_id(), decision.if_changed_choices(), old_id, choices_to_explain);
display_reasons(resolution, more_annotations);
display_masks(env, decision);
if (maybe_totals)
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index fac762c..bfec2cb 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -1159,34 +1159,40 @@ namespace
struct ChosenIDVisitor
{
- const std::shared_ptr<const PackageID> visit(const ChangesToMakeDecision & decision) const
+ const std::pair<std::shared_ptr<const PackageID>, std::shared_ptr<const ChangedChoices> > visit(
+ const ChangesToMakeDecision & decision) const
{
- return decision.origin_id();
+ return std::make_pair(decision.origin_id(), decision.if_changed_choices());
}
- const std::shared_ptr<const PackageID> visit(const BreakDecision & decision) const
+ const std::pair<std::shared_ptr<const PackageID>, std::shared_ptr<const ChangedChoices> > visit(
+ const BreakDecision & decision) const
{
- return decision.existing_id();
+ return std::make_pair(decision.existing_id(), make_null_shared_ptr());
}
- const std::shared_ptr<const PackageID> visit(const ExistingNoChangeDecision & decision) const
+ const std::pair<std::shared_ptr<const PackageID>, std::shared_ptr<const ChangedChoices> > visit(
+ const ExistingNoChangeDecision & decision) const
{
- return decision.existing_id();
+ return std::make_pair(decision.existing_id(), make_null_shared_ptr());
}
- const std::shared_ptr<const PackageID> visit(const NothingNoChangeDecision &) const
+ const std::pair<std::shared_ptr<const PackageID>, std::shared_ptr<const ChangedChoices> > visit(
+ const NothingNoChangeDecision &) const
{
- return make_null_shared_ptr();
+ return std::make_pair(make_null_shared_ptr(), make_null_shared_ptr());
}
- const std::shared_ptr<const PackageID> visit(const RemoveDecision &) const
+ const std::pair<std::shared_ptr<const PackageID>, std::shared_ptr<const ChangedChoices> > visit(
+ const RemoveDecision &) const
{
- return make_null_shared_ptr();
+ return std::make_pair(make_null_shared_ptr(), make_null_shared_ptr());
}
- const std::shared_ptr<const PackageID> visit(const UnableToMakeDecision &) const
+ const std::pair<std::shared_ptr<const PackageID>, std::shared_ptr<const ChangedChoices> > visit(
+ const UnableToMakeDecision &) const
{
- return make_null_shared_ptr();
+ return std::make_pair(make_null_shared_ptr(), make_null_shared_ptr());
}
};
@@ -1197,8 +1203,9 @@ namespace
const PackageDepSpecList & late,
const std::shared_ptr<const Resolution> & r)
{
- const std::shared_ptr<const PackageID> id(r->decision()->accept_returning<std::shared_ptr<const PackageID> >(
- ChosenIDVisitor()));
+ const std::shared_ptr<const PackageID> id(
+ r->decision()->accept_returning<std::pair<std::shared_ptr<const PackageID>, std::shared_ptr<const ChangedChoices> > >(
+ ChosenIDVisitor()).first);
if (id)
{
if (match_any(env, early, id))
@@ -1304,7 +1311,8 @@ namespace
{
return c->accept_returning<bool>(ConfirmFnVisitor(env, resolution_options, permit_downgrade, permit_old_version,
allowed_to_break_specs, allowed_to_break_system,
- r->decision()->accept_returning<std::shared_ptr<const PackageID> >(ChosenIDVisitor())
+ r->decision()->accept_returning<std::pair<std::shared_ptr<const PackageID>, std::shared_ptr<const ChangedChoices> > >(
+ ChosenIDVisitor()).first
));
}
@@ -1697,12 +1705,16 @@ namespace
std::cout << "* " << r->resolvent() << std::endl;
std::cout << " Had decided upon ";
- const std::shared_ptr<const PackageID> id(r->previous_decision()->accept_returning<
- std::shared_ptr<const PackageID> >(ChosenIDVisitor()));
- if (id)
- std::cout << *id;
+ auto c(r->previous_decision()->accept_returning<std::pair<std::shared_ptr<const PackageID>, std::shared_ptr<const ChangedChoices> > >(
+ ChosenIDVisitor()));
+ if (c.first)
+ std::cout << *c.first;
else
std::cout << r->previous_decision()->accept_returning<std::string>(KindNameVisitor());
+
+ if (c.second)
+ std::cout << " (with changed choices)";
+
std::cout << std::endl;
std::cout << " Which did not satisfy " << r->problematic_constraint()->spec()