aboutsummaryrefslogtreecommitdiff
path: root/bpkg/pkg-build.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-01-25 17:28:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-01-25 17:28:57 +0200
commit5905fbe8053c5e58e77234dc1f9f81bde6e46b41 (patch)
treefc9e43793ca7d40c65d0bb835326d3995e0dad63 /bpkg/pkg-build.cxx
parentdb495f3c771ecfe2911d55ba41ab83d22409bcc0 (diff)
Ignore revision for version equality in pkg-{status,build}, constraints
Diffstat (limited to 'bpkg/pkg-build.cxx')
-rw-r--r--bpkg/pkg-build.cxx57
1 files changed, 44 insertions, 13 deletions
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index 6202095..c3dc00e 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -66,24 +66,55 @@ namespace bpkg
//
if (c)
{
- if (c->min_version)
+ // If the constraint is equality and the revision is not explicitly
+ // specified, then compare ignoring the revision. The idea is that when
+ // the user runs 'bpkg build libfoo/1.0.0' and there is 1.0.0+1
+ // available, it should just work. The user shouldn't have to spell the
+ // revision explicitly. Similarly, when we have 'depends: libfoo ==
+ // 1.0.0', then it would be strange if 1.0.0+1 did not satisfy this
+ // constraint.
+ //
+ // Note that strictly speaking 0 doesn't mean unspecified. Which means
+ // with this implementation there is no way to say "I really mean
+ // revision 0" since 1.0.0 == 1.0.0+0. One can, in the current model, say
+ // libfoo == 1.0.0+1, though. This is probably ok since one would assume
+ // any subsequent revision of a package is only better than the ones
+ // before.
+ //
+ if (c->min_version &&
+ c->max_version &&
+ *c->min_version == *c->max_version)
{
- if (c->min_open)
- q = q && vm > *c->min_version;
- else
- q = q && vm >= *c->min_version;
- }
+ const version& v (*c->min_version);
+
+ q = compare_version_eq (vm, v, v.revision != 0);
- if (c->max_version)
+ if (v.revision == 0)
+ q += order_by_revision_desc (vm);
+ }
+ else
{
- if (c->max_open)
- q = q && vm < *c->max_version;
- else
- q = q && vm <= *c->max_version;
+ if (c->min_version)
+ {
+ if (c->min_open)
+ q = q && vm > *c->min_version;
+ else
+ q = q && vm >= *c->min_version;
+ }
+
+ if (c->max_version)
+ {
+ if (c->max_open)
+ q = q && vm < *c->max_version;
+ else
+ q = q && vm <= *c->max_version;
+ }
+
+ q += order_by_version_desc (vm);
}
}
-
- q += order_by_version_desc (vm);
+ else
+ q += order_by_version_desc (vm);
// Filter the result based on the repository to which each version
// belongs.