← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-sort-dsp-version-table into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-sort-dsp-version-table into launchpad:master.

Commit message:
Sort versions in DSP version table in descending order by series

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398254

The order was previously non-deterministic.  Since the version table shows series in descending order and versions within each series, it makes most sense to sort the versions in descending order too.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-sort-dsp-version-table into launchpad:master.
diff --git a/lib/lp/registry/browser/distributionsourcepackage.py b/lib/lp/registry/browser/distributionsourcepackage.py
index df3cd55..f4c58d4 100644
--- a/lib/lp/registry/browser/distributionsourcepackage.py
+++ b/lib/lp/registry/browser/distributionsourcepackage.py
@@ -18,9 +18,11 @@ __all__ = [
     'PublishingHistoryViewMixin',
     ]
 
+from functools import cmp_to_key
 import itertools
 import operator
 
+import apt_pkg
 from lazr.delegates import delegate_to
 import six
 from zope.component import getUtility
@@ -513,7 +515,9 @@ class DistributionSourcePackageView(DistributionSourcePackageBaseView,
             # After the title row, we list each package version that's
             # currently published, and which pockets it's published in.
             pocket_dict = self.published_by_version(package)
-            for version in pocket_dict:
+            for version in sorted(
+                    pocket_dict,
+                    key=cmp_to_key(apt_pkg.version_compare), reverse=True):
                 most_recent_publication = pocket_dict[version][0]
                 date_published = most_recent_publication.datepublished
                 pockets = ", ".join(
diff --git a/lib/lp/registry/stories/packaging/xx-distributionsourcepackage-packaging.txt b/lib/lp/registry/stories/packaging/xx-distributionsourcepackage-packaging.txt
index a1f0e86..f7ab863 100644
--- a/lib/lp/registry/stories/packaging/xx-distributionsourcepackage-packaging.txt
+++ b/lib/lp/registry/stories/packaging/xx-distributionsourcepackage-packaging.txt
@@ -21,8 +21,8 @@ source package in each series of this distribution.
     The Hoary Hedgehog Release (active development)     Set upstream link
       1.0.9a-4ubuntu1 release (main) 2005-09-15
     The Warty Warthog Release (current stable release) alsa-utils trunk series
-      1.0.8-1ubuntu1  release (main) 2005-09-15
       1.0.9a-4        release (main) 2005-09-16
+      1.0.8-1ubuntu1  release (main) 2005-09-15
 
 
 Delete Link Button
@@ -62,5 +62,5 @@ Clicking this button deletes the corresponding packaging association.
     The Hoary Hedgehog Release (active development)     Set upstream link
       1.0.9a-4ubuntu1 release (main) 2005-09-15
     The Warty Warthog Release (current stable release)  Set upstream link
-      1.0.8-1ubuntu1  release (main) 2005-09-15
       1.0.9a-4        release (main) 2005-09-16
+      1.0.8-1ubuntu1  release (main) 2005-09-15