Rev 1805: Implement CustomLayout, more layout fixes. in file:///data/jelmer/bzr-svn/trunk/
Jelmer Vernooij
jelmer at samba.org
Thu Sep 4 16:23:16 BST 2008
At file:///data/jelmer/bzr-svn/trunk/
------------------------------------------------------------
revno: 1805
revision-id: jelmer at samba.org-20080904152313-u1106gusjwpl4rlu
parent: jelmer at samba.org-20080904145734-qesxocctryjuhu64
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Thu 2008-09-04 17:23:13 +0200
message:
Implement CustomLayout, more layout fixes.
modified:
layout.py layout.py-20080323165407-y9qw8nx4oykvoe1k-1
mapping2.py mapping.py-20080904055555-lw057kjuadn0r2ma-2
tests/mapping_implementations/test_repository.py test_repository.py-20080902013845-ity7d1ymye69sobm-2
tests/test_blackbox.py test_blackbox.py-20070325150839-d10llf8arptpcfl6-1
=== modified file 'layout.py'
--- a/layout.py 2008-09-04 11:47:09 +0000
+++ b/layout.py 2008-09-04 15:23:13 +0000
@@ -280,6 +280,80 @@
return "%s()" % self.__class__.__name__
+class CustomLayout(RepositoryLayout):
+
+ def __init__(self, branches=[], tags=[]):
+ self.branches = branches
+ self.tags = tags
+
+ def get_tag_path(self, name, project=""):
+ """Return the path at which the tag with specified name should be found.
+
+ :param name: Name of the tag.
+ :param project: Optional name of the project the tag is for. Can include slashes.
+ :return: Path of the tag."
+ """
+ return None
+
+ def get_tag_name(self, path, project=""):
+ """Determine the tag name from a tag path.
+
+ :param path: Path inside the repository.
+ """
+ return None
+
+ def push_merged_revisions(self, project=""):
+ """Determine whether or not right hand side (merged) revisions should be pushed.
+
+ Defaults to False.
+
+ :param project: Name of the project.
+ """
+ return False
+
+ def get_branch_path(self, name, project=""):
+ """Return the path at which the branch with specified name should be found.
+
+ :param name: Name of the branch.
+ :param project: Optional name of the project the branch is for. Can include slashes.
+ :return: Path of the branch.
+ """
+ return None
+
+ def parse(self, path):
+ """Parse a path.
+
+ :return: Tuple with type ('tag', 'branch'), project name, branch path and path
+ inside the branch
+ """
+ for bp in sorted(self.branches):
+ if path.startswith("%s/" % bp) or bp == path:
+ return ("branch", bp, bp, path[len(bp):].strip("/"))
+
+ for tp in sorted(self.tags):
+ if path.startswith("%s/" % tp) or tp == path:
+ return ("tag", tp, tp, path[len(tp):].strip("/"))
+
+ raise NotBranchError(path)
+
+ def get_branches(self, repository, revnum, project=None, pb=None):
+ """Retrieve a list of paths that refer to branches in a specific revision.
+
+ :result: Iterator over tuples with (project, branch path)
+ """
+ return self.branches
+
+ def get_tags(self, repository, revnum, project=None, pb=None):
+ """Retrieve a list of paths that refer to tags in a specific revision.
+
+ :result: Iterator over tuples with (project, branch path)
+ """
+ return self.tags
+
+ def __repr__(self):
+ return "%s(%r,%r)" % (self.__class__.__name__, self.branches, self.tags)
+
+
class ConfigBasedLayout(RepositoryLayout):
def __init__(self, repository):
@@ -362,7 +436,8 @@
def repository_guess_layout(repository, revnum):
- return None # FIXME
+ # FIXME
+ return TrunkLayout(), TrunkLayout()
layout_registry = registry.Registry()
=== modified file 'mapping2.py'
--- a/mapping2.py 2008-09-04 11:47:09 +0000
+++ b/mapping2.py 2008-09-04 15:23:13 +0000
@@ -88,6 +88,10 @@
return cls(LegacyLayout.from_branch_path(_hinted_branch_path))
+ @classmethod
+ def get_test_instance(cls):
+ return cls(TrunkLegacyLayout())
+
def get_guessed_layout(self, repository):
return self._layout
=== modified file 'tests/mapping_implementations/test_repository.py'
--- a/tests/mapping_implementations/test_repository.py 2008-09-04 11:47:09 +0000
+++ b/tests/mapping_implementations/test_repository.py 2008-09-04 15:23:13 +0000
@@ -25,7 +25,7 @@
from bzrlib.tests import TestCase, TestSkipped, TestNotApplicable
from bzrlib.plugins.svn import format, ra
-from bzrlib.plugins.svn.layout import TrunkLayout, RootLayout
+from bzrlib.plugins.svn.layout import TrunkLayout, RootLayout, CustomLayout
from bzrlib.plugins.svn.mapping import mapping_registry
from bzrlib.plugins.svn.tests import SubversionTestCase
@@ -226,6 +226,7 @@
def test_follow_history_empty(self):
repos_url = self.make_repository("a")
repos = Repository.open(repos_url)
+ repos.set_layout(RootLayout())
self.assertEqual(set([repos.generate_revision_id(0, '', repos.get_mapping())]),
set(repos.all_revision_ids(repos.get_layout())))
=== modified file 'tests/test_blackbox.py'
--- a/tests/test_blackbox.py 2008-09-04 09:40:03 +0000
+++ b/tests/test_blackbox.py 2008-09-04 15:23:13 +0000
@@ -294,7 +294,6 @@
""")
self.check_output("", 'svn-import --layout=none %s dc' % filename)
newrepos = Repository.open("dc")
- newrepos.set_layout(RootLayout())
self.assertTrue(newrepos.has_revision(
mapping.revision_id_foreign_to_bzr((uuid, 5, ""))))
self.assertTrue(newrepos.has_revision(
More information about the bazaar-commits
mailing list