aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-28 19:11:25 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-28 19:11:25 +0100
commitecfddcd86d78caa4010d377a136bfce99c507d63 (patch)
treeffab52b94f505f196a0e29c23703b33f58d47e49
parentbf6231959a758a9d17884d598d101d4e1a886a0b (diff)
downloadpaludis-ecfddcd86d78caa4010d377a136bfce99c507d63.tar.gz
paludis-ecfddcd86d78caa4010d377a136bfce99c507d63.tar.xz
Warn if not selecting the best candidate
-rw-r--r--paludis/resolver/decision.cc2
-rw-r--r--paludis/resolver/decision.hh2
-rw-r--r--paludis/resolver/resolver.cc26
-rw-r--r--paludis/resolver/resolver.hh8
-rw-r--r--src/clients/cave/cmd_resolve_display_resolution.cc4
5 files changed, 33 insertions, 9 deletions
diff --git a/paludis/resolver/decision.cc b/paludis/resolver/decision.cc
index 32ea044..3d3e675 100644
--- a/paludis/resolver/decision.cc
+++ b/paludis/resolver/decision.cc
@@ -35,6 +35,8 @@ paludis::resolver::operator<< (std::ostream & s, const Decision & d)
else
ss << "(nothing)";
+ if (d.is_best())
+ ss << ", is best";
if (d.is_installed())
ss << ", is installed";
if (d.is_nothing())
diff --git a/paludis/resolver/decision.hh b/paludis/resolver/decision.hh
index e4995dc..9bfac0f 100644
--- a/paludis/resolver/decision.hh
+++ b/paludis/resolver/decision.hh
@@ -29,6 +29,7 @@ namespace paludis
namespace n
{
struct if_package_id;
+ struct is_best;
struct is_installed;
struct is_nothing;
struct is_same;
@@ -41,6 +42,7 @@ namespace paludis
struct Decision
{
NamedValue<n::if_package_id, std::tr1::shared_ptr<const PackageID> > if_package_id;
+ NamedValue<n::is_best, bool> is_best;
NamedValue<n::is_installed, bool> is_installed;
NamedValue<n::is_nothing, bool> is_nothing;
NamedValue<n::is_same, bool> is_same;
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 70e964e..0313bc4 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -1099,13 +1099,16 @@ Resolver::_try_to_find_decision_for(
const std::tr1::shared_ptr<const Resolution> & resolution) const
{
const std::tr1::shared_ptr<const PackageID> installed_id(_find_installed_id_for(qpn_s, resolution));
- const std::tr1::shared_ptr<const PackageID> installable_id(_find_installable_id_for(qpn_s, resolution));
+ std::pair<const std::tr1::shared_ptr<const PackageID>, bool> installable_id_best(_find_installable_id_for(qpn_s, resolution));
+ const std::tr1::shared_ptr<const PackageID> installable_id(installable_id_best.first);
+ bool best(installable_id_best.second);
if (resolution->constraints()->nothing_is_fine_too() && ! installed_id)
{
/* nothing installed, but nothing's ok */
return make_shared_ptr(new Decision(make_named_values<Decision>(
value_for<n::if_package_id>(make_null_shared_ptr()),
+ value_for<n::is_best>(false),
value_for<n::is_installed>(false),
value_for<n::is_nothing>(true),
value_for<n::is_same>(false),
@@ -1118,6 +1121,7 @@ Resolver::_try_to_find_decision_for(
/* there's nothing suitable installed. */
return make_shared_ptr(new Decision(make_named_values<Decision>(
value_for<n::if_package_id>(installable_id),
+ value_for<n::is_best>(best),
value_for<n::is_installed>(false),
value_for<n::is_nothing>(false),
value_for<n::is_same>(false),
@@ -1151,6 +1155,7 @@ Resolver::_try_to_find_decision_for(
return make_shared_ptr(new Decision(make_named_values<Decision>(
value_for<n::if_package_id>(installed_id),
+ value_for<n::is_best>(false),
value_for<n::is_installed>(true),
value_for<n::is_nothing>(false),
value_for<n::is_same>(true),
@@ -1177,6 +1182,7 @@ Resolver::_try_to_find_decision_for(
case ui_never:
return make_shared_ptr(new Decision(make_named_values<Decision>(
value_for<n::if_package_id>(installable_id),
+ value_for<n::is_best>(best),
value_for<n::is_installed>(false),
value_for<n::is_nothing>(false),
value_for<n::is_same>(is_same),
@@ -1188,6 +1194,7 @@ Resolver::_try_to_find_decision_for(
if (is_same)
return make_shared_ptr(new Decision(make_named_values<Decision>(
value_for<n::if_package_id>(installed_id),
+ value_for<n::is_best>(false),
value_for<n::is_installed>(true),
value_for<n::is_nothing>(false),
value_for<n::is_same>(is_same),
@@ -1197,6 +1204,7 @@ Resolver::_try_to_find_decision_for(
else
return make_shared_ptr(new Decision(make_named_values<Decision>(
value_for<n::if_package_id>(installable_id),
+ value_for<n::is_best>(best),
value_for<n::is_installed>(false),
value_for<n::is_nothing>(false),
value_for<n::is_same>(is_same),
@@ -1208,6 +1216,7 @@ Resolver::_try_to_find_decision_for(
if (is_same_version)
return make_shared_ptr(new Decision(make_named_values<Decision>(
value_for<n::if_package_id>(installed_id),
+ value_for<n::is_best>(false),
value_for<n::is_installed>(true),
value_for<n::is_nothing>(false),
value_for<n::is_same>(is_same),
@@ -1217,6 +1226,7 @@ Resolver::_try_to_find_decision_for(
else
return make_shared_ptr(new Decision(make_named_values<Decision>(
value_for<n::if_package_id>(installable_id),
+ value_for<n::is_best>(best),
value_for<n::is_installed>(false),
value_for<n::is_nothing>(false),
value_for<n::is_same>(is_same),
@@ -1227,6 +1237,7 @@ Resolver::_try_to_find_decision_for(
case ui_if_possible:
return make_shared_ptr(new Decision(make_named_values<Decision>(
value_for<n::if_package_id>(installed_id),
+ value_for<n::is_best>(false),
value_for<n::is_installed>(true),
value_for<n::is_nothing>(false),
value_for<n::is_same>(is_same),
@@ -1251,10 +1262,10 @@ Resolver::_find_installed_id_for(const QPN_S & qpn_s, const std::tr1::shared_ptr
filter::SupportsAction<InstalledAction>()
)]);
- return _find_id_for_from(qpn_s, resolution, ids);
+ return _find_id_for_from(qpn_s, resolution, ids).first;
}
-const std::tr1::shared_ptr<const PackageID>
+const std::pair<const std::tr1::shared_ptr<const PackageID>, bool>
Resolver::_find_installable_id_for(const QPN_S & qpn_s, const std::tr1::shared_ptr<const Resolution> & resolution) const
{
const std::tr1::shared_ptr<const PackageIDSequence> ids((*_imp->env)[selection::AllVersionsSorted(
@@ -1267,11 +1278,12 @@ Resolver::_find_installable_id_for(const QPN_S & qpn_s, const std::tr1::shared_p
return _find_id_for_from(qpn_s, resolution, ids);
}
-const std::tr1::shared_ptr<const PackageID>
+const std::pair<const std::tr1::shared_ptr<const PackageID>, bool>
Resolver::_find_id_for_from(
const QPN_S &, const std::tr1::shared_ptr<const Resolution> & resolution,
const std::tr1::shared_ptr<const PackageIDSequence> & ids) const
{
+ bool best(true);
for (PackageIDSequence::ReverseConstIterator i(ids->rbegin()), i_end(ids->rend()) ;
i != i_end ; ++i)
{
@@ -1290,10 +1302,12 @@ Resolver::_find_id_for_from(
}
if (ok)
- return *i;
+ return std::make_pair(*i, best);
+
+ best = false;
}
- return make_null_shared_ptr();
+ return std::make_pair(make_null_shared_ptr(), false);
}
const std::tr1::shared_ptr<const Resolutions>
diff --git a/paludis/resolver/resolver.hh b/paludis/resolver/resolver.hh
index 12861e5..f32cbef 100644
--- a/paludis/resolver/resolver.hh
+++ b/paludis/resolver/resolver.hh
@@ -135,9 +135,11 @@ namespace paludis
const std::string _find_cycle(const QPN_S &, const int ignorable_pass) const;
- const std::tr1::shared_ptr<const PackageID> _find_installed_id_for(const QPN_S &, const std::tr1::shared_ptr<const Resolution> &) const;
- const std::tr1::shared_ptr<const PackageID> _find_installable_id_for(const QPN_S &, const std::tr1::shared_ptr<const Resolution> &) const;
- const std::tr1::shared_ptr<const PackageID> _find_id_for_from(
+ const std::tr1::shared_ptr<const PackageID> _find_installed_id_for(
+ const QPN_S &, const std::tr1::shared_ptr<const Resolution> &) const;
+ const std::pair<const std::tr1::shared_ptr<const PackageID>, bool> _find_installable_id_for(
+ const QPN_S &, const std::tr1::shared_ptr<const Resolution> &) const;
+ const std::pair<const std::tr1::shared_ptr<const PackageID>, bool> _find_id_for_from(
const QPN_S &, const std::tr1::shared_ptr<const Resolution> &,
const std::tr1::shared_ptr<const PackageIDSequence> &) const;
diff --git a/src/clients/cave/cmd_resolve_display_resolution.cc b/src/clients/cave/cmd_resolve_display_resolution.cc
index bd34216..8f0ad79 100644
--- a/src/clients/cave/cmd_resolve_display_resolution.cc
+++ b/src/clients/cave/cmd_resolve_display_resolution.cc
@@ -273,6 +273,10 @@ paludis::cave::display_resolution(
std::cout << join(reason_names.begin(), reason_names.end(), ", ");
}
+ if ((! (*c)->decision()->is_best()) && (! (*c)->decision()->is_nothing())
+ && (! (*c)->decision()->is_installed()))
+ std::cout << c::bold_red() << " which prevented selection of the best candidate";
+
std::cout << std::endl;
}
}