Rev 304: Move more scheme-specific code out of LogWalker to Repository. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev
Jelmer Vernooij
jelmer at samba.org
Tue Dec 26 16:13:16 GMT 2006
------------------------------------------------------------
revno: 304
revision-id: jelmer at samba.org-20061226161240-bmoe91d09xx4ha4e
parent: jelmer at samba.org-20061226152813-dv0aagksub846kxu
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Tue 2006-12-26 17:12:40 +0100
message:
Move more scheme-specific code out of LogWalker to Repository.
modified:
fetch.py fetch.py-20060625004942-x2lfaib8ra707a8p-1
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 'fetch.py'
--- a/fetch.py 2006-12-26 04:48:57 +0000
+++ b/fetch.py 2006-12-26 16:12:40 +0000
@@ -286,7 +286,7 @@
parents = {}
prev_revid = None
for (branch, changes, revnum) in \
- self.source._log.follow_history(path, until_revnum):
+ self.source.follow_history(path, until_revnum):
revid = self.source.generate_revision_id(revnum, branch)
if prev_revid is not None:
=== modified file 'logwalker.py'
--- a/logwalker.py 2006-12-26 00:27:08 +0000
+++ b/logwalker.py 2006-12-26 16:12:40 +0000
@@ -54,15 +54,6 @@
return message
-class NotSvnBranchPath(BzrError):
- _fmt = """{%(branch_path)s}:%(revnum)s is not a valid Svn branch path"""
-
- def __init__(self, branch_path, revnum=None):
- BzrError.__init__(self)
- self.branch_path = branch_path
- self.revnum = revnum
-
-
class LogWalker(object):
"""Easy way to access the history of a Subversion repository."""
def __init__(self, scheme, transport=None, cache_db=None, last_revnum=None, pb=None):
@@ -156,7 +147,7 @@
def follow_history(self, branch_path, revnum):
"""Return iterator over all the revisions between revnum and
- 0 that touch branch_path.
+ 0 names branch_path or inside branch_path.
:param branch_path: Branch path to start reporting (in revnum)
:param revnum: Start revision.
@@ -166,15 +157,9 @@
if revnum == 0 and branch_path in (None, ""):
return
- if not branch_path is None and not self.scheme.is_branch(branch_path):
- raise NotSvnBranchPath(branch_path, revnum)
-
if branch_path:
branch_path = branch_path.strip("/")
- if revnum > self.saved_revnum:
- self.fetch_revisions(revnum)
-
continue_revnum = None
for i in range(revnum+1):
i = revnum - i
@@ -188,7 +173,7 @@
continue_revnum = None
changed_paths = {}
- revpaths = self._get_revision_paths(i)
+ revpaths = self.get_revision_paths(i)
for p in revpaths:
if (branch_path is None or
p == branch_path or
@@ -234,14 +219,11 @@
"""
created_branches = {}
- if revnum > self.saved_revnum:
- self.fetch_revisions(revnum)
-
for i in range(revnum+1):
if i == 0:
paths = {'': ('A', None, None)}
else:
- paths = self._get_revision_paths(i)
+ paths = self.get_revision_paths(i)
for p in paths:
if self.scheme.is_branch(p):
if paths[p][0] in ('R', 'D'):
@@ -254,7 +236,17 @@
for p in created_branches:
yield (p, i, True)
- def _get_revision_paths(self, revnum):
+ def get_revision_paths(self, revnum):
+ """Obtain dictionary with all the changes in a particular revision.
+
+ :param revnum: Subversion revision number
+ :returns: dictionary with paths as keys and
+ (action, copyfrom_path, copyfrom_rev) as values.
+ """
+
+ if revnum > self.saved_revnum:
+ self.fetch_revisions(revnum)
+
paths = {}
for p, act, cf, cr in self.db.execute("select path, action, copyfrom_path, copyfrom_rev from changed_path where rev="+str(revnum)):
paths[p] = (act, cf, cr)
@@ -273,7 +265,6 @@
author = None
return (author, _escape_commit_message(base64.b64decode(message)), date)
-
def find_latest_change(self, path, revnum):
"""Find latest revision that touched path.
@@ -288,7 +279,7 @@
if row is None and path == "":
return 0
- assert row is not None, "now latest change for %r:%d" % (path, revnum)
+ assert row is not None, "no latest change for %r:%d" % (path, revnum)
return row[0]
=== modified file 'repository.py'
--- a/repository.py 2006-12-26 15:28:13 +0000
+++ b/repository.py 2006-12-26 16:12:40 +0000
@@ -52,6 +52,28 @@
SVN_PROP_BZR_REVPROP_PREFIX = 'bzr:revprop:'
SVN_REVPROP_BZR_SIGNATURE = 'bzr:gpg-signature'
+
+class DirUpgrade(BzrError):
+ _fmt = """Dir %(from_path):%(from_revnum) is upgraded to branch %(to_path) in %(to_revnum). Not supported yet. """
+
+ def __init__(self, to_tuple, from_tuple=None):
+ BzrError.__init__(self)
+ self.to_path = to_tuple[0]
+ self.to_revnum = to_tuple[1]
+ if from_tuple is not None:
+ self.from_path = from_tuple[0]
+ self.from_revnum = from_tuple[1]
+
+
+class NotSvnBranchPath(BzrError):
+ _fmt = """{%(branch_path)s}:%(revnum)s is not a valid Svn branch path"""
+
+ def __init__(self, branch_path, revnum=None):
+ BzrError.__init__(self)
+ self.branch_path = branch_path
+ self.revnum = revnum
+
+
_unsafe = "%/-\t "
def escape_svn_path(id):
r = [((c in _unsafe) and ('%%%02x' % ord(c)) or c)
@@ -500,9 +522,19 @@
return osutils.sha_string(self.get_revision_xml(revision_id))
def follow_branch(self, branch_path, revnum):
+ if not branch_path is None and not self.scheme.is_branch(branch_path):
+ raise NotSvnBranchPath(branch_path, revnum)
+
for (bp, _, rev) in self._log.follow_history(branch_path, revnum):
yield (bp, rev)
+ def follow_history(self, branch_path, revnum):
+ if not branch_path is None and not self.scheme.is_branch(branch_path):
+ raise NotSvnBranchPath(branch_path, revnum)
+
+ for (bp, paths, rev) in self._log.follow_history(branch_path, revnum):
+ yield (bp, paths, 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
=== modified file 'tests/test_logwalker.py'
--- a/tests/test_logwalker.py 2006-12-25 16:20:19 +0000
+++ b/tests/test_logwalker.py 2006-12-26 16:12:40 +0000
@@ -52,13 +52,6 @@
self.assertRaises(NoSuchRevision, list,
walker.follow_history("/", 20))
- def test_invalid_branch_path(self):
- repos_url = self.make_client("a", "dc")
- walker = logwalker.LogWalker(NoBranchingScheme(),
- transport=SvnRaTransport(repos_url))
-
- self.assertRaises(logwalker.NotSvnBranchPath, list,
- walker.follow_history("foobar", 0))
def test_branch_log_all(self):
repos_url = self.make_client("a", "dc")
=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py 2006-12-26 15:28:13 +0000
+++ b/tests/test_repos.py 2006-12-26 16:12:40 +0000
@@ -29,11 +29,11 @@
from convert import load_dumpfile
import format
-from logwalker import NotSvnBranchPath
from scheme import TrunkBranchingScheme, NoBranchingScheme
from transport import SvnRaTransport
from tests import TestCaseWithSubversionRepository
-from repository import (parse_svn_revision_id, generate_svn_revision_id,
+from repository import (NotSvnBranchPath,
+ parse_svn_revision_id, generate_svn_revision_id,
svk_feature_to_revision_id, revision_id_to_svk_feature,
MAPPING_VERSION, escape_svn_path, unescape_svn_path)
More information about the bazaar-commits
mailing list