[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/ - improved listUpgradeSteps behavior
Yvo Schubbe
y.2008 at wcm-solutions.de
Tue Dec 23 12:55:00 EST 2008
Log message for revision 94293:
- improved listUpgradeSteps behavior
Changed:
U Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
U Products.GenericSetup/trunk/Products/GenericSetup/tests/upgrade.txt
U Products.GenericSetup/trunk/Products/GenericSetup/upgrade.py
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2008-12-23 16:57:18 UTC (rev 94292)
+++ Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2008-12-23 17:55:00 UTC (rev 94293)
@@ -4,6 +4,8 @@
GenericSetup 1.5.0 (unreleased)
-------------------------------
+- UpgradeSteps: Improved listUpgradeSteps behavior.
+
- Don't fail when a sub-item cannot be adapted after creation when
importing a folder. (https://bugs.launchpad.net/zope-cmf/+bug/300315)
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/upgrade.txt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/upgrade.txt 2008-12-23 16:57:18 UTC (rev 94292)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/upgrade.txt 2008-12-23 17:55:00 UTC (rev 94293)
@@ -49,6 +49,48 @@
>>> bool(_extractStepInfo(tool, 'ID', e, '2.0'))
True
+ with version restriction: all -> 2.0, no checker
+ ------------------------------------------------
+
+ >>> e = UpgradeEntity('TITLE', 'PROFILE', '*', '2.0', 'DESC')
+ >>> e.source is None
+ True
+ >>> e.dest
+ ('2', '0')
+
+ all <> unknown <> 2.0
+
+ >>> e.versionMatch(None)
+ True
+ >>> e.isProposed(tool, None)
+ True
+ >>> bool(_extractStepInfo(tool, 'ID', e, None))
+ True
+ >>> e.versionMatch('unknown')
+ True
+ >>> e.isProposed(tool, 'unknown')
+ True
+ >>> bool(_extractStepInfo(tool, 'ID', e, 'unknown'))
+ True
+
+ all <> 1.0 < 2.0
+
+ >>> e.versionMatch('1.0')
+ True
+ >>> e.isProposed(tool, '1.0')
+ True
+ >>> bool(_extractStepInfo(tool, 'ID', e, '1.0'))
+ True
+
+ all <> 2.0 == 2.0
+
+ >>> e.versionMatch('2.0')
+ False
+ >>> e.isProposed(tool, '2.0')
+ False
+ >>> bool(_extractStepInfo(tool, 'ID', e, '2.0'))
+ False
+
with version restriction: 1.0 -> 2.0, no checker
------------------------------------------------
@@ -66,19 +108,19 @@
True
>>> bool(_extractStepInfo(tool, 'ID', e, None))
True
- >>> e.versionMatch('unknown') # XXX: True
- False
- >>> e.isProposed(tool, 'unknown') # XXX: True
- False
+ >>> e.versionMatch('unknown')
+ True
+ >>> e.isProposed(tool, 'unknown')
+ True
>>> bool(_extractStepInfo(tool, 'ID', e, 'unknown'))
True
1.0 == 1.0 < 2.0
- >>> e.versionMatch('1.0') # XXX: True
- False
- >>> e.isProposed(tool, '1.0') # XXX: True
- False
+ >>> e.versionMatch('1.0')
+ True
+ >>> e.isProposed(tool, '1.0')
+ True
>>> bool(_extractStepInfo(tool, 'ID', e, '1.0'))
True
@@ -108,10 +150,10 @@
True
>>> bool(_extractStepInfo(tool, 'ID', e, None))
True
- >>> e.versionMatch('unknown') # XXX: True
- False
- >>> e.isProposed(tool, 'unknown') # XXX: True
- False
+ >>> e.versionMatch('unknown')
+ True
+ >>> e.isProposed(tool, 'unknown')
+ True
>>> bool(_extractStepInfo(tool, 'ID', e, 'unknown'))
True
@@ -150,10 +192,10 @@
True
>>> bool(_extractStepInfo(tool, 'ID', e, None))
True
- >>> e.versionMatch('unknown') # XXX: True
- False
- >>> e.isProposed(tool, 'unknown') # XXX: True
- False
+ >>> e.versionMatch('unknown')
+ True
+ >>> e.isProposed(tool, 'unknown')
+ True
>>> bool(_extractStepInfo(tool, 'ID', e, 'unknown'))
True
@@ -169,10 +211,10 @@
2.0 == 2.0 < 3.0
- >>> e.versionMatch('2.0') # XXX: True
- False
- >>> e.isProposed(tool, '2.0') # XXX: True
- False
+ >>> e.versionMatch('2.0')
+ True
+ >>> e.isProposed(tool, '2.0')
+ True
>>> bool(_extractStepInfo(tool, 'ID', e, '2.0'))
True
@@ -228,8 +270,8 @@
True
>>> e.isProposed(tool, '1.0')
False
- >>> bool(_extractStepInfo(tool, 'ID', e, '1.0')) # XXX: True
- False
+ >>> bool(_extractStepInfo(tool, 'ID', e, '1.0'))
+ True
all <> 2.0 <> all
@@ -237,8 +279,8 @@
True
>>> e.isProposed(tool, '2.0')
False
- >>> bool(_extractStepInfo(tool, 'ID', e, '2.0')) # XXX: True
- False
+ >>> bool(_extractStepInfo(tool, 'ID', e, '2.0'))
+ True
with combined restrictions: 1.0 -> 2.0, true checker
----------------------------------------------------
@@ -256,8 +298,8 @@
1.0 == 1.0 < 2.0
- >>> e.versionMatch('1.0') # XXX: True
- False
+ >>> e.versionMatch('1.0')
+ True
>>> e.isProposed(tool, '1.0')
True
>>> bool(_extractStepInfo(tool, 'ID', e, '1.0'))
@@ -329,8 +371,8 @@
2.0 == 2.0 < 3.0
- >>> e.versionMatch('2.0') # XXX: True
- False
+ >>> e.versionMatch('2.0')
+ True
>>> e.isProposed(tool, '2.0')
True
>>> bool(_extractStepInfo(tool, 'ID', e, '2.0'))
@@ -352,8 +394,8 @@
1.0 == 1.0 < 2.0
- >>> e.versionMatch('1.0') # XXX: True
- False
+ >>> e.versionMatch('1.0')
+ True
>>> e.isProposed(tool, '1.0')
False
>>> bool(_extractStepInfo(tool, 'ID', e, '1.0'))
@@ -425,8 +467,8 @@
2.0 == 2.0 < 3.0
- >>> e.versionMatch('2.0') # XXX: True
- False
+ >>> e.versionMatch('2.0')
+ True
>>> e.isProposed(tool, '2.0')
False
>>> bool(_extractStepInfo(tool, 'ID', e, '2.0'))
Modified: Products.GenericSetup/trunk/Products/GenericSetup/upgrade.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/upgrade.py 2008-12-23 16:57:18 UTC (rev 94292)
+++ Products.GenericSetup/trunk/Products/GenericSetup/upgrade.py 2008-12-23 17:55:00 UTC (rev 94293)
@@ -25,7 +25,7 @@
if isinstance(version, tuple):
version = '.'.join(version)
if version in (None, 'unknown', 'all'):
- return version
+ return None
return parse_version(version)
@@ -108,15 +108,12 @@
def versionMatch(self, source):
source = normalize_version(source)
- return (
- source is None or
- (self.source is None and
- (self.dest is None or source < normalize_version(self.dest))
- ) or
- (source <= normalize_version(self.source) and
- (self.dest is None or source > normalize_version(self.dest))
- )
- )
+ if source is None:
+ return True
+ start = normalize_version(self.source)
+ stop = normalize_version(self.dest)
+ return ((start is None or start == source) and
+ (stop is None or stop > source))
def isProposed(self, tool, source):
"""Check if a step can be applied.
@@ -187,11 +184,14 @@
"""Returns the info data structure for a given step.
"""
proposed = step.isProposed(tool, source)
- if (not proposed
- and source is not None
- and (step.source is None or
- normalize_version(source) > normalize_version(step.source))):
- return
+ if not proposed:
+ source = normalize_version(source)
+ if source is not None:
+ start = normalize_version(step.source)
+ stop = normalize_version(step.dest)
+ if ((start is not None and start < source) or
+ (stop is not None and stop <= source)):
+ return
info = {
'id': id,
'step': step,
More information about the Checkins
mailing list