aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-05 00:21:06 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-05 00:21:06 +0000
commite43513525a96ea640e4cfbf2166ea140a081ed5b (patch)
tree9bc2d6999a3a62baa994bea86ff74fafde25862c
parente717dd4662672b9bd2028d175fdd864144e2b7fe (diff)
downloadpaludis-e43513525a96ea640e4cfbf2166ea140a081ed5b.tar.gz
paludis-e43513525a96ea640e4cfbf2166ea140a081ed5b.tar.xz
Make db->query take a third parameter describing how the result should be ordered. Keep the two arg db->query but mark it as deprecated
-rw-r--r--doc/examples/pwp_basic_cplusplus_app.cc2
-rw-r--r--paludis/dep_list/dep_list.cc8
-rw-r--r--paludis/dep_list/uninstall_list.cc2
-rw-r--r--paludis/environment/default/default_environment.cc2
-rw-r--r--paludis/package_database.cc56
-rw-r--r--paludis/package_database.hh29
-rw-r--r--paludis/package_database_TEST.cc51
-rw-r--r--paludis/qa/deps_exist_check.cc4
-rw-r--r--paludis/qa/deps_visible_check.cc2
-rw-r--r--paludis/repositories/portage/portage_repository.cc3
-rw-r--r--paludis/repositories/portage/portage_repository_news.cc3
-rw-r--r--paludis/repositories/portage/portage_repository_sets.cc8
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc2
-rw-r--r--paludis/tasks/install_task.cc2
-rw-r--r--paludis/tasks/report_task.cc2
-rw-r--r--paludis/tasks/uninstall_task.cc2
-rw-r--r--paludis/util/collection.hh10
-rw-r--r--paludis/util/collection_concrete.hh11
-rw-r--r--src/clients/adjutrix/find_insecure_packages.cc2
-rw-r--r--src/clients/adjutrix/find_reverse_deps.cc6
-rw-r--r--src/clients/contrarius/install.cc2
-rw-r--r--src/clients/contrarius/stage.cc11
-rw-r--r--src/clients/gtkpaludis/package_overview.cc6
-rw-r--r--src/clients/gtkpaludis/packages_list.cc4
-rw-r--r--src/clients/gtkpaludis/queue_list.cc4
-rw-r--r--src/clients/paludis/applets.cc8
-rw-r--r--src/clients/paludis/do_contents.cc2
-rw-r--r--src/clients/paludis/install.cc2
-rw-r--r--src/clients/paludis/query.cc4
-rw-r--r--src/output/console_install_task.cc5
30 files changed, 198 insertions, 57 deletions
diff --git a/doc/examples/pwp_basic_cplusplus_app.cc b/doc/examples/pwp_basic_cplusplus_app.cc
index 9151fe3..98ada3e 100644
--- a/doc/examples/pwp_basic_cplusplus_app.cc
+++ b/doc/examples/pwp_basic_cplusplus_app.cc
@@ -16,7 +16,7 @@ int main(int, char *[])
{
paludis::PackageDatabaseEntryCollection::ConstPointer packages(
paludis::DefaultEnvironment::get_instance()->package_database()->query(
- paludis::PackageDepAtom("app-editors/vim"), paludis::is_installed_only));
+ paludis::PackageDepAtom("app-editors/vim"), paludis::is_installed_only, paludis::qo_order_by_version));
if (packages->empty())
cout << "Vim is not installed" << endl;
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index a155c07..16ba657 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -268,7 +268,7 @@ DepList::QueryVisitor::visit(const PackageDepAtom * const a)
/* a pda matches either if we're already installed, or if we will be installed
* by the time the current point in the dep list is reached. */
- if (! d->_imp->env->package_database()->query(*a, is_installed_only)->empty())
+ if (! d->_imp->env->package_database()->query(*a, is_installed_only, qo_whatever)->empty())
result = true;
else if (d->_imp->merge_list.end() != std::find_if(
d->_imp->merge_list.begin(),
@@ -365,7 +365,7 @@ DepList::AddVisitor::visit(const PackageDepAtom * const a)
/* find already installed things */
PackageDatabaseEntryCollection::ConstPointer already_installed(d->_imp->env->package_database()->query(
- *a, is_installed_only));
+ *a, is_installed_only, qo_order_by_version));
/* are we already on the merge list? */
MergeList::iterator existing_merge_list_entry(std::find_if(d->_imp->merge_list.begin(),
@@ -407,7 +407,7 @@ DepList::AddVisitor::visit(const PackageDepAtom * const a)
/* find installable candidates, and find the best visible candidate */
const PackageDatabaseEntry * best_visible_candidate(0);
PackageDatabaseEntryCollection::ConstPointer installable_candidates(
- d->_imp->env->package_database()->query(*a, is_installable_only));
+ d->_imp->env->package_database()->query(*a, is_installable_only, qo_order_by_version));
for (PackageDatabaseEntryCollection::ReverseIterator p(installable_candidates->rbegin()),
p_end(installable_candidates->rend()) ; p != p_end ; ++p)
@@ -454,7 +454,7 @@ DepList::AddVisitor::visit(const PackageDepAtom * const a)
if (already_installed->empty() || ! can_fall_back)
{
if (a->use_requirements_ptr() && d->_imp->env->package_database()->query(
- *a->without_use_requirements(), is_any))
+ *a->without_use_requirements(), is_any, qo_whatever))
throw UseRequirementsNotMetError(stringify(*a));
else
throw AllMaskedError(stringify(*a));
diff --git a/paludis/dep_list/uninstall_list.cc b/paludis/dep_list/uninstall_list.cc
index 119cc1f..07071c9 100644
--- a/paludis/dep_list/uninstall_list.cc
+++ b/paludis/dep_list/uninstall_list.cc
@@ -325,7 +325,7 @@ namespace
void visit(const PackageDepAtom * const a)
{
PackageDatabaseEntryCollection::ConstPointer m(env->package_database()->query(
- *a, is_installed_only));
+ *a, is_installed_only, qo_order_by_version));
matches->insert(m->begin(), m->end());
}
diff --git a/paludis/environment/default/default_environment.cc b/paludis/environment/default/default_environment.cc
index fb0f3a4..7fbf96f 100644
--- a/paludis/environment/default/default_environment.cc
+++ b/paludis/environment/default/default_environment.cc
@@ -491,7 +491,7 @@ DefaultEnvironment::local_package_set(const SetName & s) const
{
PackageDepAtom::Pointer p(new PackageDepAtom(tokens.at(1)));
p->set_tag(tag);
- if (! package_database()->query(PackageDepAtom(p->package()), is_installed_only)->empty())
+ if (! package_database()->query(PackageDepAtom(p->package()), is_installed_only, qo_whatever)->empty())
result->add_child(p);
}
else
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index 943c5de..9bb4e4c 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -205,6 +205,13 @@ PackageDatabase::fetch_unique_qualified_package_name(
PackageDatabaseEntryCollection::Pointer
PackageDatabase::query(const PackageDepAtom & a, const InstallState installed_state) const
{
+ return query(a, installed_state, qo_order_by_version);
+}
+
+PackageDatabaseEntryCollection::Pointer
+PackageDatabase::query(const PackageDepAtom & a, const InstallState installed_state,
+ const QueryOrder query_order) const
+{
PackageDatabaseEntryCollection::Concrete::Pointer result(new PackageDatabaseEntryCollection::Concrete);
IndirectIterator<std::list<Repository::Pointer>::const_iterator, const Repository>
@@ -230,7 +237,29 @@ PackageDatabase::query(const PackageDepAtom & a, const InstallState installed_st
}
}
- _sort_package_database_entry_collection(*result);
+ do
+ {
+ switch (query_order)
+ {
+ case qo_order_by_version:
+ _sort_package_database_entry_collection(*result);
+ continue;
+
+ case qo_group_by_slot:
+ _sort_package_database_entry_collection(*result);
+ _group_package_database_entry_collection(*result);
+ continue;
+
+ case qo_whatever:
+ continue;
+
+ case last_query_order:
+ break;
+ };
+
+ throw InternalError(PALUDIS_HERE, "Bad query_order");
+ }
+ while (false);
return result;
}
@@ -360,6 +389,31 @@ PackageDatabase::_sort_package_database_entry_collection(PackageDatabaseEntryCol
p.sort(PDEComparator(this));
}
+void
+PackageDatabase::_group_package_database_entry_collection(PackageDatabaseEntryCollection::Concrete & p) const
+{
+ if (p.empty())
+ return;
+
+ for (std::list<PackageDatabaseEntry>::reverse_iterator r(p.list.rbegin()) ;
+ r != p.list.rend() ; ++r)
+ {
+ SlotName r_slot(fetch_repository(r->repository)->version_metadata(r->name, r->version)->slot);
+
+ for (std::list<PackageDatabaseEntry>::reverse_iterator rr(next(r)) ;
+ rr != p.list.rend() ; ++rr)
+ {
+ SlotName rr_slot(fetch_repository(rr->repository)->version_metadata(rr->name, rr->version)->slot);
+ if (rr_slot != r_slot)
+ continue;
+
+ p.list.splice(previous(r.base()), p.list, previous(rr.base()));
+ if (p.list.rend() == ((rr = ++r)))
+ return;
+ }
+ }
+}
+
PackageDatabase::RepositoryIterator
PackageDatabase::begin_repositories() const
{
diff --git a/paludis/package_database.hh b/paludis/package_database.hh
index b3cee9b..40d385f 100644
--- a/paludis/package_database.hh
+++ b/paludis/package_database.hh
@@ -197,7 +197,7 @@ namespace paludis
};
/**
- * Do we want installed, uninstalled or either when querying?
+ * Do we want installed, installable or either when querying?
*
* \ingroup grppackagedatabase
*/
@@ -210,6 +210,19 @@ namespace paludis
};
/**
+ * How to order query results.
+ *
+ * \ingroup grppackagedatabase
+ */
+ enum QueryOrder
+ {
+ qo_order_by_version, ///< By version
+ qo_group_by_slot, ///< By version, with like slots adjacent
+ qo_whatever, ///< No particular order
+ last_query_order
+ };
+
+ /**
* A PackageDatabase can be queried for Package instances.
*
* \ingroup grppackagedatabase
@@ -222,6 +235,8 @@ namespace paludis
private:
void _sort_package_database_entry_collection(
PackageDatabaseEntryCollection::Concrete &) const;
+ void _group_package_database_entry_collection(
+ PackageDatabaseEntryCollection::Concrete &) const;
public:
/**
@@ -271,10 +286,20 @@ namespace paludis
/**
* Query the repository.
+ *
+ * \deprecated Use the three argument form.
+ */
+ PackageDatabaseEntryCollection::Pointer query(
+ const PackageDepAtom & a,
+ const InstallState) const PALUDIS_ATTRIBUTE((deprecated));
+
+ /**
+ * Query the repository.
*/
PackageDatabaseEntryCollection::Pointer query(
const PackageDepAtom & a,
- const InstallState) const;
+ const InstallState,
+ const QueryOrder) const;
/**
* Return true if the first repository is more important than the second.
diff --git a/paludis/package_database_TEST.cc b/paludis/package_database_TEST.cc
index 7c552d7..cfe915b 100644
--- a/paludis/package_database_TEST.cc
+++ b/paludis/package_database_TEST.cc
@@ -114,39 +114,74 @@ namespace test_cases
TEST_CHECK(true);
PackageDepAtom d1("r1c1/r1c1p1");
- const PackageDatabaseEntryCollection::Pointer q1(p.query(d1, is_any));
+ const PackageDatabaseEntryCollection::Pointer q1(p.query(d1, is_any, qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q1->begin(), q1->end()), 1);
PackageDepAtom d2("r1c1/r1c1p2");
- const PackageDatabaseEntryCollection::Pointer q2(p.query(d2, is_any));
+ const PackageDatabaseEntryCollection::Pointer q2(p.query(d2, is_any, qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q2->begin(), q2->end()), 2);
PackageDepAtom d3(">=r1c1/r1c1p2-1");
- const PackageDatabaseEntryCollection::Pointer q3(p.query(d3, is_any));
+ const PackageDatabaseEntryCollection::Pointer q3(p.query(d3, is_any, qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q3->begin(), q3->end()), 2);
PackageDepAtom d4(">=r1c1/r1c1p2-2");
- const PackageDatabaseEntryCollection::Pointer q4(p.query(d4, is_any));
+ const PackageDatabaseEntryCollection::Pointer q4(p.query(d4, is_any, qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q4->begin(), q4->end()), 1);
PackageDepAtom d5(">=r1c1/r1c1p2-3");
- const PackageDatabaseEntryCollection::Pointer q5(p.query(d5, is_any));
+ const PackageDatabaseEntryCollection::Pointer q5(p.query(d5, is_any, qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q5->begin(), q5->end()), 0);
PackageDepAtom d6("<r1c1/r1c1p2-3");
- const PackageDatabaseEntryCollection::Pointer q6(p.query(d6, is_any));
+ const PackageDatabaseEntryCollection::Pointer q6(p.query(d6, is_any, qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q6->begin(), q6->end()), 2);
PackageDepAtom d7("rac1/rac1pa");
- const PackageDatabaseEntryCollection::Pointer q7(p.query(d7, is_any));
+ const PackageDatabaseEntryCollection::Pointer q7(p.query(d7, is_any, qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q7->begin(), q7->end()), 4);
PackageDepAtom d8("foo/bar");
- const PackageDatabaseEntryCollection::Pointer q8(p.query(d8, is_any));
+ const PackageDatabaseEntryCollection::Pointer q8(p.query(d8, is_any, qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q8->begin(), q8->end()), 0);
}
} package_database_query_test;
+ struct PackageDatabaseQueryOrderTest : TestCase
+ {
+ PackageDatabaseQueryOrderTest() : TestCase("package database query order") { }
+
+ void run()
+ {
+ TestEnvironment e;
+ PackageDatabase & p(*e.package_database());
+
+ FakeRepository::Pointer r1(new FakeRepository(RepositoryName("repo1")));
+ r1->add_version("cat", "pkg", "1")->slot = SlotName("a");
+ r1->add_version("cat", "pkg", "2")->slot = SlotName("c");
+ r1->add_version("cat", "pkg", "3")->slot = SlotName("c");
+ r1->add_version("cat", "pkg", "4")->slot = SlotName("a");
+ p.add_repository(r1);
+ TEST_CHECK(true);
+
+ FakeRepository::Pointer r2(new FakeRepository(RepositoryName("repo2")));
+ r2->add_version("cat", "pkg", "1")->slot = SlotName("a");
+ r2->add_version("cat", "pkg", "3")->slot = SlotName("b");
+ p.add_repository(r2);
+ TEST_CHECK(true);
+
+ PackageDepAtom d("cat/pkg");
+
+ const PackageDatabaseEntryCollection::Pointer q1(p.query(d, is_any, qo_order_by_version));
+ TEST_CHECK_EQUAL(join(q1->begin(), q1->end(), " "),
+ "cat/pkg-1::repo1 cat/pkg-1::repo2 cat/pkg-2::repo1 cat/pkg-3::repo1 cat/pkg-3::repo2 cat/pkg-4::repo1");
+
+ const PackageDatabaseEntryCollection::Pointer q2(p.query(d, is_any, qo_group_by_slot));
+ TEST_CHECK_EQUAL(join(q2->begin(), q2->end(), " "),
+ "cat/pkg-2::repo1 cat/pkg-3::repo1 cat/pkg-3::repo2 cat/pkg-1::repo1 cat/pkg-1::repo2 cat/pkg-4::repo1");
+ }
+ } package_database_query_order_test;
+
/**
* \test PackageDatabase disambiguate tests.
*
diff --git a/paludis/qa/deps_exist_check.cc b/paludis/qa/deps_exist_check.cc
index d453cb1..7d1a9d9 100644
--- a/paludis/qa/deps_exist_check.cc
+++ b/paludis/qa/deps_exist_check.cc
@@ -47,7 +47,7 @@ namespace
void visit(const PackageDepAtom * const p)
{
- if (env->package_database()->query(PackageDepAtom(p->package()), is_any)->empty())
+ if (env->package_database()->query(PackageDepAtom(p->package()), is_any, qo_whatever)->empty())
{
if (in_any)
result << Message(qal_maybe, "No match for " + role + " entry '"
@@ -77,7 +77,7 @@ namespace
void visit(const BlockDepAtom * const b)
{
- if (env->package_database()->query(*b->blocked_atom(), is_any)->empty())
+ if (env->package_database()->query(*b->blocked_atom(), is_any, qo_whatever)->empty())
result << Message(qal_maybe, "No match for " + role + " block '!"
+ stringify(*b->blocked_atom()) + "'");
}
diff --git a/paludis/qa/deps_visible_check.cc b/paludis/qa/deps_visible_check.cc
index 896264b..4739710 100644
--- a/paludis/qa/deps_visible_check.cc
+++ b/paludis/qa/deps_visible_check.cc
@@ -99,7 +99,7 @@ namespace
bool found(false);
std::string candidates;
PackageDatabaseEntryCollection::Pointer matches(env->package_database()->query(
- *p, is_any));
+ *p, is_any, qo_order_by_version));
for (PackageDatabaseEntryCollection::ReverseIterator m(matches->rbegin()),
m_end(matches->rend()) ; m != m_end ; ++m)
{
diff --git a/paludis/repositories/portage/portage_repository.cc b/paludis/repositories/portage/portage_repository.cc
index 4e1177f..ea11c7f 100644
--- a/paludis/repositories/portage/portage_repository.cc
+++ b/paludis/repositories/portage/portage_repository.cc
@@ -857,7 +857,8 @@ PortageRepository::info(bool verbose) const
i_end(info_pkgs.end()) ; i != i_end ; ++i)
{
PackageDatabaseEntryCollection::ConstPointer q(
- _imp->params.environment->package_database()->query(PackageDepAtom(*i), is_installed_only));
+ _imp->params.environment->package_database()->query(PackageDepAtom(*i), is_installed_only,
+ qo_order_by_version));
if (q->empty())
package_info->add_kv(*i, "(none)");
else
diff --git a/paludis/repositories/portage/portage_repository_news.cc b/paludis/repositories/portage/portage_repository_news.cc
index 6c21b75..b25affb 100644
--- a/paludis/repositories/portage/portage_repository_news.cc
+++ b/paludis/repositories/portage/portage_repository_news.cc
@@ -118,7 +118,8 @@ PortageRepositoryNews::update_news() const
bool local_show(false);
for (NewsFile::DisplayIfInstalledIterator i(news.begin_display_if_installed()),
i_end(news.end_display_if_installed()) ; i != i_end ; ++i)
- if (! _imp->environment->package_database()->query(PackageDepAtom(*i), is_installed_only)->empty())
+ if (! _imp->environment->package_database()->query(PackageDepAtom(*i), is_installed_only,
+ qo_whatever)->empty())
local_show = true;
show &= local_show;
}
diff --git a/paludis/repositories/portage/portage_repository_sets.cc b/paludis/repositories/portage/portage_repository_sets.cc
index bf5f9f6..5c0bbf9 100644
--- a/paludis/repositories/portage/portage_repository_sets.cc
+++ b/paludis/repositories/portage/portage_repository_sets.cc
@@ -122,7 +122,7 @@ PortageRepositorySets::package_set(const SetName & s) const
PackageDepAtom::Pointer p(new PackageDepAtom(tokens.at(1)));
p->set_tag(tag);
if (! _imp->environment->package_database()->query(PackageDepAtom(p->package()),
- is_installed_only)->empty())
+ is_installed_only, qo_whatever)->empty())
result->add_child(p);
}
else
@@ -295,7 +295,8 @@ PortageRepositorySets::security_set(bool insecurity) const
glsa_pkg_end(glsa->end_packages()) ; glsa_pkg != glsa_pkg_end ; ++glsa_pkg)
{
PackageDatabaseEntryCollection::ConstPointer candidates(_imp->environment->package_database()->query(
- PackageDepAtom(glsa_pkg->name()), insecurity ? is_any : is_installed_only));
+ PackageDepAtom(glsa_pkg->name()), insecurity ? is_any : is_installed_only,
+ qo_order_by_version));
for (PackageDatabaseEntryCollection::Iterator c(candidates->begin()), c_end(candidates->end()) ;
c != c_end ; ++c)
{
@@ -323,7 +324,8 @@ PortageRepositorySets::security_set(bool insecurity) const
c->repository)->version_metadata(c->name, c->version)->slot);
PackageDatabaseEntryCollection::ConstPointer available(
- _imp->environment->package_database()->query(PackageDepAtom(glsa_pkg->name()), is_installable_only));
+ _imp->environment->package_database()->query(PackageDepAtom(glsa_pkg->name()), is_installable_only,
+ qo_order_by_version));
for (PackageDatabaseEntryCollection::ReverseIterator r(available->rbegin()),
r_end(available->rend()) ; r != r_end ; ++r)
{
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index c984602..ed9d8d4 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -172,7 +172,7 @@ VirtualsRepository::need_entries() const
v(_imp->names.begin()), v_end(_imp->names.end()) ; v != v_end ; ++v)
{
PackageDatabaseEntryCollection::ConstPointer matches(_imp->env->package_database()->query(
- *v->second, is_installable_only));
+ *v->second, is_installable_only, qo_order_by_version));
if (matches->empty())
Log::get_instance()->message(ll_warning, lc_context, "No packages matching '"
diff --git a/paludis/tasks/install_task.cc b/paludis/tasks/install_task.cc
index d13b9ea..e111dcb 100644
--- a/paludis/tasks/install_task.cc
+++ b/paludis/tasks/install_task.cc
@@ -297,7 +297,7 @@ InstallTask::execute()
// look for packages with the same name in the same slot
PackageDatabaseEntryCollection::Pointer collision_list(_imp->env->package_database()->query(
PackageDepAtom(stringify(dep->package.name) + ":" + stringify(dep->metadata->slot)),
- is_installed_only));
+ is_installed_only, qo_order_by_version));
// don't clean the thing we just installed
PackageDatabaseEntryCollection::Concrete clean_list;
diff --git a/paludis/tasks/report_task.cc b/paludis/tasks/report_task.cc
index 7162efe..3f31acd 100644
--- a/paludis/tasks/report_task.cc
+++ b/paludis/tasks/report_task.cc
@@ -96,7 +96,7 @@ namespace
VulnerableChecker::visit(const PackageDepAtom * const a)
{
PackageDatabaseEntryCollection::ConstPointer insecure(
- _env.package_database()->query(*a, is_any));
+ _env.package_database()->query(*a, is_any, qo_order_by_version));
for (PackageDatabaseEntryCollection::Iterator i(insecure->begin()),
i_end(insecure->end()) ; i != i_end ; ++i)
if (a->tag())
diff --git a/paludis/tasks/uninstall_task.cc b/paludis/tasks/uninstall_task.cc
index 5d5e948..3f623dd 100644
--- a/paludis/tasks/uninstall_task.cc
+++ b/paludis/tasks/uninstall_task.cc
@@ -154,7 +154,7 @@ UninstallTask::execute()
Context local_context("When looking for target '" + stringify(**t) + "':");
PackageDatabaseEntryCollection::ConstPointer r(_imp->env->package_database()->query(
- **t, is_installed_only));
+ **t, is_installed_only, qo_order_by_version));
if (r->empty())
throw NoSuchPackageError(stringify(**t));
else if (next(r->begin()) != r->end())
diff --git a/paludis/util/collection.hh b/paludis/util/collection.hh
index 40368a0..718d066 100644
--- a/paludis/util/collection.hh
+++ b/paludis/util/collection.hh
@@ -123,6 +123,16 @@ namespace paludis
*/
virtual void push_back(const T_ & v) = 0;
+ /**
+ * Our insert iterator type.
+ */
+ typedef libwrapiter::OutputIterator<SequentialCollection<T_>, T_> Inserter;
+
+ /**
+ * Fetch an inserter.
+ */
+ virtual Inserter inserter() = 0;
+
///\}
///\name Queries
diff --git a/paludis/util/collection_concrete.hh b/paludis/util/collection_concrete.hh
index c5d560e..4fed4e5 100644
--- a/paludis/util/collection_concrete.hh
+++ b/paludis/util/collection_concrete.hh
@@ -52,11 +52,15 @@ namespace paludis
std::list<T_> _items;
public:
+ /// Access to the underlying data structure
+ std::list<T_> & list;
+
///\name Basic operations
///\{
Concrete() :
- SequentialCollection()
+ SequentialCollection(),
+ list(_items)
{
}
@@ -116,6 +120,11 @@ namespace paludis
return _items.empty();
}
+ virtual Inserter inserter()
+ {
+ return Inserter(std::back_inserter(_items));
+ }
+
///\name Extra functions
///\{
diff --git a/src/clients/adjutrix/find_insecure_packages.cc b/src/clients/adjutrix/find_insecure_packages.cc
index c68bb9e..f6a46ae 100644
--- a/src/clients/adjutrix/find_insecure_packages.cc
+++ b/src/clients/adjutrix/find_insecure_packages.cc
@@ -91,7 +91,7 @@ namespace
void visit(const PackageDepAtom * const a)
{
PackageDatabaseEntryCollection::ConstPointer insecure(
- _env.package_database()->query(*a, is_any));
+ _env.package_database()->query(*a, is_any, qo_order_by_version));
for (PackageDatabaseEntryCollection::Iterator i(insecure->begin()),
i_end(insecure->end()) ; i != i_end ; ++i)
if (a->tag())
diff --git a/src/clients/adjutrix/find_reverse_deps.cc b/src/clients/adjutrix/find_reverse_deps.cc
index 64ea746..cafa472 100644
--- a/src/clients/adjutrix/find_reverse_deps.cc
+++ b/src/clients/adjutrix/find_reverse_deps.cc
@@ -121,7 +121,7 @@ namespace
void
ReverseDepChecker::visit(const PackageDepAtom * const a)
{
- PackageDatabaseEntryCollection::ConstPointer dep_entries(_db->query(*a, is_any));
+ PackageDatabaseEntryCollection::ConstPointer dep_entries(_db->query(*a, is_any, qo_order_by_version));
PackageDatabaseEntryCollection::Pointer matches(new PackageDatabaseEntryCollection::Concrete);
bool header_written = false;
@@ -181,7 +181,7 @@ namespace
Context context("When checking package '" + stringify(p) + "':");
PackageDatabaseEntryCollection::Pointer p_entries(env.package_database()->query(
- PackageDepAtom(p), is_any));
+ PackageDepAtom(p), is_any, qo_order_by_version));
bool found_matches(false);
@@ -241,7 +241,7 @@ int do_find_reverse_deps(NoConfigEnvironment & env)
return 4;
}
- PackageDatabaseEntryCollection::Pointer entries(env.package_database()->query(*atom, is_any));
+ PackageDatabaseEntryCollection::Pointer entries(env.package_database()->query(*atom, is_any, qo_order_by_version));
int ret(0);
if (entries->empty())
diff --git a/src/clients/contrarius/install.cc b/src/clients/contrarius/install.cc
index c1df90d..5618a21 100644
--- a/src/clients/contrarius/install.cc
+++ b/src/clients/contrarius/install.cc
@@ -266,7 +266,7 @@ do_install(PackageDepAtom::ConstPointer atom)
{
PackageDatabaseEntryCollection::ConstPointer p(
DefaultEnvironment::get_instance()->package_database()->query(
- PackageDepAtom(e.query()), is_installable_only));
+ PackageDepAtom(e.query()), is_installable_only, qo_order_by_version));
if (p->empty())
{
diff --git a/src/clients/contrarius/stage.cc b/src/clients/contrarius/stage.cc
index 1a4d05c..c6f755a 100644
--- a/src/clients/contrarius/stage.cc
+++ b/src/clients/contrarius/stage.cc
@@ -72,7 +72,7 @@ bool
BinutilsStage::is_rebuild() const
{
return (! DefaultEnvironment::get_instance()->package_database()->query(
- *_options.binutils, is_installed_only)->empty());
+ *_options.binutils, is_installed_only, qo_whatever)->empty());
}
int
@@ -93,7 +93,7 @@ bool
KernelHeadersStage::is_rebuild() const
{
return (! DefaultEnvironment::get_instance()->package_database()->query(
- *_options.headers, is_installed_only)->empty());
+ *_options.headers, is_installed_only, qo_whatever)->empty());
}
int
@@ -129,7 +129,7 @@ bool
MinimalStage::is_rebuild() const
{
return (! DefaultEnvironment::get_instance()->package_database()->query(
- *_options.gcc, is_installed_only)->empty());
+ *_options.gcc, is_installed_only, qo_whatever)->empty());
}
int
@@ -147,7 +147,7 @@ LibCStage::is_rebuild() const
{
PackageDatabaseEntryCollection::ConstPointer c(
DefaultEnvironment::get_instance()->package_database()->query(
- *_options.libc, is_installed_only));
+ *_options.libc, is_installed_only, qo_whatever));
if (c->empty())
return false;
@@ -182,7 +182,8 @@ bool
FullStage::is_rebuild() const
{
PackageDatabaseEntryCollection::ConstPointer c(
- DefaultEnvironment::get_instance()->package_database()->query(*_options.gcc, is_installed_only));
+ DefaultEnvironment::get_instance()->package_database()->query(
+ *_options.gcc, is_installed_only, qo_whatever));
if (c->empty())
return false;
diff --git a/src/clients/gtkpaludis/package_overview.cc b/src/clients/gtkpaludis/package_overview.cc
index ce0ee0e..d5ef3ed 100644
--- a/src/clients/gtkpaludis/package_overview.cc
+++ b/src/clients/gtkpaludis/package_overview.cc
@@ -167,8 +167,10 @@ namespace
PackageDepAtom::Pointer atom(new PackageDepAtom(stringify(_pkg)));
PackageDatabaseEntryCollection::ConstPointer
- entries(DefaultEnvironment::get_instance()->package_database()->query(*atom, is_any)),
- preferred_entries(DefaultEnvironment::get_instance()->package_database()->query(*atom, is_installed_only));
+ entries(DefaultEnvironment::get_instance()->package_database()->query(
+ *atom, is_any, qo_order_by_version)),
+ preferred_entries(DefaultEnvironment::get_instance()->package_database()->query(
+ *atom, is_installed_only, qo_order_by_version));
if (preferred_entries->empty())
preferred_entries = entries;
diff --git a/src/clients/gtkpaludis/packages_list.cc b/src/clients/gtkpaludis/packages_list.cc
index 35f0d3f..ae9fd2b 100644
--- a/src/clients/gtkpaludis/packages_list.cc
+++ b/src/clients/gtkpaludis/packages_list.cc
@@ -160,12 +160,12 @@ namespace
bool is_installed(true);
PackageDatabaseEntryCollection::ConstPointer results(DefaultEnvironment::get_instance()->package_database()->query(
- PackageDepAtom(i->first), is_installed_only));
+ PackageDepAtom(i->first), is_installed_only, qo_order_by_version));
if (results->empty())
{
is_installed = false;
results = DefaultEnvironment::get_instance()->package_database()->query(
- PackageDepAtom(i->first), is_any);
+ PackageDepAtom(i->first), is_any, qo_order_by_version);
}
if (results->empty())
continue;
diff --git a/src/clients/gtkpaludis/queue_list.cc b/src/clients/gtkpaludis/queue_list.cc
index 950432d..1c9b5b8 100644
--- a/src/clients/gtkpaludis/queue_list.cc
+++ b/src/clients/gtkpaludis/queue_list.cc
@@ -337,7 +337,7 @@ QueueList::Populate::display_entry(const paludis::DepListEntry & e)
row[_q->_imp->columns.col_left] = left;
PackageDatabaseEntryCollection::Pointer existing(DefaultEnvironment::get_instance()->package_database()->
- query(PackageDepAtom(e.package.name), is_installed_only));
+ query(PackageDepAtom(e.package.name), is_installed_only, qo_order_by_version));
std::string right = stringify(e.package.version);
@@ -347,7 +347,7 @@ QueueList::Populate::display_entry(const paludis::DepListEntry & e)
{
existing = DefaultEnvironment::get_instance()->package_database()->query(PackageDepAtom(
stringify(e.package.name) + ":" + stringify(e.metadata->slot)),
- is_installed_only);
+ is_installed_only, qo_order_by_version);
if (existing->empty())
right.append(" [S]");
else if (existing->last()->version < e.package.version)
diff --git a/src/clients/paludis/applets.cc b/src/clients/paludis/applets.cc
index 3d9e84f..163c0e7 100644
--- a/src/clients/paludis/applets.cc
+++ b/src/clients/paludis/applets.cc
@@ -47,7 +47,7 @@ int do_has_version()
std::string query(*CommandLine::get_instance()->begin_parameters());
PackageDepAtom::Pointer atom(new PackageDepAtom(query));
PackageDatabaseEntryCollection::ConstPointer entries(env->package_database()->query(
- *atom, is_installed_only));
+ *atom, is_installed_only, qo_whatever));
if (entries->empty())
return_code = 1;
@@ -65,7 +65,7 @@ int do_best_version()
std::string query(*CommandLine::get_instance()->begin_parameters());
PackageDepAtom::Pointer atom(new PackageDepAtom(query));
PackageDatabaseEntryCollection::ConstPointer entries(env->package_database()->query(
- *atom, is_installed_only));
+ *atom, is_installed_only, qo_order_by_version));
/* make built_with_use work for virtuals... icky... */
while (! entries->empty())
@@ -112,10 +112,10 @@ int do_environment_variable()
PackageDepAtom::Pointer atom(new PackageDepAtom(atom_str));
PackageDatabaseEntryCollection::ConstPointer entries(env->package_database()->query(
- *atom, is_installed_only));
+ *atom, is_installed_only, qo_order_by_version));
if (entries->empty())
- entries = env->package_database()->query(*atom, is_any);
+ entries = env->package_database()->query(*atom, is_any, qo_order_by_version);
if (entries->empty())
throw NoSuchPackageError(atom_str);
diff --git a/src/clients/paludis/do_contents.cc b/src/clients/paludis/do_contents.cc
index 903cd5e..a1a6e88 100644
--- a/src/clients/paludis/do_contents.cc
+++ b/src/clients/paludis/do_contents.cc
@@ -95,7 +95,7 @@ do_one_contents(
new p::PackageDepAtom(q));
p::PackageDatabaseEntryCollection::ConstPointer
- entries(env->package_database()->query(*atom, p::is_installed_only));
+ entries(env->package_database()->query(*atom, p::is_installed_only, p::qo_order_by_version));
if (entries->empty())
throw p::NoSuchPackageError(q);
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index b1e716a..0583e05 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -459,7 +459,7 @@ do_install()
{
PackageDatabaseEntryCollection::ConstPointer p(
DefaultEnvironment::get_instance()->package_database()->query(
- PackageDepAtom(e.query()), is_installable_only));
+ PackageDepAtom(e.query()), is_installable_only, qo_order_by_version));
if (p->empty())
{
cout << endl;
diff --git a/src/clients/paludis/query.cc b/src/clients/paludis/query.cc
index 85c4e9b..38e3c07 100644
--- a/src/clients/paludis/query.cc
+++ b/src/clients/paludis/query.cc
@@ -47,8 +47,8 @@ void do_one_package_query(
/* prefer the best installed version, then the best visible version, then
* the best version */
PackageDatabaseEntryCollection::ConstPointer
- entries(env->package_database()->query(*atom, is_any)),
- preferred_entries(env->package_database()->query(*atom, is_installed_only));
+ entries(env->package_database()->query(*atom, is_any, qo_order_by_version)),
+ preferred_entries(env->package_database()->query(*atom, is_installed_only, qo_order_by_version));
if (entries->empty())
throw NoSuchPackageError(q);
if (preferred_entries->empty())
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 1171599..5d36dd3 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -161,10 +161,11 @@ ConsoleInstallTask::on_display_merge_list_entry(const DepListEntry & d)
return;
PackageDatabaseEntryCollection::Pointer existing(environment()->package_database()->
- query(PackageDepAtom(d.package.name), is_installed_only));
+ query(PackageDepAtom(d.package.name), is_installed_only, qo_order_by_version));
PackageDatabaseEntryCollection::Pointer existing_slot(environment()->package_database()->
- query(PackageDepAtom(stringify(d.package.name) + ":" + stringify(d.metadata->slot)), is_installed_only));
+ query(PackageDepAtom(stringify(d.package.name) + ":" + stringify(d.metadata->slot)),
+ is_installed_only, qo_order_by_version));
display_merge_list_entry_start(d);
display_merge_list_entry_package_name(d);