[Checkins] SVN: Products.ZopeVersionControl/trunk/ Made sure the VersionHistory.BranchInfo class fulfill the API, providing a getId method. Added missing security declarations.
Dorneles Tremea
dorneles at x3ng.com.br
Fri Sep 10 14:29:07 EDT 2010
Log message for revision 116297:
Made sure the VersionHistory.BranchInfo class fulfill the API, providing a getId method. Added missing security declarations.
Changed:
U Products.ZopeVersionControl/trunk/CHANGES.txt
U Products.ZopeVersionControl/trunk/Products/ZopeVersionControl/VersionHistory.py
A Products.ZopeVersionControl/trunk/Products/ZopeVersionControl/tests/testVersionHistory.py
-=-
Modified: Products.ZopeVersionControl/trunk/CHANGES.txt
===================================================================
--- Products.ZopeVersionControl/trunk/CHANGES.txt 2010-09-10 17:38:01 UTC (rev 116296)
+++ Products.ZopeVersionControl/trunk/CHANGES.txt 2010-09-10 18:29:06 UTC (rev 116297)
@@ -4,11 +4,13 @@
1.1.3 - unreleased
------------------
+- Made sure the VersionHistory.BranchInfo class fulfill the API,
+ providing a getId method. Added missing security declarations.
1.1.2 - 2010-08-05
------------------
-- Make sure we cast MAX32 to an int, as ``2**31`` would be automatically
+- Made sure we cast MAX32 to an int, as ``2**31`` would be automatically
overflow to a long on 32bit Python's.
1.1.1 - 2010-08-04
Modified: Products.ZopeVersionControl/trunk/Products/ZopeVersionControl/VersionHistory.py
===================================================================
--- Products.ZopeVersionControl/trunk/Products/ZopeVersionControl/VersionHistory.py 2010-09-10 17:38:01 UTC (rev 116296)
+++ Products.ZopeVersionControl/trunk/Products/ZopeVersionControl/VersionHistory.py 2010-09-10 18:29:06 UTC (rev 116297)
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Foundation and Contributors.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__version__='$Revision: 1.4 $'[11:-2]
@@ -204,7 +204,7 @@
# up to the caller to decide what to do in this situation.
if branch.root is None:
return None
-
+
# If the branch has a root (a version in another branch), then
# we check the root and do it again with the ancestor branch.
rootver = self._versions[branch.root]
@@ -222,6 +222,7 @@
return self._branches[branch_id].versionIds()
return self._versions.keys()
+
InitializeClass(VersionHistory)
@@ -230,6 +231,8 @@
maintains the name of the branch, the version id of the root of
the branch and indices to allow for efficient lookups."""
+ security = ClassSecurityInfo()
+
def __init__(self, name, root):
# m_order maintains a newest-first mapping of int -> version id.
# m_date maintains a mapping of a packed date (int # of minutes
@@ -242,6 +245,12 @@
self.name = name
self.root = root
+ security.declarePublic('getId')
+ def getId(self):
+ """Return the name of the object as string."""
+ return self.name
+
+ security.declarePrivate('append')
def append(self, version):
"""Append a version to the branch information. Note that this
does not store the actual version, but metadata about the
@@ -254,10 +263,12 @@
timestamp = int(version.date_created / 60.0)
self.m_date[timestamp] = key
+ security.declarePrivate('versionIds')
def versionIds(self):
"""Return a newest-first sequence of version ids in the branch."""
return self.m_order.values()
+ security.declarePrivate('latest')
def latest(self):
"""Return the version id of the latest version in the branch."""
mapping = self.m_order
@@ -268,4 +279,5 @@
def __len__(self):
return len(self.m_order)
+
InitializeClass(BranchInfo)
Added: Products.ZopeVersionControl/trunk/Products/ZopeVersionControl/tests/testVersionHistory.py
===================================================================
--- Products.ZopeVersionControl/trunk/Products/ZopeVersionControl/tests/testVersionHistory.py (rev 0)
+++ Products.ZopeVersionControl/trunk/Products/ZopeVersionControl/tests/testVersionHistory.py 2010-09-10 18:29:06 UTC (rev 116297)
@@ -0,0 +1,42 @@
+##############################################################################
+#
+# Copyright (c) 2001 Zope Foundation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+"""Test the VersionHistory internals.
+
+$Id$
+"""
+import unittest
+
+from common import common_setUp
+from common import common_tearDown
+
+
+class VersionHistoryTests(unittest.TestCase):
+
+ setUp = common_setUp
+ tearDown = common_tearDown
+
+ def testBranchHaveName(self):
+ self.repository.applyVersionControl(self.document1)
+ info = self.repository.getVersionInfo(self.document1)
+ history = self.repository.getVersionHistory(info.history_id)
+ branch = history.createBranch('foo', None)
+ self.assertEqual(branch.getId(), 'foo')
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(VersionHistoryTests))
+ return suite
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: Products.ZopeVersionControl/trunk/Products/ZopeVersionControl/tests/testVersionHistory.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
More information about the checkins
mailing list