aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-06 01:01:35 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-06 01:01:35 +0000
commit2f3c62c13c8e0655fc962d49ae9be70f713ba580 (patch)
tree04bceae04bf5a2176e72f8b0fc9a7899a42617bf
parent3d8bceb5a95a455eb6c1106686ac686a997cee6b (diff)
downloadpaludis-2f3c62c13c8e0655fc962d49ae9be70f713ba580.tar.gz
paludis-2f3c62c13c8e0655fc962d49ae9be70f713ba580.tar.xz
Delay metadata generation where possible. Fixes: ticket:379
-rw-r--r--paludis/dep_list.cc8
-rw-r--r--paludis/query-fwd.hh1
-rw-r--r--paludis/query.cc38
-rw-r--r--paludis/query.hh26
4 files changed, 71 insertions, 2 deletions
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index e22e9c8..1a86efd 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -26,6 +26,7 @@
#include <paludis/handled_information.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/action.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/distribution.hh>
#include <paludis/hashed_containers.hh>
@@ -384,13 +385,13 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
tr1::shared_ptr<const PackageID> best_visible_candidate;
tr1::shared_ptr<const PackageIDSequence> installable_candidates(
d->_imp->env->package_database()->query(
- query::SupportsAction<InstallAction>() &
+ query::MaybeSupportsAction<InstallAction>() &
query::Matches(a),
qo_order_by_version));
for (PackageIDSequence::ReverseConstIterator p(installable_candidates->rbegin()),
p_end(installable_candidates->rend()) ; p != p_end ; ++p)
- if (! (*p)->masked())
+ if ((*p)->supports_action(SupportsActionTest<InstallAction>()) && ! (*p)->masked())
{
best_visible_candidate = *p;
break;
@@ -408,6 +409,9 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
for (PackageIDSequence::ReverseConstIterator p(installable_candidates->rbegin()),
p_end(installable_candidates->rend()) ; p != p_end ; ++p)
{
+ if (! (*p)->supports_action(SupportsActionTest<InstallAction>()))
+ continue;
+
bool success(true);
for (PackageID::MasksConstIterator m((*p)->begin_masks()), m_end((*p)->end_masks()) ;
m != m_end ; ++m)
diff --git a/paludis/query-fwd.hh b/paludis/query-fwd.hh
index 552bcb7..71a244b 100644
--- a/paludis/query-fwd.hh
+++ b/paludis/query-fwd.hh
@@ -36,6 +36,7 @@ namespace paludis
class Category;
class NotMasked;
template <typename A_> class SupportsAction;
+ template <typename A_> class MaybeSupportsAction;
class InstalledAtRoot;
class All;
}
diff --git a/paludis/query.cc b/paludis/query.cc
index e87b944..0ff70eb 100644
--- a/paludis/query.cc
+++ b/paludis/query.cc
@@ -559,6 +559,32 @@ namespace
return result;
}
};
+
+ template <typename T_>
+ struct MaybeSupportsDelegate :
+ QueryDelegate
+ {
+ std::string
+ as_human_readable_string() const
+ {
+ return "maybe " + SupportsNames<T_>::name();
+ }
+
+ tr1::shared_ptr<RepositoryNameSequence>
+ repositories(const Environment & e) const
+ {
+ SupportsActionTest<T_> t;
+
+ tr1::shared_ptr<RepositoryNameSequence> result(new RepositoryNameSequence);
+
+ for (PackageDatabase::RepositoryConstIterator i(e.package_database()->begin_repositories()),
+ i_end(e.package_database()->end_repositories()) ; i != i_end ; ++i)
+ if ((*i)->some_ids_might_support_action(t))
+ result->push_back((*i)->name());
+
+ return result;
+ }
+ };
}
template <typename A_>
@@ -567,9 +593,21 @@ query::SupportsAction<A_>::SupportsAction() :
{
}
+template <typename A_>
+query::MaybeSupportsAction<A_>::MaybeSupportsAction() :
+ Query(tr1::shared_ptr<QueryDelegate>(new MaybeSupportsDelegate<A_>))
+{
+}
+
template class query::SupportsAction<InstallAction>;
template class query::SupportsAction<UninstallAction>;
template class query::SupportsAction<InstalledAction>;
template class query::SupportsAction<PretendAction>;
template class query::SupportsAction<ConfigAction>;
+template class query::MaybeSupportsAction<InstallAction>;
+template class query::MaybeSupportsAction<UninstallAction>;
+template class query::MaybeSupportsAction<InstalledAction>;
+template class query::MaybeSupportsAction<PretendAction>;
+template class query::MaybeSupportsAction<ConfigAction>;
+
diff --git a/paludis/query.hh b/paludis/query.hh
index d795532..f35b825 100644
--- a/paludis/query.hh
+++ b/paludis/query.hh
@@ -291,6 +291,32 @@ namespace paludis
};
/**
+ * Fetch packages that maybe support a particular action.
+ *
+ * A full SupportsAction<> on an ebuild ID requires a metadata load,
+ * since unsupported EAPIs don't support any actions. MaybeSupportsAction,
+ * on the other hand, only uses Repository::some_ids_might_support_action,
+ * so it does not incur a penalty but may return additional results.
+ *
+ * \see Query
+ * \see PackageDatabase::query
+ * \ingroup grpquery
+ * \nosubgrouping
+ */
+ template <typename A_>
+ class PALUDIS_VISIBLE MaybeSupportsAction :
+ public Query
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ MaybeSupportsAction();
+
+ ///\}
+ };
+
+ /**
* Fetch packages that are installed at a particular root.
*
* \see Query