aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-03 22:14:30 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-03 22:14:30 +0000
commitb6f74117d4190c9c309d02410e230a187d0ea4c8 (patch)
tree11ea4a2da1a2a00c8f30c3a7b3ad197cdd3868bc
parent22e52949359f6c39155ab86680d1b3b5cb7d901e (diff)
downloadpaludis-b6f74117d4190c9c309d02410e230a187d0ea4c8.tar.gz
paludis-b6f74117d4190c9c309d02410e230a187d0ea4c8.tar.xz
Don't try to install installed packages.
-rw-r--r--paludis/dep_list.cc4
-rw-r--r--paludis/package_database.cc27
-rw-r--r--paludis/package_database.hh31
-rw-r--r--paludis/package_database_TEST.cc16
-rw-r--r--src/query.cc3
5 files changed, 36 insertions, 45 deletions
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 3327621..287a538 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -313,7 +313,7 @@ DepList::visit(const PackageDepAtom * const p)
Context context("When resolving package dependency '" + stringify(*p) + "':");
PackageDatabaseEntryCollection::ConstPointer installed(
- _imp->environment->package_database()->query_installed(p));
+ _imp->environment->package_database()->query(p, is_installed_only));
/* are we already on the merge list? */
{
@@ -353,7 +353,7 @@ DepList::visit(const PackageDepAtom * const p)
VersionMetadata::ConstPointer metadata(0);
PackageDatabaseEntryCollection::Pointer matches(0);
- matches = _imp->environment->package_database()->query(p);
+ matches = _imp->environment->package_database()->query(p, is_uninstalled_only);
for (PackageDatabaseEntryCollection::ReverseIterator e(matches->rbegin()),
e_end(matches->rend()) ; e != e_end ; ++e)
{
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index ac321a4..c6566cd 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -160,7 +160,7 @@ PackageDatabase::fetch_unique_qualified_package_name(
}
PackageDatabaseEntryCollection::Pointer
-PackageDatabase::_do_query(const PackageDepAtom * const a, bool installed_only) const
+PackageDatabase::_do_query(const PackageDepAtom * const a, const InstallState installed_state) const
{
PackageDatabaseEntryCollection::Pointer result(new PackageDatabaseEntryCollection);
@@ -169,7 +169,10 @@ PackageDatabase::_do_query(const PackageDepAtom * const a, bool installed_only)
r_end(_imp->repositories.end());
for ( ; r != r_end ; ++r)
{
- if (installed_only && ! r->installed())
+ if ((installed_state == is_installed_only) && ! r->installed())
+ continue;
+
+ if ((installed_state == is_uninstalled_only) && r->installed())
continue;
if (! r->has_category_named(a->package().get<qpn_category>()))
@@ -194,15 +197,9 @@ PackageDatabase::_do_query(const PackageDepAtom * const a, bool installed_only)
}
PackageDatabaseEntryCollection::Pointer
-PackageDatabase::query(const PackageDepAtom * const a) const
-{
- return _do_query(a, false);
-}
-
-PackageDatabaseEntryCollection::Pointer
-PackageDatabase::query_installed(const PackageDepAtom * const a) const
+PackageDatabase::query(const PackageDepAtom * const a, const InstallState s) const
{
- return _do_query(a, true);
+ return _do_query(a, s);
}
const RepositoryName &
@@ -233,15 +230,9 @@ PackageDatabase::favourite_repository() const
}
PackageDatabaseEntryCollection::Pointer
-PackageDatabase::query(PackageDepAtom::ConstPointer a) const
-{
- return query(a.raw_pointer());
-}
-
-PackageDatabaseEntryCollection::Pointer
-PackageDatabase::query_installed(PackageDepAtom::ConstPointer a) const
+PackageDatabase::query(PackageDepAtom::ConstPointer a, const InstallState s) const
{
- return query_installed(a.raw_pointer());
+ return _do_query(a.raw_pointer(), s);
}
PackageDatabase::RepositoryIterator
diff --git a/paludis/package_database.hh b/paludis/package_database.hh
index 0e442b5..64c2177 100644
--- a/paludis/package_database.hh
+++ b/paludis/package_database.hh
@@ -184,6 +184,16 @@ namespace paludis
};
/**
+ * Do we want installed, uninstalled or either?
+ */
+ enum InstallState
+ {
+ is_installed_only, ///< Installed only
+ is_uninstalled_only, ///< Uninstalled only
+ is_either ///< Either
+ };
+
+ /**
* A PackageDatabase can be queried for Package instances.
*/
class PackageDatabase :
@@ -193,7 +203,7 @@ namespace paludis
{
private:
PackageDatabaseEntryCollection::Pointer _do_query(
- const PackageDepAtom * const a, bool installed_only) const;
+ const PackageDepAtom * const a, const InstallState) const;
public:
/**
@@ -242,26 +252,15 @@ namespace paludis
* Query the repository.
*/
PackageDatabaseEntryCollection::Pointer query(
- const PackageDepAtom * const a) const;
+ const PackageDepAtom * const a,
+ const InstallState) const;
/**
* Query the repository (overload for a CountedPtr)
*/
PackageDatabaseEntryCollection::Pointer query(
- PackageDepAtom::ConstPointer a) const;
-
- /**
- * Query the repository, installed packages only.
- */
- PackageDatabaseEntryCollection::Pointer query_installed(
- const PackageDepAtom * const a) const;
-
- /**
- * Query the repository (overload for a CountedPtr), installed
- * packages only.
- */
- PackageDatabaseEntryCollection::Pointer query_installed(
- PackageDepAtom::ConstPointer a) const;
+ PackageDepAtom::ConstPointer a,
+ const InstallState) const;
/**
* Which repository is better?
diff --git a/paludis/package_database_TEST.cc b/paludis/package_database_TEST.cc
index 92bde5c..48a6057 100644
--- a/paludis/package_database_TEST.cc
+++ b/paludis/package_database_TEST.cc
@@ -123,35 +123,35 @@ namespace test_cases
TEST_CHECK(true);
PackageDepAtom d1("r1c1/r1c1p1");
- const PackageDatabaseEntryCollection::Pointer q1(p.query(&d1));
+ const PackageDatabaseEntryCollection::Pointer q1(p.query(&d1, is_either));
TEST_CHECK_EQUAL(q1->size(), 1);
PackageDepAtom d2("r1c1/r1c1p2");
- const PackageDatabaseEntryCollection::Pointer q2(p.query(&d2));
+ const PackageDatabaseEntryCollection::Pointer q2(p.query(&d2, is_either));
TEST_CHECK_EQUAL(q2->size(), 2);
PackageDepAtom d3(">=r1c1/r1c1p2-1");
- const PackageDatabaseEntryCollection::Pointer q3(p.query(&d3));
+ const PackageDatabaseEntryCollection::Pointer q3(p.query(&d3, is_either));
TEST_CHECK_EQUAL(q3->size(), 2);
PackageDepAtom d4(">=r1c1/r1c1p2-2");
- const PackageDatabaseEntryCollection::Pointer q4(p.query(&d4));
+ const PackageDatabaseEntryCollection::Pointer q4(p.query(&d4, is_either));
TEST_CHECK_EQUAL(q4->size(), 1);
PackageDepAtom d5(">=r1c1/r1c1p2-3");
- const PackageDatabaseEntryCollection::Pointer q5(p.query(&d5));
+ const PackageDatabaseEntryCollection::Pointer q5(p.query(&d5, is_either));
TEST_CHECK_EQUAL(q5->size(), 0);
PackageDepAtom d6("<r1c1/r1c1p2-3");
- const PackageDatabaseEntryCollection::Pointer q6(p.query(&d6));
+ const PackageDatabaseEntryCollection::Pointer q6(p.query(&d6, is_either));
TEST_CHECK_EQUAL(q6->size(), 2);
PackageDepAtom d7("rac1/rac1pa");
- const PackageDatabaseEntryCollection::Pointer q7(p.query(&d7));
+ const PackageDatabaseEntryCollection::Pointer q7(p.query(&d7, is_either));
TEST_CHECK_EQUAL(q7->size(), 4);
PackageDepAtom d8("foo/bar");
- const PackageDatabaseEntryCollection::Pointer q8(p.query(&d8));
+ const PackageDatabaseEntryCollection::Pointer q8(p.query(&d8, is_either));
TEST_CHECK_EQUAL(q8->size(), 0);
}
} package_database_query_test;
diff --git a/src/query.cc b/src/query.cc
index fff1888..d0bbe57 100644
--- a/src/query.cc
+++ b/src/query.cc
@@ -44,7 +44,8 @@ void do_one_query(
p::PackageNamePart(q))) :
new p::PackageDepAtom(q));
- p::PackageDatabaseEntryCollection::ConstPointer entries(env->package_database()->query(atom));
+ p::PackageDatabaseEntryCollection::ConstPointer entries(env->package_database()->query(
+ atom, p::is_either));
if (entries->empty())
throw p::NoSuchPackageError(q);