aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-21 17:15:04 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-21 17:15:04 +0100
commit6ad3da4d54ab976085c8f1d38629f7cfb3b5b3f3 (patch)
treea60e3077965d34206ee7cd85d76669dd1cca2554
parent621957c9424feaf862938185bd73f7421755aaf1 (diff)
downloadpaludis-6ad3da4d54ab976085c8f1d38629f7cfb3b5b3f3.tar.gz
paludis-6ad3da4d54ab976085c8f1d38629f7cfb3b5b3f3.tar.xz
Prefer 'weakly' masked IDs for 'cave show'
Given foo-1.2 that is keyword masked, and foo-9999 that is unavailable, pick foo-1.2 as the ID to show.
-rw-r--r--src/clients/cave/cmd_show.cc48
1 files changed, 46 insertions, 2 deletions
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index ce15174..bd7feb6 100644
--- a/src/clients/cave/cmd_show.cc
+++ b/src/clients/cave/cmd_show.cc
@@ -863,6 +863,34 @@ namespace
}
}
+ struct WeakMask
+ {
+ bool visit(const UnacceptedMask &) const
+ {
+ return true;
+ }
+
+ bool visit(const UserMask &) const
+ {
+ return false;
+ }
+
+ bool visit(const RepositoryMask &) const
+ {
+ return true;
+ }
+
+ bool visit(const UnsupportedMask &) const
+ {
+ return false;
+ }
+
+ bool visit(const AssociationMask &) const
+ {
+ return false;
+ }
+ };
+
void do_one_package(
const ShowCommandLine & cmdline,
const std::tr1::shared_ptr<Environment> & env,
@@ -875,7 +903,7 @@ namespace
if (ids->empty())
throw NothingMatching(s);
- std::tr1::shared_ptr<const PackageID> best_installable, best_masked_installable, best_not_installed;
+ std::tr1::shared_ptr<const PackageID> best_installable, best_weak_masked_installable, best_masked_installable, best_not_installed;
std::tr1::shared_ptr<PackageIDSequence> all_installed(new PackageIDSequence);
std::set<RepositoryName> repos;
for (PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ;
@@ -886,7 +914,21 @@ namespace
else if ((*i)->supports_action(SupportsActionTest<InstallAction>()))
{
if ((*i)->masked())
- best_masked_installable = *i;
+ {
+ bool weak_masked(true);
+ for (PackageID::MasksConstIterator m((*i)->begin_masks()), m_end((*i)->end_masks()) ;
+ m != m_end ; ++m)
+ if (! (*m)->accept_returning<bool>(WeakMask()))
+ {
+ weak_masked = false;
+ break;
+ }
+
+ if (weak_masked)
+ best_weak_masked_installable = *i;
+ else
+ best_masked_installable = *i;
+ }
else
best_installable = *i;
}
@@ -897,6 +939,8 @@ namespace
}
if (! best_installable)
+ best_installable = best_weak_masked_installable;
+ if (! best_installable)
best_installable = best_masked_installable;
if (! best_installable)
best_installable = best_not_installed;