[Zope-CVS] CVS: Products/ZopeVersionControl - IVersionControl.py:1.3 Repository.py:1.5

Shane Hathaway shane@zope.com
Tue, 11 Feb 2003 16:49:24 -0500


Update of /cvs-repository/Products/ZopeVersionControl
In directory cvs.zope.org:/tmp/cvs-serv23885

Modified Files:
	IVersionControl.py Repository.py 
Log Message:
Added an optional argument to isResourceUpToDate(), 'require_branch'.  If
require_branch is set, isResourceUpToDate() only returns true if the object
is on the mainline or a branch, with no sticky tag.


=== Products/ZopeVersionControl/IVersionControl.py 1.2 => 1.3 ===
--- Products/ZopeVersionControl/IVersionControl.py:1.2	Thu May  9 13:43:40 2002
+++ Products/ZopeVersionControl/IVersionControl.py	Tue Feb 11 16:49:23 2003
@@ -46,10 +46,15 @@
         Permission: public
         """
 
-    def isResourceUpToDate(object):
+    def isResourceUpToDate(object, require_branch=0):
         """
         Returns true if a resource is based on the latest version. Note
         that the latest version is in the context of any activity (branch).
+
+        If the require_branch flag is true, this method returns false if
+        the resource is updated to a particular version, label, or date.
+        Useful for determining whether a call to checkoutResource()
+        will succeed.
 
         Permission: public
         """


=== Products/ZopeVersionControl/Repository.py 1.4 => 1.5 ===
--- Products/ZopeVersionControl/Repository.py:1.4	Wed Jan 15 17:17:46 2003
+++ Products/ZopeVersionControl/Repository.py	Tue Feb 11 16:49:23 2003
@@ -82,12 +82,18 @@
         return hasattr(object, '__vc_info__')
 
     security.declarePublic('isResourceUpToDate')
-    def isResourceUpToDate(self, object):
+    def isResourceUpToDate(self, object, require_branch=0):
         info = self.getVersionInfo(object)
         history = self.getVersionHistory(info.history_id)
         branch = 'mainline'
-        if info.sticky and (info.sticky[0] == 'B'):
-            branch = info.sticky[1]
+        if info.sticky:
+            if info.sticky[0] == 'B':
+                branch = info.sticky[1]
+            elif require_branch:
+                # The object is updated to a particular version
+                # rather than a branch.  The caller
+                # requires a branch.
+                return 0
         return history.isLatestVersion(info.version_id, branch)
 
     security.declarePublic('isResourceChanged')