From 02ca7e6b7bb7c01659adba36944e59262f307b06 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 23 Dec 2015 17:50:01 +0200 Subject: Support version release --- bpkg/package | 85 +++++++++++++++------ bpkg/package.ixx | 2 +- bpkg/package.xml | 21 +++++ .../1/status/extra/libbar-1.1.0+1.tar.gz | Bin 0 -> 243 bytes .../1/status/extra/libbar-1.1.0-1.tar.gz | Bin 242 -> 0 bytes .../1/status/testing/libbar-1.0.0+1.tar.gz | Bin 0 -> 243 bytes .../1/status/testing/libbar-1.0.0-1.tar.gz | Bin 244 -> 0 bytes tests/test.sh | 12 +-- 8 files changed, 88 insertions(+), 32 deletions(-) create mode 100644 tests/repository/1/status/extra/libbar-1.1.0+1.tar.gz delete mode 100644 tests/repository/1/status/extra/libbar-1.1.0-1.tar.gz create mode 100644 tests/repository/1/status/testing/libbar-1.0.0+1.tar.gz delete mode 100644 tests/repository/1/status/testing/libbar-1.0.0-1.tar.gz diff --git a/bpkg/package b/bpkg/package index 734cacb..318f09d 100644 --- a/bpkg/package +++ b/bpkg/package @@ -18,7 +18,7 @@ #include #include -#pragma db model version(1, 1, closed) +#pragma db model version(1, 1, open) namespace bpkg { @@ -64,8 +64,10 @@ namespace bpkg { uint16_t epoch; string canonical_upstream; + string canonical_release; uint16_t revision; string upstream; + string release; }; } @@ -86,12 +88,12 @@ namespace bpkg // version // // Sometimes we need to split the version into two parts: the part - // that goes into the object id (epoch, canonical upstream, revision) - // and the original upstream. This is what the canonical_version and - // upstream_version value types are for. Note that upstream_version - // derives from version and uses it as storage. The idea here is this: - // when we split the version, we often still want to have the "whole" - // version object readily accessible and that's exactly what this + // that goes into the object id (epoch, canonical upstream, canonical + // release, revision) and the original upstream and release. This is what + // the canonical_version and upstream_version value types are for. Note that + // upstream_version derives from version and uses it as storage. The idea + // here is this: when we split the version, we often still want to have the + // "whole" version object readily accessible and that's exactly what this // strange contraption is for. See available_package for an example // on how everything fits together. // @@ -101,15 +103,31 @@ namespace bpkg { uint16_t epoch; string canonical_upstream; + + // By a fluke SQLite 3 uses BINARY collation for UTF-8-encoded TEXT columns + // by default. So no need to adjust it to make "absent" and specified + // canonical releases to compare properly. But better to keep an eye on + // it not to miss a moment if SQLite plug UCA-compliant collation. + // Note: PostgreSQL uses UCA-compliant one by default for UTF8-encoded + // TEXT columns. + // + // Unicode Collation Algorithm (UCA): http://unicode.org/reports/tr10/ + // + string canonical_release; + uint16_t revision; }; #pragma db value transient struct upstream_version: version { - #pragma db member(upstream_) virtual(string) \ - get(this.upstream) \ - set(this = bpkg::version (0, std::move (?), 0)) + #pragma db member(upstream_) virtual(string) \ + get(this.upstream) \ + set(this = bpkg::version (0, std::move (?), "~", 0)) + + #pragma db member(release_) virtual(string) \ + get(this.release) \ + set(this = bpkg::version (0, this.upstream, std::move (?), 0)) upstream_version () = default; upstream_version (version v): version (move (v)) {} @@ -119,17 +137,23 @@ namespace bpkg void init (const canonical_version& cv, const upstream_version& uv) { - *this = version (cv.epoch, uv.upstream, cv.revision); - assert (cv.canonical_upstream == canonical_upstream); + *this = version (cv.epoch, uv.upstream, uv.release, cv.revision); + assert (cv.canonical_upstream == canonical_upstream && + cv.canonical_release == canonical_release); } }; - #pragma db map type(version) as(_version) \ - to(bpkg::_version{(?).epoch, \ - (?).canonical_upstream, \ - (?).revision, \ - (?).upstream}) \ - from(bpkg::version ((?).epoch, std::move ((?).upstream), (?).revision)) + #pragma db map type(version) as(_version) \ + to(bpkg::_version{(?).epoch, \ + (?).canonical_upstream, \ + (?).canonical_release, \ + (?).revision, \ + (?).upstream, \ + (?).release}) \ + from(bpkg::version ((?).epoch, \ + std::move ((?).upstream), \ + std::move ((?).release), \ + (?).revision)) // repository_location @@ -461,9 +485,9 @@ namespace bpkg // Version comparison operators. // // They allow comparing objects that have epoch, canonical_upstream, - // and revision data members. The idea is that this works for both - // query members of types version and canonical_version as well as - // for comparing canonical_version to version. + // canonical_release, and revision data members. The idea is that this + // works for both query members of types version and canonical_version + // as well as for comparing canonical_version to version. // template inline auto @@ -471,6 +495,7 @@ namespace bpkg { return x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream && + x.canonical_release == y.canonical_release && x.revision == y.revision; } @@ -480,6 +505,7 @@ namespace bpkg { return x.epoch != y.epoch || x.canonical_upstream != y.canonical_upstream || + x.canonical_release != y.canonical_release || x.revision != y.revision; } @@ -490,7 +516,9 @@ namespace bpkg return x.epoch < y.epoch || (x.epoch == y.epoch && x.canonical_upstream < y.canonical_upstream) || (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream && - x.revision < y.revision); + x.canonical_release < y.canonical_release) || + (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream && + x.canonical_release == y.canonical_release && x.revision < y.revision); } template @@ -500,7 +528,9 @@ namespace bpkg return x.epoch < y.epoch || (x.epoch == y.epoch && x.canonical_upstream < y.canonical_upstream) || (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream && - x.revision <= y.revision); + x.canonical_release < y.canonical_release) || + (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream && + x.canonical_release == y.canonical_release && x.revision <= y.revision); } template @@ -510,7 +540,9 @@ namespace bpkg return x.epoch > y.epoch || (x.epoch == y.epoch && x.canonical_upstream > y.canonical_upstream) || (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream && - x.revision > y.revision); + x.canonical_release > y.canonical_release) || + (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream && + x.canonical_release == y.canonical_release && x.revision > y.revision); } template @@ -520,7 +552,9 @@ namespace bpkg return x.epoch > y.epoch || (x.epoch == y.epoch && x.canonical_upstream > y.canonical_upstream) || (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream && - x.revision >= y.revision); + x.canonical_release > y.canonical_release) || + (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream && + x.canonical_release == y.canonical_release && x.revision >= y.revision); } template @@ -531,6 +565,7 @@ namespace bpkg return "ORDER BY" + x.epoch + "DESC," + x.canonical_upstream + "DESC," + + x.canonical_release + "DESC," + x.revision + "DESC"; } } diff --git a/bpkg/package.ixx b/bpkg/package.ixx index 8d1c219..32d79f4 100644 --- a/bpkg/package.ixx +++ b/bpkg/package.ixx @@ -9,7 +9,7 @@ namespace bpkg inline available_package_id:: available_package_id (string n, const bpkg::version& v) : name (move (n)), - version {v.epoch, v.canonical_upstream, v.revision} + version {v.epoch, v.canonical_upstream, v.canonical_release, v.revision} { } } diff --git a/bpkg/package.xml b/bpkg/package.xml index 9ac6a3a..f2c470c 100644 --- a/bpkg/package.xml +++ b/bpkg/package.xml @@ -49,12 +49,15 @@ + + + @@ -62,6 +65,7 @@ + @@ -69,11 +73,13 @@ + + @@ -81,6 +87,7 @@ + @@ -94,6 +101,7 @@ + @@ -102,11 +110,13 @@ + + @@ -114,6 +124,7 @@ + @@ -124,6 +135,7 @@ + @@ -131,17 +143,21 @@ + + + + @@ -149,6 +165,7 @@ + @@ -156,8 +173,10 @@ + + @@ -177,8 +196,10 @@ + + diff --git a/tests/repository/1/status/extra/libbar-1.1.0+1.tar.gz b/tests/repository/1/status/extra/libbar-1.1.0+1.tar.gz new file mode 100644 index 0000000..890e9e2 Binary files /dev/null and b/tests/repository/1/status/extra/libbar-1.1.0+1.tar.gz differ diff --git a/tests/repository/1/status/extra/libbar-1.1.0-1.tar.gz b/tests/repository/1/status/extra/libbar-1.1.0-1.tar.gz deleted file mode 100644 index 09ffc97..0000000 Binary files a/tests/repository/1/status/extra/libbar-1.1.0-1.tar.gz and /dev/null differ diff --git a/tests/repository/1/status/testing/libbar-1.0.0+1.tar.gz b/tests/repository/1/status/testing/libbar-1.0.0+1.tar.gz new file mode 100644 index 0000000..5794085 Binary files /dev/null and b/tests/repository/1/status/testing/libbar-1.0.0+1.tar.gz differ diff --git a/tests/repository/1/status/testing/libbar-1.0.0-1.tar.gz b/tests/repository/1/status/testing/libbar-1.0.0-1.tar.gz deleted file mode 100644 index e8a54ca..0000000 Binary files a/tests/repository/1/status/testing/libbar-1.0.0-1.tar.gz and /dev/null differ diff --git a/tests/test.sh b/tests/test.sh index 8b391d1..e6a0a10 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -679,22 +679,22 @@ stat libfoo "fetched 1.0.0" test cfg-create --wipe test cfg-add $rep/status/extra test cfg-fetch -stat libbar "available 1.1.0-1" +stat libbar "available 1.1.0+1" test cfg-add $rep/status/stable test cfg-fetch -stat libbar "available 1.1.0-1 1.0.0" +stat libbar "available 1.1.0+1 1.0.0" test cfg-create --wipe test cfg-add $rep/status/testing test cfg-fetch -stat libbar "available 1.1.0 1.0.0-1 1.0.0" +stat libbar "available 1.1.0 1.0.0+1 1.0.0" test cfg-create --wipe test cfg-add $rep/status/unstable test cfg-fetch -stat libbar "available 2.0.0 1.1.0 1.0.0-1 1.0.0" -test pkg-fetch libbar/1.0.0-1 -stat libbar "fetched 1.0.0-1; available 2.0.0 1.1.0" +stat libbar "available 2.0.0 1.1.0 1.0.0+1 1.0.0" +test pkg-fetch libbar/1.0.0+1 +stat libbar "fetched 1.0.0+1; available 2.0.0 1.1.0" test pkg-purge libbar test pkg-fetch libbar/2.0.0 stat libbar "fetched 2.0.0" -- cgit v1.1