From 2d907a525ab169f1cb97b87550e3646fde003733 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 3 Sep 2019 00:18:20 +0300 Subject: Adapt to optional package revision --- mod/mod-build-task.cxx | 2 +- mod/mod-builds.cxx | 31 ++++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'mod') diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx index ec94e89..030c41d 100644 --- a/mod/mod-build-task.cxx +++ b/mod/mod-build-task.cxx @@ -404,7 +404,7 @@ handle (request& rq, response& rs) bld_query::id.toolchain_name == tqm.toolchain_name && compare_version_eq (bld_query::id.toolchain_version, - toolchain_version, + canonical_version (toolchain_version), true /* revision */) && (bld_query::state == "built" || diff --git a/mod/mod-builds.cxx b/mod/mod-builds.cxx index dedabfe..71e7f7b 100644 --- a/mod/mod-builds.cxx +++ b/mod/mod-builds.cxx @@ -130,9 +130,15 @@ build_query (const brep::cstrings* configs, // Package version. // if (!params.version ().empty () && params.version () != "*") + { + // May throw invalid_argument. + // + version v (params.version (), false /* fold_zero_revision */); + q = q && compare_version_eq (pid.version, - version (params.version ()), // May throw. - true); + canonical_version (v), + v.revision.has_value ()); + } // Build toolchain name/version. // @@ -144,12 +150,18 @@ build_query (const brep::cstrings* configs, if (p == string::npos) // Invalid format. throw invalid_argument (""); + // Note that the toolchain version is selected from the list and denotes + // the exact version revision, so an absent and zero revisions have the + // same semantics and the zero revision is folded. + // string tn (tc, 0, p); version tv (string (tc, p + 1)); // May throw invalid_argument. q = q && qb::id.toolchain_name == tn && - compare_version_eq (qb::id.toolchain_version, tv, true); + compare_version_eq (qb::id.toolchain_version, + canonical_version (tv), + true /* revision */); } // Build configuration name. @@ -244,9 +256,15 @@ package_query (const brep::params::builds& params, // Package version. // if (!params.version ().empty () && params.version () != "*") + { + // May throw invalid_argument. + // + version v (params.version (), false /* fold_zero_revision */); + q = q && compare_version_eq (qp::id.version, - version (params.version ()), // May throw. - true); + canonical_version (v), + v.revision.has_value ()); + } } catch (const invalid_argument&) { @@ -683,6 +701,9 @@ handle (request& rq, response& rs) // May throw invalid_argument. // + // Note that an absent and zero revisions have the same semantics, + // so the zero revision is folded (see above for details). + // tc_version = version (string (tc, p + 1)); } catch (const invalid_argument&) -- cgit v1.1