aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-02-04 21:26:24 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-02-04 21:26:24 +0000
commit5772b5c03e71f2dc1f32b1d64a9095d3233854eb (patch)
tree9a8c27469f6d8629e5fba2fdcc9a83f84341e943
parentce7cd6c3f08eb81f2ed85abd1ca669acca6f278c (diff)
downloadpaludis-5772b5c03e71f2dc1f32b1d64a9095d3233854eb.tar.gz
paludis-5772b5c03e71f2dc1f32b1d64a9095d3233854eb.tar.xz
Don't die if a real package in the virtual/ category provides an old-style virtual.
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc13
-rw-r--r--paludis/repositories/virtuals/virtuals_repository_TEST.cc33
2 files changed, 42 insertions, 4 deletions
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index e137fb5..44bbfce 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -209,11 +209,15 @@ VirtualsRepository::need_ids() const
if (_imp->has_ids)
return;
+ _imp->has_ids = true;
+
Context context("When loading entries for virtuals repository:");
need_names();
Log::get_instance()->message(ll_debug, lc_context, "VirtualsRepository need_entries");
+ IDMap my_ids;
+
/* Populate our _imp->entries. */
for (std::vector<std::pair<QualifiedPackageName, tr1::shared_ptr<const PackageDepSpec> > >::const_iterator
v(_imp->names.begin()), v_end(_imp->names.end()) ; v != v_end ; ++v)
@@ -231,9 +235,9 @@ VirtualsRepository::need_ids() const
for (PackageIDSequence::ConstIterator m(matches->begin()), m_end(matches->end()) ;
m != m_end ; ++m)
{
- IDMap::iterator i(_imp->ids.find(v->first));
- if (_imp->ids.end() == i)
- i = _imp->ids.insert(std::make_pair(v->first, make_shared_ptr(new PackageIDSequence))).first;
+ IDMap::iterator i(my_ids.find(v->first));
+ if (my_ids.end() == i)
+ i = my_ids.insert(std::make_pair(v->first, make_shared_ptr(new PackageIDSequence))).first;
tr1::shared_ptr<const PackageID> id(make_virtual_package_id(QualifiedPackageName(v->first), *m));
if (stringify(id->name().category) != "virtual")
@@ -242,7 +246,8 @@ VirtualsRepository::need_ids() const
}
}
- _imp->has_ids = true;
+ using std::swap;
+ swap(my_ids, _imp->ids);
}
tr1::shared_ptr<Repository>
diff --git a/paludis/repositories/virtuals/virtuals_repository_TEST.cc b/paludis/repositories/virtuals/virtuals_repository_TEST.cc
index 3315616..1cde168 100644
--- a/paludis/repositories/virtuals/virtuals_repository_TEST.cc
+++ b/paludis/repositories/virtuals/virtuals_repository_TEST.cc
@@ -112,5 +112,38 @@ namespace test_cases
"virtual/pkg-2::virtuals (virtual for cat/pkg-2:0::repo1)");
}
} test_virtuals_repository_duplicates;
+
+ struct VirtualsRepositoryRecursionTest : TestCase
+ {
+ VirtualsRepositoryRecursionTest() : TestCase("virtuals repository recursion") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ tr1::shared_ptr<VirtualsRepository> virtuals(new VirtualsRepository(&env));
+ tr1::shared_ptr<FakeRepository> repo1(new FakeRepository(&env, RepositoryName("repo1")));
+ tr1::shared_ptr<FakeRepository> repo2(new FakeRepository(&env, RepositoryName("repo2")));
+
+ env.package_database()->add_repository(2, repo1);
+ env.package_database()->add_repository(3, repo2);
+ env.package_database()->add_repository(4, virtuals);
+
+ repo1->add_version("virtual", "gkp", "1")->provide_key()->set_from_string("virtual/pkg");
+ repo1->add_virtual_package(QualifiedPackageName("virtual/pkg"), make_shared_ptr(
+ new PackageDepSpec(parse_user_package_dep_spec("virtual/gkp", UserPackageDepSpecOptions()))));
+
+ repo2->add_version("virtual", "pkg", "2")->provide_key()->set_from_string("virtual/pkg");
+ repo2->add_virtual_package(QualifiedPackageName("virtual/pkg"), make_shared_ptr(new PackageDepSpec(
+ parse_user_package_dep_spec("virtual/pkg", UserPackageDepSpecOptions()))));
+
+ TEST_CHECK(virtuals->has_category_named(CategoryNamePart("virtual")));
+ TEST_CHECK(virtuals->has_package_named(QualifiedPackageName("virtual/pkg")));
+
+ tr1::shared_ptr<const PackageIDSequence> r(env.package_database()->query(query::All(), qo_order_by_version));
+ TEST_CHECK_STRINGIFY_EQUAL(join(indirect_iterator(r->begin()), indirect_iterator(r->end()), " | "),
+ "virtual/gkp-1:0::repo1 | virtual/pkg-1::virtuals (virtual for virtual/gkp-1:0::repo1) | "
+ "virtual/pkg-2:0::repo2 | virtual/pkg-2::virtuals (virtual for virtual/pkg-2:0::repo2)");
+ }
+ } test_virtuals_repository_recursion;
}