diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-10-01 14:32:44 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-10-07 18:04:00 +0200 |
commit | ce8a7b9e50945758efdafc63869e1b44864f9d7d (patch) | |
tree | 64db2fd0338ce08a401add5459b70d937669db38 | |
parent | d1fae6b26e0820dee76e396c540bb1de90038917 (diff) |
Adopt to some bpkg namespace types reshape
-rw-r--r-- | brep/package | 20 | ||||
-rw-r--r-- | brep/package-version-details.cxx | 21 | ||||
-rw-r--r-- | brep/package.cxx | 12 | ||||
-rw-r--r-- | loader/loader.cxx | 6 | ||||
-rw-r--r-- | tests/loader/driver.cxx | 94 |
5 files changed, 73 insertions, 80 deletions
diff --git a/brep/package b/brep/package index ddfc179..6ca0c12 100644 --- a/brep/package +++ b/brep/package @@ -45,13 +45,17 @@ namespace brep // bpkg namespace from which we "borrow" types (and some of them use // version). // -#pragma db map type(bpkg::version) as(brep::_version) \ - to(brep::_version{(?).epoch (), \ - (?).upstream (), \ - (?).revision (), \ - (?).canonical_upstream ()}) \ +#pragma db map type(bpkg::version) as(brep::_version) \ + to(brep::_version{(?).epoch, \ + (?).upstream, \ + (?).revision, \ + (?).canonical_upstream}) \ from(bpkg::version ((?).epoch, std::move ((?).upstream), (?).revision)) +#pragma db map type(bpkg::comparison) as(std::string) \ + to(bpkg::to_string (?)) \ + from(bpkg::to_comparison (?)) + namespace brep { // @@ If namespace, then should probably call it 'repo'. @@ -157,9 +161,8 @@ namespace brep // dependencies // using comparison = bpkg::comparison; - using version_comparison = bpkg::version_comparison; - #pragma db value(version_comparison) definition - #pragma db member(version_comparison::value) column("") + using dependency_condition = bpkg::dependency_condition; + #pragma db value(dependency_condition) definition // Notes: // @@ -192,6 +195,7 @@ namespace brep // using dependency = bpkg::dependency; #pragma db value(dependency) definition + #pragma db member(dependency::condition) column("") using dependency_alternatives = bpkg::dependency_alternatives; #pragma db value(dependency_alternatives) definition diff --git a/brep/package-version-details.cxx b/brep/package-version-details.cxx index 162e783..0d08a45 100644 --- a/brep/package-version-details.cxx +++ b/brep/package-version-details.cxx @@ -116,9 +116,7 @@ namespace brep try { - package_version_id id { - p, v.epoch (), v.canonical_upstream (), v.revision ()}; - + package_version_id id {p, v.epoch, v.canonical_upstream, v.revision}; pv = db_->load<package_version> (id); // If the requested package version turned up to be an "external" one @@ -193,22 +191,11 @@ namespace brep if (&d != &da[0]) s << " | "; - // @@ Should it be a link to package version search page on the + // @@ Should it be a link to the package version search page or + // the best matching package version details page on the // corresponding repository site ? // - s << d.package; - - if (d.version) - { - static const strings operations ({"==", "<", ">", "<=", ">="}); - size_t op (static_cast<size_t> (d.version->operation)); - assert (op < operations.size ()); - - // @@ Should it be a link to the best matching package version - // details page on the corresponding repository site ? - // - s << " " << operations[op] << " " << d.version->value.string (); - } + s << d; } if (!da.comment.empty ()) diff --git a/brep/package.cxx b/brep/package.cxx index 8b9a219..b0c1115 100644 --- a/brep/package.cxx +++ b/brep/package.cxx @@ -88,11 +88,11 @@ namespace brep return _id_type { { package.object_id (), - version.epoch (), - version.canonical_upstream (), - version.revision () + version.epoch, + version.canonical_upstream, + version.revision }, - version.upstream ()}; + version.upstream}; } void package_version:: @@ -100,7 +100,7 @@ namespace brep { package = lazy_shared_ptr<package_type> (db, v.data.package); version = version_type (v.data.epoch, move (v.upstream), v.data.revision); - assert (version.canonical_upstream () == v.data.canonical_upstream); + assert (version.canonical_upstream == v.data.canonical_upstream); } // max_package_version @@ -109,7 +109,7 @@ namespace brep _id (package_version::_id_type&& v) { version = version_type (v.data.epoch, move (v.upstream), v.data.revision); - assert (version.canonical_upstream () == v.data.canonical_upstream); + assert (version.canonical_upstream == v.data.canonical_upstream); } // repository diff --git a/loader/loader.cxx b/loader/loader.cxx index 0739774..3aa2b12 100644 --- a/loader/loader.cxx +++ b/loader/loader.cxx @@ -406,9 +406,9 @@ load_packages (const shared_ptr<repository>& rp, database& db) package_version_id { pm.name, - pm.version.epoch (), - pm.version.canonical_upstream (), - pm.version.revision () + pm.version.epoch, + pm.version.canonical_upstream, + pm.version.revision })); if (pv == nullptr) diff --git a/tests/loader/driver.cxx b/tests/loader/driver.cxx index 443da72..4fc1333 100644 --- a/tests/loader/driver.cxx +++ b/tests/loader/driver.cxx @@ -30,9 +30,9 @@ using namespace brep; static inline bool operator== (const dependency& a, const dependency& b) { - return a.package == b.package && !a.version == !b.version && - (!a.version || (a.version->value == b.version->value && - a.version->operation == b.version->operation)); + return a.name == b.name && !a.condition == !b.condition && + (!a.condition || (a.condition->operation == b.condition->operation && + a.condition->version == b.condition->version)); } static bool @@ -131,9 +131,9 @@ main (int argc, char* argv[]) db.load<package_version> ( package_version_id { "libfoo", - fv1.epoch (), - fv1.canonical_upstream (), - fv1.revision ()})); + fv1.epoch, + fv1.canonical_upstream, + fv1.revision})); assert (check_location (fpv1)); version fv2 ("1.2.2"); @@ -141,9 +141,9 @@ main (int argc, char* argv[]) db.load<package_version> ( package_version_id { "libfoo", - fv2.epoch (), - fv2.canonical_upstream (), - fv2.revision ()})); + fv2.epoch, + fv2.canonical_upstream, + fv2.revision})); assert (check_location (fpv2)); version fv3 ("1.2.3-4"); @@ -151,9 +151,9 @@ main (int argc, char* argv[]) db.load<package_version> ( package_version_id { "libfoo", - fv3.epoch (), - fv3.canonical_upstream (), - fv3.revision ()})); + fv3.epoch, + fv3.canonical_upstream, + fv3.revision})); assert (check_location (fpv3)); version fv4 ("1.2.4"); @@ -161,9 +161,9 @@ main (int argc, char* argv[]) db.load<package_version> ( package_version_id { "libfoo", - fv4.epoch (), - fv4.canonical_upstream (), - fv4.revision ()})); + fv4.epoch, + fv4.canonical_upstream, + fv4.revision})); assert (check_location (fpv4)); version xv ("1.0.0-1"); @@ -171,9 +171,9 @@ main (int argc, char* argv[]) db.load<package_version> ( package_version_id { "libstudxml", - xv.epoch (), - xv.canonical_upstream (), - xv.revision ()})); + xv.epoch, + xv.canonical_upstream, + xv.revision})); assert (check_location (xpv)); // Verify libstudxml package. @@ -215,12 +215,13 @@ main (int argc, char* argv[]) assert (xpv->dependencies[0][0] == (dependency { "libexpat", - brep::optional<version_comparison> ( - version_comparison{version ("2.0.0"), comparison::ge})})); + brep::optional<dependency_condition> ( + dependency_condition{comparison::ge, version ("2.0.0")})})); assert (xpv->dependencies[1].size () == 1); assert (xpv->dependencies[1][0] == - (dependency {"libgenx", brep::optional<version_comparison> ()})); + (dependency { + "libgenx", brep::optional<dependency_condition> ()})); assert (xpv->requirements.empty ()); @@ -283,14 +284,14 @@ main (int argc, char* argv[]) assert (fpv2->dependencies[0][0] == (dependency { "libbar", - brep::optional<version_comparison> ( - version_comparison{version ("2.4.0"), comparison::le})})); + brep::optional<dependency_condition> ( + dependency_condition{comparison::le, version ("2.4.0")})})); assert (fpv2->dependencies[1][0] == (dependency { "libexp", - brep::optional<version_comparison> ( - version_comparison{version ("1+1.2"), comparison::eq})})); + brep::optional<dependency_condition> ( + dependency_condition{comparison::eq, version ("1+1.2")})})); assert (fpv2->requirements.empty ()); @@ -311,8 +312,8 @@ main (int argc, char* argv[]) assert (fpv3->dependencies[0][0] == (dependency { "libmisc", - brep::optional<version_comparison> ( - version_comparison{version ("2.0.0"), comparison::ge})})); + brep::optional<dependency_condition> ( + dependency_condition{comparison::ge, version ("2.0.0")})})); assert (fpv4->internal_repository.load () == sr); assert (fpv4->external_repositories.empty ()); @@ -332,8 +333,8 @@ main (int argc, char* argv[]) assert (fpv4->dependencies[0][0] == (dependency { "libmisc", - brep::optional<version_comparison> ( - version_comparison{version ("2.0.0"), comparison::ge})})); + brep::optional<dependency_condition> ( + dependency_condition{comparison::ge, version ("2.0.0")})})); // Verify 'math' repository. // @@ -356,9 +357,9 @@ main (int argc, char* argv[]) db.load<package_version> ( package_version_id { "libexp", - ev.epoch (), - ev.canonical_upstream (), - ev.revision ()})); + ev.epoch, + ev.canonical_upstream, + ev.revision})); assert (check_location (epv)); version fv5 ("1.2.4-1"); @@ -366,9 +367,9 @@ main (int argc, char* argv[]) db.load<package_version> ( package_version_id { "libfoo", - fv5.epoch (), - fv5.canonical_upstream (), - fv5.revision ()})); + fv5.epoch, + fv5.canonical_upstream, + fv5.revision})); assert (fpv[5].load () == fpv5); assert (check_location (fpv5)); @@ -411,14 +412,14 @@ main (int argc, char* argv[]) assert (fpv5->dependencies[0][0] == (dependency { "libmisc", - brep::optional<version_comparison> ( - version_comparison{version ("1.1"), comparison::lt})})); + brep::optional<dependency_condition> ( + dependency_condition{comparison::lt, version ("1.1")})})); assert (fpv5->dependencies[0][1] == (dependency { "libmisc", - brep::optional<version_comparison> ( - version_comparison{version ("2.3.0"), comparison::gt})})); + brep::optional<dependency_condition> ( + dependency_condition{comparison::gt, version ("2.3.0")})})); assert (fpv5->dependencies[1].size () == 1); assert (fpv5->dependencies[1].comment == "Newer - better."); @@ -478,7 +479,8 @@ main (int argc, char* argv[]) assert (epv->dependencies.size () == 1); assert (epv->dependencies[0].size () == 1); assert (epv->dependencies[0][0] == - (dependency {"libmisc", brep::optional<version_comparison> ()})); + (dependency { + "libmisc", brep::optional<dependency_condition> ()})); assert (epv->requirements.empty ()); @@ -502,9 +504,9 @@ main (int argc, char* argv[]) db.load<package_version> ( package_version_id { "libbar", - bv.epoch (), - bv.canonical_upstream (), - bv.revision ()})); + bv.epoch, + bv.canonical_upstream, + bv.revision})); assert (check_location (bpv)); version fv0 ("0.1"); @@ -512,9 +514,9 @@ main (int argc, char* argv[]) db.load<package_version> ( package_version_id { "libfoo", - fv0.epoch (), - fv0.canonical_upstream (), - fv0.revision ()})); + fv0.epoch, + fv0.canonical_upstream, + fv0.revision})); assert (check_location (fpv0)); // Verify libbar package. |