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-22 19:16:52 +0100
commit3b6c0d2c842258d93c9c7a1087a6704085a4e5aa (patch)
treeaec4b5e06bdad0d54f3a5b739db7c0388fda9a51
parente9620d4142faf4f3aec5676e7b839a4e271ec438 (diff)
downloadpaludis-3b6c0d2c842258d93c9c7a1087a6704085a4e5aa.tar.gz
paludis-3b6c0d2c842258d93c9c7a1087a6704085a4e5aa.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 ce15174dc..bd7feb6d3 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;