[Zope-CVS] CVS: Products/ZopeVersionControl - IVersionControl.py:1.2.2.1 Repository.py:1.3.2.1 VersionSupport.py:1.2.2.1
Chris McDonough
chrism@zope.com
Wed, 8 Jan 2003 14:06:32 -0500
Update of /cvs-repository/Products/ZopeVersionControl
In directory cvs.zope.org:/tmp/cvs-serv28019
Modified Files:
Tag: chrism-cte-branch
IVersionControl.py Repository.py VersionSupport.py
Log Message:
Redo interfaces and make objects implement an interface.
=== Products/ZopeVersionControl/IVersionControl.py 1.2 => 1.2.2.1 ===
--- Products/ZopeVersionControl/IVersionControl.py:1.2 Thu May 9 13:43:40 2002
+++ Products/ZopeVersionControl/IVersionControl.py Wed Jan 8 14:06:29 2003
@@ -15,23 +15,15 @@
from Interface import Interface
-
-class IVersionControl(Interface):
- """The version control interface serves as the main API for version
- control operations. The interface hides most of the details of
- version data storage and retrieval.
-
- In Zope 3, the version control interface will probably be implemented
- by a version control service. In the meantime, it may be implemented
- directly by repository implementations (or other things, like CMF
- tools).
-
- The goal of this version of the version control interface is to
- support simple linear versioning with support for labelled versions.
- Future versions or extensions of this interface will likely support
- more advanced version control features such as concurrent lines of
- descent (activities) and collection versioning."""
-
+class IVersionRepository(Interface):
+ """
+ The interface implemented by the repository object.
+
+ In Zope 3, the version control interface will probably be implemented
+ by a version control service. In the meantime, it may be implemented
+ directly by repository implementations (or other things, like CMF
+ tools).
+ """
def isAVersionableResource(object):
"""
Returns true if the given object is a versionable resource.
@@ -146,6 +138,180 @@
"""
def getVersionIds(object):
+ """
+ Return a sequence of the (string) version ids corresponding to the
+ available versions of an object. This should be used by UI elements
+ to populate version selection widgets, etc.
+
+ Permission: Use version control
+ """
+
+ def getLabelsForResource(object):
+ """
+ Return a sequence of the (string) labels corresponding to the
+ versions of the given object that have been associated with a
+ label. This should be used by UI elements to populate version
+ selection widgets, etc.
+
+ Permission: Use version control
+ """
+
+ def getLogEntries(object):
+ """
+ Return a sequence of LogEntry objects (most recent first) that
+ are associated with a version-controlled object.
+
+ Permission: Use version control
+ """
+
+
+class IVersionControl(Interface):
+ """
+ The version control interface serves as the main API for version
+ control operations. The interface hides most of the details of
+ version data storage and retrieval.
+
+ The goal of this version of the version control interface is to
+ support simple linear versioning with support for labelled versions.
+ Future versions or extensions of this interface will likely support
+ more advanced version control features such as concurrent lines of
+ descent (activities) and collection versioning.
+
+ This is the interface implemented by VersionSupport, which is mixed
+ (jammed) in to SimpleItem during initialization.
+ """
+
+ def getRepository():
+ """
+ Returns the closest version repository via acquisition.
+
+ Raises VersionControlError if no repository can be found.
+
+ Permission: private.
+ """
+
+ def isAVersionableResource(object):
+ """
+ Returns true if the given object is a versionable resource.
+
+ Permission: public
+ """
+
+ def isUnderVersionControl():
+ """
+ Returns true if the given object is under version control.
+
+ Permission: public
+ """
+
+ def isResourceUpToDate():
+ """
+ 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 object is not under version control, a VersionControlError
+ will be raised.
+
+ Permission: public
+ """
+
+ def isResourceChanged():
+ """
+ Return true if the state of a resource has changed in a transaction
+ *after* the version bookkeeping was saved. Note that this method is
+ not appropriate for detecting changes within a transaction!
+
+ If the object is not under version control, a VersionControlError
+ will be raised.
+
+ Permission: public
+ """
+
+ def getVersionInfo():
+ """
+ Return the VersionInfo associated with the given object. The
+ VersionInfo object contains version control bookkeeping information.
+
+ If the object is not under version control, a VersionControlError
+ will be raised.
+
+ Permission: public
+ """
+
+ def applyVersionControl():
+ """
+ Place the given object under version control. A VersionControlError
+ will be raised if the object is already under version control or
+ if a repository cannot be found.
+
+ After being placed under version control, the resource is logically
+ in the 'checked-in' state.
+
+ Permission: Use version control
+ """
+
+ def checkoutResource():
+ """
+ Put the object into the 'checked-out' state, allowing changes
+ to be made to the object. If the object is not under version
+ control or the object is already checked out, a
+ VersionControlError will be raised.
+
+ Permission: Use version control
+ """
+
+ def checkinResource(message=''):
+ """
+ Check-in (create a new version) of the object, updating the
+ state and bookkeeping information of the object. The optional
+ message should describe the changes being committed. If the
+ object is not under version control or is already in the
+ checked-in state, a VersionControlError will be raised.
+
+ Permission: Use version control
+ """
+
+ def uncheckoutResource():
+ """
+ Discard changes to the object made since the last checkout.
+ If the object is not under version control or is not checked
+ out, a VersionControlError will be raised.
+ """
+
+ def updateResource(selector=None):
+ """
+ Update the state of the given object to that of a specific version
+ of the object. The object must be in the checked-in state to be
+ updated. The selector must be a string (version id, activity id,
+ label or date) that is used to select a version from the version
+ history.
+
+ Permission: Use version control
+ """
+
+ def labelResource(label, force=None):
+ """
+ Associate the given resource with a label. If force is true, then
+ any existing association with the given label will be removed and
+ replaced with the new association. If force is false and there is
+ an existing association with the given label, a VersionControlError
+ will be raised.
+
+ Permission: Use version control
+ """
+
+ def getVersionOfResource(history_id, selector):
+ """
+ Given a version history id and a version selector, return the
+ object as of that version. Note that the returned object has no
+ acquisition context. The selector must be a string (version id,
+ activity id, label or date) that is used to select a version
+ from the version history.
+
+ Permission: Use version control
+ """
+
+ def getVersionIds():
"""
Return a sequence of the (string) version ids corresponding to the
available versions of an object. This should be used by UI elements
=== Products/ZopeVersionControl/Repository.py 1.3 => 1.3.2.1 ===
--- Products/ZopeVersionControl/Repository.py:1.3 Wed Jun 12 13:57:43 2002
+++ Products/ZopeVersionControl/Repository.py Wed Jan 8 14:06:29 2003
@@ -24,11 +24,14 @@
from BTrees.OIBTree import OIBTree
from EventLog import LogEntry
import time, Utility
+from IVersionControl import IVersionRepository
class Repository(Implicit, Persistent):
"""The repository implementation manages the actual data of versions
and version histories. It does not handle user interface issues."""
+
+ __implements__ = (IVersionRepository,)
def __init__(self):
# These keep track of symbolic label and branch names that
=== Products/ZopeVersionControl/VersionSupport.py 1.2 => 1.2.2.1 ===
--- Products/ZopeVersionControl/VersionSupport.py:1.2 Thu May 9 13:43:40 2002
+++ Products/ZopeVersionControl/VersionSupport.py Wed Jan 8 14:06:29 2003
@@ -17,7 +17,7 @@
from Globals import DTMLFile, InitializeClass
from Utility import VersionControlError
from Utility import use_vc_permission
-
+from IVersionControl implement IVersionControl
def _isAVersionableResource(object):
if hasattr(object, '__non_versionable__'):
@@ -27,6 +27,8 @@
class VersionSupport(ExtensionClass.Base):
"""Mixin class to support version-controllable resources."""
+
+ __implements__ = (IVersionControl,)
manage_options=(
{'label': 'Version Control', 'action':'versionControlMain',