aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 03:18:34 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 03:25:21 +0100
commit8440450ddb94f56912f886fc6654e70d32c2e915 (patch)
tree23d3d9862b34c4078ff5e6440387067e494693c9
parentb4e42442332b9489ab811a3b51cbfa2802c54760 (diff)
downloadpaludis-8440450ddb94f56912f886fc6654e70d32c2e915.tar.gz
paludis-8440450ddb94f56912f886fc6654e70d32c2e915.tar.xz
Allow user ::from->in repository deps (continued)
For user dep specs, allow cat/pkg::from->in package dep specs. 'from' matches on origin repositories, 'in' matches on current repositories. At most one of from or in can be blank. ::in retains its current meaning.
-rw-r--r--paludis/user_dep_spec.cc32
-rw-r--r--paludis/user_dep_spec_TEST.cc44
2 files changed, 71 insertions, 5 deletions
diff --git a/paludis/user_dep_spec.cc b/paludis/user_dep_spec.cc
index 6879c8a..78823b2 100644
--- a/paludis/user_dep_spec.cc
+++ b/paludis/user_dep_spec.cc
@@ -193,6 +193,35 @@ namespace
s.erase(slot_p);
}
}
+
+ void
+ user_remove_trailing_repo_if_exists(std::string & s, PartiallyMadePackageDepSpec & result)
+ {
+ std::string::size_type repo_p;
+ if (std::string::npos == ((repo_p = s.rfind("::"))))
+ return;
+
+ std::string repo_name(s.substr(repo_p + 2));
+ s.erase(repo_p);
+
+ std::string::size_type arrow_p(repo_name.find("->"));
+ if (std::string::npos == arrow_p)
+ result.in_repository(RepositoryName(repo_name));
+ else
+ {
+ std::string from_repository(repo_name.substr(0, arrow_p));
+ std::string to_repository(repo_name.substr(arrow_p + 2));
+
+ if (from_repository.empty() && to_repository.empty())
+ throw PackageDepSpecError("::-> requires either a from or a to repository");
+
+ if (! to_repository.empty())
+ result.in_repository(RepositoryName(to_repository));
+
+ if (! from_repository.empty())
+ result.from_repository(RepositoryName(from_repository));
+ }
+ }
}
PackageDepSpec
@@ -208,8 +237,7 @@ paludis::parse_user_package_dep_spec(const std::string & ss, const Environment *
(k::check_sanity(), std::tr1::bind(&user_check_sanity, _1, options, env))
(k::remove_trailing_square_bracket_if_exists(), std::tr1::bind(&user_remove_trailing_square_bracket_if_exists,
_1, _2, std::tr1::ref(had_bracket_version_requirements)))
- (k::remove_trailing_repo_if_exists(), std::tr1::bind(&elike_remove_trailing_repo_if_exists,
- _1, _2, ELikePackageDepSpecOptions() + epdso_allow_repository_deps))
+ (k::remove_trailing_repo_if_exists(), std::tr1::bind(&user_remove_trailing_repo_if_exists, _1, _2))
(k::remove_trailing_slot_if_exists(), std::tr1::bind(&user_remove_trailing_slot_if_exists, _1, _2))
(k::has_version_operator(), std::tr1::bind(&elike_has_version_operator, _1, std::tr1::cref(had_bracket_version_requirements)))
(k::get_remove_version_operator(), std::tr1::bind(&elike_get_remove_version_operator, _1,
diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc
index 7642193..e0ee81d 100644
--- a/paludis/user_dep_spec_TEST.cc
+++ b/paludis/user_dep_spec_TEST.cc
@@ -112,7 +112,8 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(i, "foo/bar[-two][one]");
TEST_CHECK_STRINGIFY_EQUAL(*i.package_ptr(), "foo/bar");
TEST_CHECK(! i.version_requirements_ptr());
- TEST_CHECK(! i.repository_ptr());
+ TEST_CHECK(! i.in_repository_ptr());
+ TEST_CHECK(! i.from_repository_ptr());
TEST_CHECK(! i.slot_requirement_ptr());
TEST_CHECK(i.additional_requirements_ptr());
@@ -134,7 +135,8 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(l, "foo/bar[>=1.2&<2.0][-two][one]");
TEST_CHECK_STRINGIFY_EQUAL(*l.package_ptr(), "foo/bar");
TEST_CHECK(l.version_requirements_ptr());
- TEST_CHECK(! l.repository_ptr());
+ TEST_CHECK(! l.in_repository_ptr());
+ TEST_CHECK(! l.from_repository_ptr());
TEST_CHECK_STRINGIFY_EQUAL(l.version_requirements_ptr()->begin()->version_spec, "1.2");
TEST_CHECK_EQUAL(l.version_requirements_ptr()->begin()->version_operator, vo_greater_equal);
TEST_CHECK_STRINGIFY_EQUAL(next(l.version_requirements_ptr()->begin())->version_spec, "2.0");
@@ -145,7 +147,8 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(m, "foo/bar[=1.2|=1.3*|~1.4]");
TEST_CHECK_STRINGIFY_EQUAL(*m.package_ptr(), "foo/bar");
TEST_CHECK(m.version_requirements_ptr());
- TEST_CHECK(! m.repository_ptr());
+ TEST_CHECK(! m.in_repository_ptr());
+ TEST_CHECK(! m.from_repository_ptr());
TEST_CHECK_STRINGIFY_EQUAL(m.version_requirements_ptr()->begin()->version_spec, "1.2");
TEST_CHECK_EQUAL(m.version_requirements_ptr()->begin()->version_operator, vo_equal);
TEST_CHECK_STRINGIFY_EQUAL(next(m.version_requirements_ptr()->begin())->version_spec, "1.3");
@@ -223,6 +226,41 @@ namespace test_cases
}
} test_user_package_dep_spec_unspecific;
+ struct UserPackageDepSpecReposTest : TestCase
+ {
+ UserPackageDepSpecReposTest() : TestCase("user package dep spec repos") { }
+
+ void run()
+ {
+ TestEnvironment env;
+
+ PackageDepSpec a(parse_user_package_dep_spec("cat/pkg::repo",
+ &env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ TEST_CHECK(a.in_repository_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(*a.in_repository_ptr(), "repo");
+ TEST_CHECK(! a.from_repository_ptr());
+
+ PackageDepSpec b(parse_user_package_dep_spec("cat/pkg::->repo",
+ &env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ TEST_CHECK(b.in_repository_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(*b.in_repository_ptr(), "repo");
+ TEST_CHECK(! b.from_repository_ptr());
+
+ PackageDepSpec c(parse_user_package_dep_spec("cat/pkg::repo->",
+ &env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ TEST_CHECK(c.from_repository_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(*c.from_repository_ptr(), "repo");
+ TEST_CHECK(! c.in_repository_ptr());
+
+ PackageDepSpec d(parse_user_package_dep_spec("cat/pkg::r1->r2",
+ &env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ TEST_CHECK(d.in_repository_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(*d.in_repository_ptr(), "r2");
+ TEST_CHECK(d.from_repository_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(*d.from_repository_ptr(), "r1");
+ }
+ } test_user_package_dep_spec_repo;
+
struct UserPackageDepSpecDisambiguationTest : TestCase
{
UserPackageDepSpecDisambiguationTest() : TestCase("user package dep spec disambiguation") { }