[Piuparts-commits] [SCM] piuparts git repository branch, piatti, updated. 0.49-105-gac1319a

Andreas Beckmann anbe at debian.org
Fri Mar 1 15:32:56 UTC 2013


The following commit has been merged in the piatti branch:
commit 87e23c30acc8a7b766510a0ed8693ee0b6ce57ba
Author: Andreas Beckmann <anbe at debian.org>
Date:   Sun Feb 17 18:00:26 2013 +0100

    lib/db: sort packages returned by reserve() by importance
    
    use descending waiting_count() as primary sort key
    (ideally we should use waiting_depth() as first sort key, but that
    attribute is not computed and waiting_count should be a useful
    approximation)
    and shuffle packages with the same waiting_count
    
    this should move packages from waiting-for-dependency-to-be-tested
    to waiting-to-be-tested state earlier
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>

diff --git a/debian/changelog b/debian/changelog
index 680774d..fbe7427 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,7 @@ piuparts (0.50) UNRELEASED; urgency=low
   * piupartslib/packagesdb.py:
     - Add Package.waiting_count() and friends, populated in calc_rrdep_count.
   * piuparts-master.py:
+    - Sort packages to be tested by importance, i.e. descending waiting_count.
   * piuparts-slave.py:
     - Tarball recreation can be disabled by setting max-tgz-age to 0.
     - Relax package existence checks to allow distupgrading to backports.
diff --git a/piupartslib/packagesdb.py b/piupartslib/packagesdb.py
index b082540..e9cee8b 100644
--- a/piupartslib/packagesdb.py
+++ b/piupartslib/packagesdb.py
@@ -26,6 +26,7 @@ Lars Wirzenius <liw at iki.fi>
 
 import logging
 import os
+import random
 import tempfile
 import time
 import UserDict
@@ -307,6 +308,7 @@ class PackagesDB:
         self._in_state = None
         self._package_state = {}
         self._recycle_mode = False
+        self._candidates_for_testing = None
         self.set_subdirs(ok="pass", fail="fail", evil="untestable",
                          reserved="reserved", morefail=["bugged", "affected"],
                          recycle="recycle")
@@ -638,13 +640,22 @@ class PackagesDB:
         return "does-not-exist"
 
     def _find_packages_ready_for_testing(self):
-        return self.get_pkg_names_in_state("waiting-to-be-tested")
+        if self._candidates_for_testing is None:
+            package_names = self.get_pkg_names_in_state("waiting-to-be-tested")
+            if len(package_names) > 1:
+                self.calc_rrdep_counts()
+                tuples = [(self.get_package(pn).waiting_count(), random.random(), pn)
+                        for pn in package_names]
+                self._candidates_for_testing = [self.get_package(x[2])
+                        for x in sorted(tuples, reverse = True)]
+            else:
+                self._candidates_for_testing = [self.get_package(pn)
+                        for pn in package_names]
+        return self._candidates_for_testing
 
     def reserve_package(self):
         all_but_recycle = [x for x in self._all if x != self._recycle]
-        pset = self._find_packages_ready_for_testing()
-        while (len(pset)):
-            p = self.get_package(pset.pop())
+        for p in self._find_packages_ready_for_testing():
             if self._recycle_mode and self._logdb.log_exists(p, [self._recycle]):
                 for vdir in all_but_recycle:
                     if self._logdb.log_exists(p, [vdir]):

-- 
piuparts git repository



More information about the Piuparts-commits mailing list