From 5905fbe8053c5e58e77234dc1f9f81bde6e46b41 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 25 Jan 2016 17:28:57 +0200 Subject: Ignore revision for version equality in pkg-{status,build}, constraints --- bpkg/pkg-status.cxx | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'bpkg/pkg-status.cxx') diff --git a/bpkg/pkg-status.cxx b/bpkg/pkg-status.cxx index 26cf803..98c583a 100644 --- a/bpkg/pkg-status.cxx +++ b/bpkg/pkg-status.cxx @@ -50,7 +50,7 @@ namespace bpkg query q (query::name == n); if (!v.empty ()) - q = q && query::version == v; + q = q && compare_version_eq (query::version, v, v.revision != 0); p = db.query_one (q); } @@ -60,29 +60,32 @@ namespace bpkg // no need to look for it in available packages. // vector> aps; - if (p == nullptr || v.empty ()) { using query = query; query q (query::id.name == n); - // If the user specified the version, then only look for that - // specific version. + // If we found an existing package, then only look for versions greater + // than what already exists. // - if (!v.empty ()) - q = q && query::id.version == v; + if (p != nullptr) + { + q = q && query::id.version > p->version; + q += order_by_version_desc (query::id.version); + } // - // Otherwise, if we found an existing package, then only look for - // versions greater than what already exists. + // Otherwise, if the user specified the version, then only look for that + // specific version (we still do it since there are might be other + // revisions). // - else if (p != nullptr) - q = q && query::id.version > p->version; - - q += order_by_version_desc (query::id.version); + else if (!v.empty ()) + { + q = q && compare_version_eq (query::id.version, v, v.revision != 0); + q += order_by_revision_desc (query::id.version); + } - // Only consider packages that are in repositories that were - // explicitly added to the configuration and their complements, - // recursively. + // Only consider packages that are in repositories that were explicitly + // added to the configuration and their complements, recursively. // aps = filter (db.load (""), db.query (q)); } @@ -97,7 +100,7 @@ namespace bpkg // Also print the version of the package unless the user specified it. // - if (v.empty ()) + if (v != p->version) cout << " " << p->version; if (p->hold_package) @@ -113,10 +116,10 @@ namespace bpkg { cout << (found ? "; " : "") << "available"; - // If the user specified the version, then there will be only one - // entry. + // If the user specified the version, then there might only be one + // entry in which case it is useless to repeat it. // - if (v.empty ()) + if (v.empty () || aps.size () > 1 || aps[0]->version != v) { for (shared_ptr ap: aps) cout << ' ' << ap->version; -- cgit v1.1