From 1f55369acf68e2a4c591da45085c787a9d5b1484 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 14 Jun 2009 10:57:16 +0100 Subject: [PATCH] --stable sets all implementations with the same version at once --- stable.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/stable.py b/stable.py index 6eecb48..e64f5b2 100644 --- a/stable.py +++ b/stable.py @@ -1,5 +1,5 @@ from xml.dom import minidom -from zeroinstall.injector import namespaces +from zeroinstall.injector import namespaces, model from logging import warn def mark_stable(data): @@ -9,14 +9,19 @@ def mark_stable(data): all_impls = doc.documentElement.getElementsByTagNameNS(namespaces.XMLNS_IFACE, 'implementation') for x in all_impls: if get_stability(x) == 'testing': - testing.append(x) + testing.append((get_version(x), x)) if len(testing) == 0: raise Exception('No implementations are currently "testing"!') - impl = testing[-1] - if len(testing) > 1: - warn("Multiple 'testing' implementations - changing last one (%s)", impl.getAttribute('version')) + + testing = sorted(testing) + higest_version = testing[-1][0] + latest_testing = [impl for version, impl in testing if version == higest_version] + + if len(latest_testing) < len(testing): + warn("Multiple 'testing' versions - changing %d (of %d) with version %s", len(latest_testing), len(testing), model.format_version(higest_version)) - impl.setAttribute('stability', 'stable') + for impl in latest_testing: + impl.setAttribute('stability', 'stable') return doc.toxml() @@ -27,3 +32,14 @@ def get_stability(x): if stab: return stab x = x.parentNode return 'testing' + +def get_version(x): + root = x.ownerDocument.documentElement + while x is not root: + version = x.getAttribute('version') + if version: + mod = x.getAttribute('version-modifier') + if mod: version += mod + return model.parse_version(version) + x = x.parentNode + raise Exception("No version on %s" % x) -- 2.11.4.GIT