This should preserve the pre-existing behavior, where if latest is set
to True, only the latest builds in a tag are returned, and if latest is
set to False, all the builds in a tag are returned.
The new behavior is a kind of middleground, where you can set latest=3,
and only the latest three builds for each package in a tag are returned.
We want this ultimately for mashing rawhide so we can create a downgrade
path for people if new builds break them.
https://bugzilla.redhat.com/show_bug.cgi?id=1082830
---
hub/kojihub.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/hub/kojihub.py b/hub/kojihub.py
index f2a2c09..509a30b 100644
--- a/hub/kojihub.py
+++ b/hub/kojihub.py
@@ -1,7 +1,7 @@
# Python library
# kojihub - library for koji's XMLRPC interface
-# Copyright (c) 2005-2010 Red Hat
+# Copyright (c) 2005-2014 Red Hat
#
# Koji is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -24,6 +24,7 @@
import base64
import calendar
import cgi
+import collections
import koji
import koji.auth
import koji.db
@@ -1123,6 +1124,7 @@ def
readTaggedBuilds(tag,event=None,inherit=False,latest=False,package=None,owne
set inherit=True to follow inheritance
set event to query at a time in the past
set latest=True to get only the latest build per package
+ set latest=N to get only the N latest tagged RPMS
If type is not None, restrict the list to builds of the given type. Currently the
supported
types are 'maven', 'win', and 'image'.
@@ -1191,7 +1193,7 @@ def
readTaggedBuilds(tag,event=None,inherit=False,latest=False,package=None,owne
# i.e. latest first
builds = []
- seen = {} # used to enforce the 'latest' option
+ seen = collections.defaultdict(0) # used to enforce the 'latest' option
for tagid in taglist:
#log_error(koji.db._quoteparams(q,locals()))
for build in _multiRow(q, locals(), [pair[1] for pair in fields]):
@@ -1204,10 +1206,10 @@ def
readTaggedBuilds(tag,event=None,inherit=False,latest=False,package=None,owne
# list should take priority
continue
if latest:
- if seen.has_key(pkgid):
- #only take the first (note ordering in query above)
+ if (latest is True and seen[pkgid]) or seen[pkgid] >= latest:
+ #only take the first N (note ordering in query above)
continue
- seen[pkgid] = 1
+ seen[pkgid] = seen[pkgid] + 1
builds.append(build)
return builds
@@ -1218,6 +1220,7 @@ def readTaggedRPMS(tag, package=None, arch=None,
event=None,inherit=False,latest
set inherit=True to follow inheritance
set event to query at a time in the past
set latest=False to get all tagged RPMS (not just from the latest builds)
+ set latest=N to get only the N latest tagged RPMS
If type is not None, restrict the list to rpms from builds of the given type.
Currently the
supported types are 'maven' and 'win'.
@@ -1307,6 +1310,7 @@ def readTaggedArchives(tag, package=None, event=None, inherit=False,
latest=True
set inherit=True to follow inheritance
set event to query at a time in the past
set latest=False to get all tagged archives (not just from the latest builds)
+ set latest=N to get only the N latest tagged RPMS
If type is not None, restrict the listing to archives of the given type. Currently
the supported types are 'maven' and 'win'.
--
1.9.3