Rev 306: Move scheme-specific code out of LogWalker. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev
Jelmer Vernooij
jelmer at samba.org
Tue Dec 26 17:00:52 GMT 2006
------------------------------------------------------------
revno: 306
revision-id: jelmer at samba.org-20061226170019-y9g1pa78mbe723kk
parent: jelmer at samba.org-20061226164250-ofgmt9boudgxei2y
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Tue 2006-12-26 18:00:19 +0100
message:
Move scheme-specific code out of LogWalker.
modified:
logwalker.py logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/test_logwalker.py test_logwalker.py-20060622141944-pkocc3rj8g62ukbi-1
tests/test_repos.py test_repos.py-20060508151940-ddc49a59257ca712
=== modified file 'logwalker.py'
--- a/logwalker.py 2006-12-26 16:42:50 +0000
+++ b/logwalker.py 2006-12-26 17:00:19 +0000
@@ -192,30 +192,6 @@
continue_revnum = revpaths[branch_path][2]
branch_path = revpaths[branch_path][1]
- def find_branches(self, revnum, scheme):
- """Find all branches that were changed in the specified revision number.
-
- :param revnum: Revision to search for branches.
- """
- created_branches = {}
-
- for i in range(revnum+1):
- if i == 0:
- paths = {'': ('A', None, None)}
- else:
- paths = self.get_revision_paths(i)
- for p in paths:
- if scheme.is_branch(p):
- if paths[p][0] in ('R', 'D'):
- del created_branches[p]
- yield (p, i, False)
-
- if paths[p][0] in ('A', 'R'):
- created_branches[p] = i
-
- for p in created_branches:
- yield (p, i, True)
-
def get_revision_paths(self, revnum):
"""Obtain dictionary with all the changes in a particular revision.
=== modified file 'repository.py'
--- a/repository.py 2006-12-26 16:42:50 +0000
+++ b/repository.py 2006-12-26 17:00:19 +0000
@@ -28,7 +28,7 @@
from bzrlib.repository import Repository, RepositoryFormat
from bzrlib.revision import Revision, NULL_REVISION
from bzrlib.transport import Transport
-from bzrlib.trace import mutter
+from bzrlib.trace import mutter, warning
from svn.core import SubversionException, Pool
import svn.core
@@ -235,17 +235,15 @@
mutter("Connected to repository with UUID %s" % self.uuid)
- mutter('svn latest-revnum')
- self._latest_revnum = transport.get_latest_revnum()
-
cache_file = os.path.join(self.create_cache_dir(), 'cache-v1')
if not cachedbs.has_key(cache_file):
cachedbs[cache_file] = sqlite3.connect(cache_file)
self.cachedb = cachedbs[cache_file]
- self._log = logwalker.LogWalker(transport=transport,
- cache_db=self.cachedb,
- last_revnum=self._latest_revnum)
+ mutter('svn latest-revnum')
+ self._latest_revnum = transport.get_latest_revnum()
+ self._log = logwalker.LogWalker(transport=transport, cache_db=self.cachedb,
+ last_revnum=self._latest_revnum)
self.branchprop_list = BranchPropertyList(self._log, self.cachedb)
self.fileid_map = SimpleFileIdMap(self, self.cachedb)
@@ -531,7 +529,7 @@
if branch_path is not None and not self.scheme.is_branch(branch_path):
# FIXME: if copyfrom_path is not a branch path,
# should simulate a reverse "split" of a branch
- warn('directory %r:%d upgraded to branch. This is not currently supported.' %
+ warning('directory %r:%d upgraded to branch. This is not currently supported.' %
(branch_path, revnum))
changed_paths = {}
@@ -583,9 +581,31 @@
return self._ancestry
def find_branches(self, revnum=None):
+ """Find all branches that were changed in the specified revision number.
+
+ :param revnum: Revision to search for branches.
+ """
if revnum is None:
- revnum = self.transport.get_latest_revnum()
- return self._log.find_branches(revnum, self.scheme)
+ revnum = self._latest_revnum
+
+ created_branches = {}
+
+ for i in range(revnum+1):
+ if i == 0:
+ paths = {'': ('A', None, None)}
+ else:
+ paths = self._log.get_revision_paths(i)
+ for p in paths:
+ if self.scheme.is_branch(p):
+ if paths[p][0] in ('R', 'D'):
+ del created_branches[p]
+ yield (p, i, False)
+
+ if paths[p][0] in ('A', 'R'):
+ created_branches[p] = i
+
+ for p in created_branches:
+ yield (p, i, True)
def is_shared(self):
"""Return True if this repository is flagged as a shared repository."""
=== modified file 'tests/test_logwalker.py'
--- a/tests/test_logwalker.py 2006-12-26 16:42:50 +0000
+++ b/tests/test_logwalker.py 2006-12-26 17:00:19 +0000
@@ -78,13 +78,6 @@
self.assertEqual(1, len(list(walker.follow_history("branches/brancha",
1))))
- def test_find_branches_no(self):
- repos_url = self.make_client("a", "dc")
-
- walker = logwalker.LogWalker(transport=SvnRaTransport(repos_url))
-
- self.assertEqual([("", 0, True)], list(walker.find_branches(0, NoBranchingScheme())))
-
def test_find_latest_none(self):
repos_url = self.make_client("a", "dc")
self.build_tree({'dc/branches': None})
@@ -163,46 +156,6 @@
self.assertEqual(2, walker.find_latest_change("branches/foo", 2))
- def test_find_branches_no_later(self):
- repos_url = self.make_client("a", "dc")
-
- walker = logwalker.LogWalker(transport=SvnRaTransport(repos_url))
-
- self.assertEqual([("", 0, True)], list(walker.find_branches(0, NoBranchingScheme())))
-
- def test_find_branches_trunk_empty(self):
- repos_url = self.make_client("a", "dc")
-
- walker = logwalker.LogWalker(transport=SvnRaTransport(repos_url))
-
- self.assertEqual([], list(walker.find_branches(0, TrunkBranchingScheme())))
-
- def test_find_branches_trunk_one(self):
- repos_url = self.make_client("a", "dc")
-
- walker = logwalker.LogWalker(transport=SvnRaTransport(repos_url))
-
- self.build_tree({'dc/trunk/foo': "data"})
- self.client_add("dc/trunk")
- self.client_commit("dc", "My Message")
-
- self.assertEqual([("trunk", 1, True)], list(walker.find_branches(1, TrunkBranchingScheme())))
-
- def test_find_branches_removed(self):
- repos_url = self.make_client("a", "dc")
-
- walker = logwalker.LogWalker(transport=SvnRaTransport(repos_url))
-
- self.build_tree({'dc/trunk/foo': "data"})
- self.client_add("dc/trunk")
- self.client_commit("dc", "My Message")
-
- self.client_delete("dc/trunk")
- self.client_commit("dc", "remove")
-
- self.assertEqual([("trunk", 1, True)], list(walker.find_branches(1, TrunkBranchingScheme())))
- self.assertEqual([("trunk", 2, False)], list(walker.find_branches(2, TrunkBranchingScheme())))
-
def test_follow_history_branch_replace(self):
repos_url = self.make_client("a", "dc")
=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py 2006-12-26 16:12:40 +0000
+++ b/tests/test_repos.py 2006-12-26 17:00:19 +0000
@@ -92,6 +92,58 @@
self.assertEqual(1, len(list(repos.follow_branch("branches/brancha",
1))))
+ def test_find_branches_no(self):
+ repos_url = self.make_client("a", "dc")
+
+ repos = Repository.open(repos_url)
+ repos.set_branching_scheme(NoBranchingScheme())
+
+ self.assertEqual([("", 0, True)], list(repos.find_branches(0)))
+
+ def test_find_branches_no_later(self):
+ repos_url = self.make_client("a", "dc")
+
+ repos = Repository.open(repos_url)
+ repos.set_branching_scheme(NoBranchingScheme())
+
+ self.assertEqual([("", 0, True)], list(repos.find_branches(0)))
+
+ def test_find_branches_trunk_empty(self):
+ repos_url = self.make_client("a", "dc")
+
+ repos = Repository.open(repos_url)
+ repos.set_branching_scheme(TrunkBranchingScheme())
+
+ self.assertEqual([], list(repos.find_branches(0)))
+
+ def test_find_branches_trunk_one(self):
+ repos_url = self.make_client("a", "dc")
+
+ repos = Repository.open(repos_url)
+ repos.set_branching_scheme(TrunkBranchingScheme())
+
+ self.build_tree({'dc/trunk/foo': "data"})
+ self.client_add("dc/trunk")
+ self.client_commit("dc", "My Message")
+
+ self.assertEqual([("trunk", 1, True)], list(repos.find_branches(1)))
+
+ def test_find_branches_removed(self):
+ repos_url = self.make_client("a", "dc")
+
+ repos = Repository.open(repos_url)
+ repos.set_branching_scheme(TrunkBranchingScheme())
+
+ self.build_tree({'dc/trunk/foo': "data"})
+ self.client_add("dc/trunk")
+ self.client_commit("dc", "My Message")
+
+ self.client_delete("dc/trunk")
+ self.client_commit("dc", "remove")
+
+ self.assertEqual([("trunk", 1, True)], list(repos.find_branches(1)))
+ self.assertEqual([("trunk", 2, False)], list(repos.find_branches(2)))
+
def test_url(self):
""" Test repository URL is kept """
bzrdir = self.make_local_bzrdir('b', 'bc')
More information about the bazaar-commits
mailing list