aboutsummaryrefslogtreecommitdiff
path: root/bpkg/package.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-03-21 13:44:48 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-03-21 13:45:58 +0300
commit5b353cce5b2d78e007924f903b8b02afaf9d3975 (patch)
treea990eadbb501cc4845e94bf2183f59d9f7f168be /bpkg/package.cxx
parentdf79f83187ecb91569b254ecbd90f46edabe8826 (diff)
Improve search for available package corresponding to selected package in pkg-build
Diffstat (limited to 'bpkg/package.cxx')
-rw-r--r--bpkg/package.cxx31
1 files changed, 10 insertions, 21 deletions
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<version_constraint>& c,
- bool order)
+ bool order,
+ bool revision)
{
using query = query<available_package>;
@@ -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);