aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-24 17:31:31 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-24 17:31:31 +0000
commit75596a0c1bbcfe8e7eb1095a40a5911ba8056a6f (patch)
tree3fccdb2ea016fd2af6a13f8dbda9035d7d15d56c
parent393899ffc024d98549cc0009fffa22ac5b23ffa4 (diff)
downloadpaludis-75596a0c1bbcfe8e7eb1095a40a5911ba8056a6f.tar.gz
paludis-75596a0c1bbcfe8e7eb1095a40a5911ba8056a6f.tar.xz
Don't show duplicated constraints
-rw-r--r--src/clients/cave/cmd_display_resolution.cc38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index cc1d8b0..2729696 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -210,26 +210,27 @@ namespace
}
}
- void display_one_constraint(const Constraint & c)
+ const std::string constraint_as_string(const Constraint & c)
{
- cout << c.spec();
+ std::stringstream result;
+ result << c.spec();
switch (c.use_existing())
{
case ue_if_same:
- cout << ", use existing if same";
+ result << ", use existing if same";
break;
case ue_never:
- cout << ", never using existing";
+ result << ", never using existing";
break;
case ue_only_if_transient:
- cout << ", using existing only if transient";
+ result << ", using existing only if transient";
break;
case ue_if_same_version:
- cout << ", use existing if same version";
+ result << ", use existing if same version";
break;
case ue_if_possible:
- cout << ", use existing if possible";
+ result << ", use existing if possible";
break;
case last_ue:
@@ -239,16 +240,18 @@ namespace
switch (c.destination_type())
{
case dt_install_to_slash:
- cout << ", installing to /";
+ result << ", installing to /";
break;
case dt_create_binary:
- cout << ", creating a binary";
+ result << ", creating a binary";
break;
case last_dt:
break;
}
+
+ return result.str();
}
void display_explanation_constraints(const Constraints & constraints)
@@ -257,9 +260,7 @@ namespace
for (Constraints::ConstIterator c(constraints.begin()), c_end(constraints.end()) ;
c != c_end ; ++c)
{
- cout << " * ";
- display_one_constraint(**c);
- cout << endl;
+ cout << " * " << constraint_as_string(**c) << endl;
cout << " Because of ";
ReasonNameGetter g(true);
cout << (*c)->reason()->accept_returning<std::pair<std::string, bool> >(g).first;
@@ -640,16 +641,19 @@ namespace
m != m_end ; ++m)
cout << " Masked by " << (*m)->description() << endl;
+ std::set<std::string> duplicates;
for (Constraints::ConstIterator c(u->unmet_constraints()->begin()),
c_end(u->unmet_constraints()->end()) ;
c != c_end ; ++c)
{
- cout << " Did not meet ";
- display_one_constraint(**c);
-
ReasonNameGetter g(false);
- cout << " from " << (*c)->reason()->accept_returning<std::pair<std::string, bool> >(g).first;
- cout << endl;
+ std::string s(constraint_as_string(**c) + " from " +
+ (*c)->reason()->accept_returning<std::pair<std::string, bool> >(g).first);
+
+ if (! duplicates.insert(s).second)
+ continue;
+
+ cout << " Did not meet " << s << endl;
if ((*c)->spec().if_package() && (*c)->spec().if_package()->additional_requirements_ptr() &&
(! match_package(*env, *(*c)->spec().if_package(), *u->package_id(), MatchPackageOptions())) &&