[calm - Cygwin server-side packaging maintenance script] branch master, updated. 20200220-1-g187fd2a

jturney-9JcytcrH/[email protected]
Newsgroups gmane.os.cygwin.cvs.apps
Message-ID <[email protected]>


https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=187fd2a99a5e65f2d37ab7b846263258c33a53c2

commit 187fd2a99a5e65f2d37ab7b846263258c33a53c2
Author: Jon Turney <[email protected]>
Date:   Fri Feb 21 15:33:17 2020 +0000

    Make keep-count: not retain test: versions
    
    (Note that we will always retain the version assigned to the test:
    stability level (the highest test: version, unless specified in
    override.hint), if any.
    
    For the moment, also retain 2 test versions, so the change in
    behaviour isn't large. This could be tuned down to retaining 1 test
    version in future.
    
    v2:
    Handle keep-count:0 correctly


Diff:
---
 calm/common_constants.py |  1 +
 calm/hint.py             |  1 +
 calm/package.py          | 20 +++++++++++++++++---
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/calm/common_constants.py b/calm/common_constants.py
index 5d884c4..7111dd6 100644
--- a/calm/common_constants.py
+++ b/calm/common_constants.py
@@ -71,6 +71,7 @@ MAILHOST = 'localhost'
 
 # defaults for package freshness
 DEFAULT_KEEP_COUNT = 3
+DEFAULT_KEEP_COUNT_TEST = 2
 DEFAULT_KEEP_DAYS = 0
 
 # different values to be used when we are not running on sourceware.org, but my
diff --git a/calm/hint.py b/calm/hint.py
index c2d702c..ec9bda9 100755
--- a/calm/hint.py
+++ b/calm/hint.py
@@ -66,6 +66,7 @@ hintkeys[override] = {
     'test': 'val',
     'keep': 'val',
     'keep-count': 'val',
+    'keep-count-test': 'val',
     'keep-days': 'val',
     'disable-check': 'val',
     'replace-versions': 'val',
diff --git a/calm/package.py b/calm/package.py
index 26072f2..dca89b2 100755
--- a/calm/package.py
+++ b/calm/package.py
@@ -1350,11 +1350,25 @@ def stale_packages(packages):
             else:
                 logging.error("package '%s' has non-existent keep: version '%s'" % (pn, v))
 
-        # mark as fresh the highest n versions, where n is given by the
+        # mark as fresh the highest n non-test versions, where n is given by the
         # keep-count: override hint, (defaulting to DEFAULT_KEEP_COUNT)
         keep_count = int(po.override_hints.get('keep-count', common_constants.DEFAULT_KEEP_COUNT))
-        for v in sorted(po.vermap.keys(), key=lambda v: SetupVersion(v), reverse=True)[0:keep_count]:
-            mark_package_fresh(packages, pn, v)
+        for v in sorted(po.vermap.keys(), key=lambda v: SetupVersion(v), reverse=True):
+            if 'test' not in po.version_hints[v]:
+                if keep_count <= 0:
+                    break
+                mark_package_fresh(packages, pn, v)
+                keep_count = keep_count - 1
+
+        # mark as fresh the highest n test versions, where n is given by the
+        # keep-count-test: override hint, (defaulting to DEFAULT_KEEP_COUNT_TEST)
+        keep_count = int(po.override_hints.get('keep-count-test', common_constants.DEFAULT_KEEP_COUNT_TEST))
+        for v in sorted(po.vermap.keys(), key=lambda v: SetupVersion(v), reverse=True):
+            if 'test' in po.version_hints[v]:
+                if keep_count <= 0:
+                    break
+                mark_package_fresh(packages, pn, v)
+                keep_count = keep_count - 1
 
         # mark as fresh all versions after the first one which is newer than
         # the keep-days: override hint, (defaulting to DEFAULT_KEEP_DAYS)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.