Rev 303: Add Repository.follow_branch() in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev
Jelmer Vernooij
jelmer at samba.org
Tue Dec 26 15:28:54 GMT 2006
------------------------------------------------------------
revno: 303
revision-id: jelmer at samba.org-20061226152813-dv0aagksub846kxu
parent: jelmer at samba.org-20061226044857-llotsyniugb18krc
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Tue 2006-12-26 16:28:13 +0100
message:
Add Repository.follow_branch()
modified:
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/test_repos.py test_repos.py-20060508151940-ddc49a59257ca712
=== modified file 'branch.py'
--- a/branch.py 2006-12-22 19:54:05 +0000
+++ b/branch.py 2006-12-26 15:28:13 +0000
@@ -112,7 +112,7 @@
def _generate_revision_history(self, last_revnum):
self._revision_history = []
- for (branch, _, rev) in self.repository._log.follow_history(
+ for (branch, rev) in self.repository.follow_branch(
self.branch_path, last_revnum):
self._revision_history.append(
self.repository.generate_revision_id(rev, branch))
=== modified file 'repository.py'
--- a/repository.py 2006-12-25 23:09:33 +0000
+++ b/repository.py 2006-12-26 15:28:13 +0000
@@ -316,7 +316,7 @@
SVN_PROP_BZR_MERGE, "").splitlines():
ancestry.extend(l.split("\n"))
- for (branch, paths, rev) in self._log.follow_history(path, revnum - 1):
+ for (branch, rev) in self.follow_branch(path, revnum - 1):
ancestry.append(self.generate_revision_id(rev, branch))
ancestry.append(None)
@@ -362,7 +362,7 @@
parent_path = None
parent_ids = []
- for (branch, paths, rev) in self._log.follow_history(path, revnum):
+ for (branch, rev) in self.follow_branch(path, revnum):
if rev < revnum:
parent_revnum = rev
parent_path = branch
@@ -499,6 +499,10 @@
def get_revision_sha1(self, revision_id):
return osutils.sha_string(self.get_revision_xml(revision_id))
+ def follow_branch(self, branch_path, revnum):
+ for (bp, _, rev) in self._log.follow_history(branch_path, revnum):
+ yield (bp, rev)
+
def has_signature_for_revision_id(self, revision_id):
# TODO: Retrieve from SVN_PROP_BZR_SIGNATURE
return False # SVN doesn't store GPG signatures. Perhaps
@@ -518,7 +522,7 @@
self._previous = revision_id
self._ancestry = {}
- for (branch, _, rev) in self._log.follow_history(path, revnum - 1):
+ for (branch, rev) in self.follow_branch(path, revnum - 1):
revid = self.generate_revision_id(rev, branch)
self._ancestry[self._previous] = [revid]
self._previous = revid
@@ -539,7 +543,6 @@
def get_physical_lock_status(self):
return False
-
def get_commit_builder(self, branch, parents, config, timestamp=None,
timezone=None, committer=None, revprops=None,
revision_id=None):
=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py 2006-12-26 02:35:40 +0000
+++ b/tests/test_repos.py 2006-12-26 15:28:13 +0000
@@ -29,6 +29,7 @@
from convert import load_dumpfile
import format
+from logwalker import NotSvnBranchPath
from scheme import TrunkBranchingScheme, NoBranchingScheme
from transport import SvnRaTransport
from tests import TestCaseWithSubversionRepository
@@ -47,6 +48,50 @@
self.assertEqual(bzrdir._format.get_format_description(), \
"Subversion Local Checkout")
+ def test_get_branch_log(self):
+ repos_url = self.make_client("a", "dc")
+ self.build_tree({'dc/foo': "data"})
+ self.client_add("dc/foo")
+ self.client_commit("dc", "My Message")
+
+ repos = Repository.open(repos_url)
+
+ self.assertEqual(1, len(list(repos.follow_branch("", 1))))
+
+ def test_get_branch_invalid_revision(self):
+ repos_url = self.make_client("a", "dc")
+ repos = Repository.open(repos_url)
+ self.assertRaises(NoSuchRevision, list,
+ repos.follow_branch("/", 20))
+
+ def test_branch_log_all(self):
+ repos_url = self.make_client("a", "dc")
+ self.build_tree({'dc/trunk/file': "data", "dc/foo/file":"data"})
+ self.client_add("dc/trunk")
+ self.client_add("dc/foo")
+ self.client_commit("dc", "My Message")
+
+ repos = Repository.open(repos_url)
+
+ self.assertEqual(1, len(list(repos.follow_branch(None, 1))))
+
+ def test_branch_log_specific(self):
+ repos_url = self.make_client("a", "dc")
+ self.build_tree({
+ 'dc/branches': None,
+ 'dc/branches/brancha': None,
+ 'dc/branches/branchab': None,
+ 'dc/branches/brancha/data': "data",
+ "dc/branches/branchab/data":"data"})
+ self.client_add("dc/branches")
+ self.client_commit("dc", "My Message")
+
+ repos = Repository.open(repos_url)
+ repos.set_branching_scheme(TrunkBranchingScheme())
+
+ self.assertEqual(1, len(list(repos.follow_branch("branches/brancha",
+ 1))))
+
def test_url(self):
""" Test repository URL is kept """
bzrdir = self.make_local_bzrdir('b', 'bc')
More information about the bazaar-commits
mailing list