[pypy-svn] buildbot commit 0a92169ea38d: Fix the ordering: hg revisions are always more recent than svn ones.

Bitbucket commits-noreply at bitbucket.org
Tue Dec 14 14:41:07 CET 2010


# HG changeset patch -- Bitbucket.org
# Project buildbot
# URL http://bitbucket.org/pypy/buildbot/overview
# User Armin Rigo <arigo at tunes.org>
# Date 1292333974 -3600
# Node ID 0a92169ea38de840cee59fac65cf1d4255be0bda
# Parent  ebd81ebe66caa7a397b70e8daf588e90ca854f02
Fix the ordering: hg revisions are always more recent than svn ones.

--- a/bot2/pypybuildbot/summary.py
+++ b/bot2/pypybuildbot/summary.py
@@ -645,8 +645,24 @@ class Summary(HtmlResource):
 
     @staticmethod
     def _prune_runs(runs, cutnum):
+        #
+        def revkey(rev):
+            if isinstance(rev, tuple):
+                extra, rev = rev
+            else:
+                extra = None
+            # subversion: just an integer
+            if isinstance(rev, int) or rev.isdigit():
+                return (extra, 1, int(rev))
+            # mercurial: "integer:globalid"
+            if ':' in rev and rev[:rev.index(':')].isdigit():
+                i = rev.index(':')
+                return (extra, 2, int(rev[:i]), rev)
+            # unknown
+            return (extra, 3, rev)
+        #
         keys = runs.keys()
-        keys.sort()
+        keys.sort(key=revkey)
         if len(runs) > cutnum:
             for rev in keys[:-cutnum]:
                 del runs[rev]

--- a/bot2/pypybuildbot/test/test_summary.py
+++ b/bot2/pypybuildbot/test/test_summary.py
@@ -300,6 +300,30 @@ def test__prune_runs():
         (4, 400): 40,
         (5,  20): 50
         }
+    # with Mercurial, we get revision numbers of the form "localid:universalid"
+    # these ones should sort after the subversion numbers
+    runs = {
+        (1, "100"): 10,
+        (2, "200"): 20,
+        (3, "300"): 30,
+        (3, "2:b57f9a090b62"): 40,
+        (3, "10:34197134282a"): 45,
+        (5, "20"): 50
+        }
+    summary.Summary._prune_runs(runs, 4)
+    assert len(runs) == 4
+    assert runs == {
+        (3, "300"): 30,
+        (3, "2:b57f9a090b62"): 40,
+        (3, "10:34197134282a"): 45,
+        (5, "20"): 50
+        }
+    summary.Summary._prune_runs(runs, 2)
+    assert len(runs) == 2
+    assert runs == {
+        (3, "10:34197134282a"): 45,
+        (5, "20"): 50
+        }
 
 
 def test_show_elapsed():



More information about the Pypy-commit mailing list