From 5b353cce5b2d78e007924f903b8b02afaf9d3975 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 21 Mar 2022 13:44:48 +0300 Subject: Improve search for available package corresponding to selected package in pkg-build --- bpkg/package.cxx | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'bpkg/package.cxx') diff --git a/bpkg/package.cxx b/bpkg/package.cxx index da560f2..4b9cdc3 100644 --- a/bpkg/package.cxx +++ b/bpkg/package.cxx @@ -120,7 +120,8 @@ namespace bpkg query_available (database& db, const package_name& name, const optional& c, - bool order) + bool order, + bool revision) { using query = query; @@ -134,18 +135,6 @@ namespace bpkg { assert (c->complete ()); - // If the revision is not explicitly specified, then compare ignoring the - // revision. The idea is that when the user runs 'bpkg build libfoo/1' - // and there is 1+1 available, it should just work. The user shouldn't - // have to spell the revision explicitly. Similarly, when we have - // 'depends: libfoo == 1', then it would be strange if 1+1 did not - // satisfy this constraint. The same for libfoo <= 1 -- 1+1 should - // satisfy. - // - // Note that we always compare ignoring the iteration, as it can not be - // specified in the manifest/command line. This way the latest iteration - // will always be picked up. - // query qs (compare_version_eq (vm, canonical_version (wildcard_version), false /* revision */, @@ -160,8 +149,8 @@ namespace bpkg q = q && (compare_version_eq (vm, canonical_version (v), - v.revision.has_value (), - false /* iteration */) || + revision || v.revision.has_value (), + revision /* iteration */) || qs); } else @@ -172,24 +161,24 @@ namespace bpkg { const version& v (*c->min_version); canonical_version cv (v); - bool rv (v.revision); + bool rv (revision || v.revision); if (c->min_open) - qr = compare_version_gt (vm, cv, rv, false /* iteration */); + qr = compare_version_gt (vm, cv, rv, revision /* iteration */); else - qr = compare_version_ge (vm, cv, rv, false /* iteration */); + qr = compare_version_ge (vm, cv, rv, revision /* iteration */); } if (c->max_version) { const version& v (*c->max_version); canonical_version cv (v); - bool rv (v.revision); + bool rv (revision || v.revision); if (c->max_open) - qr = qr && compare_version_lt (vm, cv, rv, false /* iteration */); + qr = qr && compare_version_lt (vm, cv, rv, revision); else - qr = qr && compare_version_le (vm, cv, rv, false /* iteration */); + qr = qr && compare_version_le (vm, cv, rv, revision); } q = q && (qr || qs); -- cgit v1.1