Rev 332: More efficient implementation of follow_branch(). in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev
Jelmer Vernooij
jelmer at samba.org
Fri Dec 29 21:19:03 GMT 2006
------------------------------------------------------------
revno: 332
revision-id: jelmer at samba.org-20061229211551-5f6dzb5dk7z59iqg
parent: jelmer at samba.org-20061229203040-w86k8wxrfinr8bg2
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Fri 2006-12-29 22:15:51 +0100
message:
More efficient implementation of follow_branch().
modified:
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/test_branch.py test_branch.py-20060508162215-74ffeb5d608f8e20
=== modified file 'branch.py'
--- a/branch.py 2006-12-29 20:14:44 +0000
+++ b/branch.py 2006-12-29 21:15:51 +0000
@@ -103,8 +103,7 @@
return WorkingTree.open(to_location)
- def create_checkout(self, to_location, revision_id=None,
- lightweight=False):
+ def create_checkout(self, to_location, revision_id=None, lightweight=False):
if lightweight:
return self._create_lightweight_checkout(to_location, revision_id)
else:
=== modified file 'repository.py'
--- a/repository.py 2006-12-29 20:30:40 +0000
+++ b/repository.py 2006-12-29 21:15:51 +0000
@@ -323,14 +323,12 @@
return False
try:
- kind = self.transport.check_path(path.encode('utf8'), revnum)
+ return (svn.core.svn_node_none != self.transport.check_path(path.encode('utf8'), revnum))
except SubversionException, (_, num):
if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
return False
raise
- return (kind != svn.core.svn_node_none)
-
def revision_trees(self, revids):
for revid in revids:
yield self.revision_tree(revid)
@@ -495,7 +493,6 @@
yielded_paths.append(bp)
except NotBranchError:
pass
-
revnum-=1
def follow_branch(self, branch_path, revnum):
@@ -503,8 +500,28 @@
assert isinstance(revnum, int) and revnum >= 0
if not self.scheme.is_branch(branch_path):
raise errors.NotSvnBranchPath(branch_path, revnum)
- for (revnum, _, bp) in self.follow_branch_history(branch_path, revnum):
- yield (revnum, bp)
+ branch_path = branch_path.strip("/")
+
+ while revnum > 0:
+ paths = self._log.get_revision_paths(revnum, branch_path)
+ if paths == {}:
+ revnum-=1
+ continue
+ yield (branch_path, revnum)
+ # FIXME: what if one of the parents of branch_path was moved?
+ if (paths.has_key(branch_path) and
+ paths[branch_path][0] in ('R', 'A')):
+ if paths[branch_path][1] is None:
+ return
+ if not self.scheme.is_branch(paths[branch_path][1]):
+ # FIXME: if copyfrom_path is not a branch path,
+ # should simulate a reverse "split" of a branch
+ # for now, just make it look like the branch ended here
+ return
+ revnum = paths[branch_path][2]
+ branch_path = paths[branch_path][1]
+ continue
+ revnum-=1
def follow_branch_history(self, branch_path, revnum):
assert branch_path is not None
@@ -512,6 +529,7 @@
raise errors.NotSvnBranchPath(branch_path, revnum)
for (bp, paths, revnum) in self._log.follow_path(branch_path, revnum):
+ # FIXME: what if one of the parents of branch_path was moved?
if (paths.has_key(bp) and
paths[bp][1] is not None and
not self.scheme.is_branch(paths[bp][1])):
=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py 2006-12-22 19:54:05 +0000
+++ b/tests/test_branch.py 2006-12-29 21:15:51 +0000
@@ -431,8 +431,7 @@
def test_create_checkout(self):
repos_url = self.make_client('d', 'dc')
- self.build_tree({'dc/trunk': None,
- 'dc/trunk/hosts': 'hej1'})
+ self.build_tree({'dc/trunk': None, 'dc/trunk/hosts': 'hej1'})
self.client_add("dc/trunk")
self.client_commit("dc", "created trunk and added hosts") #1
@@ -440,8 +439,7 @@
oldbranch = Branch.open(url)
newtree = oldbranch.create_checkout("e")
- self.assertTrue(
- newtree.branch.repository.has_revision(
+ self.assertTrue(newtree.branch.repository.has_revision(
'svn-v%d:1@%s-trunk' % (MAPPING_VERSION, oldbranch.repository.uuid)))
self.assertTrue(os.path.exists("e/.bzr"))
More information about the bazaar-commits
mailing list