[Checkins] SVN: zc.vault/trunk/src/zc/vault/ Fix a subtle bug with rename after the vault freeze (commit).

Zvezdan Petkovic zvezdan at zope.com
Fri Aug 3 10:24:51 EDT 2007


Log message for revision 78554:
  Fix a subtle bug with rename after the vault freeze (commit).
  
  Fix applied, test written as a footnote, added option to interpret
  footnotes to a test runner.
  
  

Changed:
  U   zc.vault/trunk/src/zc/vault/README.txt
  U   zc.vault/trunk/src/zc/vault/tests.py
  U   zc.vault/trunk/src/zc/vault/vault.py

-=-
Modified: zc.vault/trunk/src/zc/vault/README.txt
===================================================================
--- zc.vault/trunk/src/zc/vault/README.txt	2007-08-03 01:34:35 UTC (rev 78553)
+++ zc.vault/trunk/src/zc/vault/README.txt	2007-08-03 14:24:49 UTC (rev 78554)
@@ -1430,6 +1430,8 @@
 copy between inventories. At the time of writing, this use case is
 unnecessary, and doing so will have unspecified behavior.
 
+See also [#rename_after_freeze]_ for an important test case.
+
 We have now discussed the core API for the vault system for basic use.  A
 number of other use cases are important, however:
 
@@ -2487,3 +2489,26 @@
 
 A special reference that knows both vault and token?
 
+
+Footnotes
+=========
+
+.. [#rename_after_freeze] A test for a subtle bug in revision <= 78553
+
+One important case, at least for the regression testing is an attempt to
+rename an item after the vault has been frozen.  Since we have just
+committed, this is the right time to try that.  Let's create a local
+copy of an inventory and try to rename some items on it.
+
+    >>> v.manifest._z_frozen
+    True
+    >>> l = Inventory(Manifest(v.manifest))
+    >>> l.manifest._z_frozen
+    False
+    >>> l.contents('abe').items()
+    [('old_donald', <Demo u'd1'>), ('new_donald', <Demo u'Demo-2'>)]
+    >>> l.contents('abe')('old_donald').moveTo(l.contents('abe'), 'bob')
+    >>> l.contents('abe')('new_donald').moveTo(l.contents('abe'), 'donald')
+    >>> l.contents('abe').items()
+    [('bob', <Demo u'd1'>), ('donald', <Demo u'Demo-2'>)]
+

Modified: zc.vault/trunk/src/zc/vault/tests.py
===================================================================
--- zc.vault/trunk/src/zc/vault/tests.py	2007-08-03 01:34:35 UTC (rev 78553)
+++ zc.vault/trunk/src/zc/vault/tests.py	2007-08-03 14:24:49 UTC (rev 78554)
@@ -144,7 +144,8 @@
     tests = (
         doctest.DocFileSuite(
             'README.txt',
-            setUp=setUp, tearDown=tearDown, checker=checker),
+            setUp=setUp, tearDown=tearDown, checker=checker,
+            optionflags=doctest.INTERPRET_FOOTNOTES),
         doctest.DocFileSuite(
             'versions.txt',
             setUp=setUp, tearDown=tearDown),

Modified: zc.vault/trunk/src/zc/vault/vault.py
===================================================================
--- zc.vault/trunk/src/zc/vault/vault.py	2007-08-03 01:34:35 UTC (rev 78553)
+++ zc.vault/trunk/src/zc/vault/vault.py	2007-08-03 14:24:49 UTC (rev 78554)
@@ -434,9 +434,9 @@
             raise ValueError('May not move item to within itself')
         parent = self.parent
         if old_name:
-            del self.parent[old_name]
+            del parent[old_name]
         if (parent is None or
-            clean_location.relationship is not parent.relationship):
+            clean_location.relationship.token != parent.relationship.token):
             location.makeMutable()
         else:
             location = parent



More information about the Checkins mailing list