[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/versioncontrol/
Changed makeBranch to automatically select branch ids. Specifying
Jim Fulton
jim at zope.com
Tue May 24 12:09:06 EDT 2005
Log message for revision 30488:
Changed makeBranch to automatically select branch ids. Specifying
branch ids is still possible but is not "supported" in the sense that
it isn't documented or tested, and may not be allowed in the future.
Changed:
U Zope3/trunk/src/zope/app/versioncontrol/README.txt
U Zope3/trunk/src/zope/app/versioncontrol/interfaces.py
U Zope3/trunk/src/zope/app/versioncontrol/repository.py
-=-
Modified: Zope3/trunk/src/zope/app/versioncontrol/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/versioncontrol/README.txt 2005-05-24 01:33:54 UTC (rev 30487)
+++ Zope3/trunk/src/zope/app/versioncontrol/README.txt 2005-05-24 16:08:36 UTC (rev 30488)
@@ -552,12 +552,16 @@
Now we can use this object to make a branch:
- >>> repository.makeBranch(obranch, '2-branch')
+ >>> repository.makeBranch(obranch)
+ '2.1'
+The `makeBranch` method returns the new branch name. This is needed
+to check out a working version for the branch.
+
To create a new version on the branch, we first have to check out the
object on the branch:
- >>> repository.updateResource(obranch, '2-branch')
+ >>> repository.updateResource(obranch, '2.1')
>>> repository.checkoutResource(obranch)
>>> repository.getVersionInfo(obranch).version_id
@@ -572,8 +576,10 @@
>>> transaction.commit()
>>> repository.getVersionInfo(obranch).version_id
- '2-branch.1'
+ '2.1.1'
+Note that the new version number is the branch name followed by a
+number on the branch.
Supporting separately versioned subobjects
------------------------------------------
Modified: Zope3/trunk/src/zope/app/versioncontrol/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/versioncontrol/interfaces.py 2005-05-24 01:33:54 UTC (rev 30487)
+++ Zope3/trunk/src/zope/app/versioncontrol/interfaces.py 2005-05-24 16:08:36 UTC (rev 30488)
@@ -186,10 +186,12 @@
Permission: Use version control
"""
- def makeBranch(object, branch_id):
- """Create a new branch with the given branch id
+ def makeBranch(object):
+ """Create a new branch, returning the branch id.
The branch is created from the object's version.
+
+ A branch id is computed and returned.
"""
CHECKED_OUT = 0
Modified: Zope3/trunk/src/zope/app/versioncontrol/repository.py
===================================================================
--- Zope3/trunk/src/zope/app/versioncontrol/repository.py 2005-05-24 01:33:54 UTC (rev 30487)
+++ Zope3/trunk/src/zope/app/versioncontrol/repository.py 2005-05-24 16:08:36 UTC (rev 30488)
@@ -390,7 +390,7 @@
history = self.getVersionHistory(info.history_id)
history.labelVersion(info.version_id, label, force)
- def makeBranch(self, object, branch_id):
+ def makeBranch(self, object, branch_id=None):
# Note - this is not part of the official version control API yet.
# It is here to allow unit testing of the architectural aspects
# that are already in place to support activities in the future.
@@ -401,8 +401,19 @@
'The selected resource must be checked in.'
)
- branch_id = branch_id or None
+ history = self.getVersionHistory(info.history_id)
+ if branch_id is None:
+ i = 1
+ while 1:
+ branch_id = "%s.%d" % (info.version_id, i)
+ if not (history._branches.has_key(branch_id)
+ or
+ self._labels.has_key(branch_id)
+ ):
+ break
+ i += 1
+
# Make sure that branch ids and labels do not collide.
if self._labels.has_key(branch_id) or branch_id == 'mainline':
raise VersionControlError(
@@ -412,8 +423,6 @@
if not self._branches.has_key(branch_id):
self._branches[branch_id] = 1
- history = self.getVersionHistory(info.history_id)
-
if history._branches.has_key(branch_id):
raise VersionControlError(
'The resource is already associated with the given branch.'
@@ -421,6 +430,8 @@
history.createBranch(branch_id, info.version_id)
+ return branch_id
+
def getVersionOfResource(self, history_id, selector):
history = self.getVersionHistory(history_id)
sticky = None
More information about the Zope3-Checkins
mailing list