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/package | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'bpkg/package') diff --git a/bpkg/package b/bpkg/package index e46164c..8bd9546 100644 --- a/bpkg/package +++ b/bpkg/package @@ -503,13 +503,34 @@ namespace bpkg // template inline auto + compare_version_eq (const T1& x, const T2& y, bool revision) + -> decltype (x.epoch == y.epoch) + { + // Since we don't quite know what T1 and T2 are (and where the resulting + // expression will run), let's not push our luck with something like + // (revision || x.revision == y.revision). + // + if (revision) + return x.epoch == y.epoch && + x.canonical_upstream == y.canonical_upstream && + x.canonical_release == y.canonical_release && + x.revision == y.revision; + else + return x.epoch == y.epoch && + x.canonical_upstream == y.canonical_upstream && + x.canonical_release == y.canonical_release; + } + + /* + Currently unused (and probably should stay that way). + + template + inline auto operator== (const T1& x, const T2& y) -> decltype (x.epoch == y.epoch) { - return x.epoch == y.epoch && - x.canonical_upstream == y.canonical_upstream && - x.canonical_release == y.canonical_release && - x.revision == y.revision; + return compare_version_eq (x, y, true); } + */ template inline auto @@ -580,6 +601,14 @@ namespace bpkg + x.canonical_release + "DESC," + x.revision + "DESC"; } + + template + inline auto + order_by_revision_desc (const T& x) -> //decltype ("ORDER BY" + x.epoch) + decltype (x.revision == 0) + { + return "ORDER BY" + x.revision + "DESC"; + } } #include -- cgit v1.1