Rev 1711: Add simple config-based layout implementation. in file:///data/jelmer/bzr-svn/trunk/
Jelmer Vernooij
jelmer at samba.org
Sat Aug 30 01:40:36 BST 2008
At file:///data/jelmer/bzr-svn/trunk/
------------------------------------------------------------
revno: 1711
revision-id: jelmer at samba.org-20080830004033-jwoyzljlkfmzyogg
parent: jelmer at samba.org-20080830001533-imwcdb8tbans5roi
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Sat 2008-08-30 02:40:33 +0200
message:
Add simple config-based layout implementation.
modified:
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
layout.py layout.py-20080323165407-y9qw8nx4oykvoe1k-1
logwalker.py logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
mapping.py mapping.py-20080128201303-6cp01phc0dmc0kiv-1
mapping4.py mapping4.py-20080827182338-y4xzpsf43vyiwcir-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
=== modified file 'commit.py'
--- a/commit.py 2008-08-29 23:55:41 +0000
+++ b/commit.py 2008-08-30 00:40:33 +0000
@@ -190,7 +190,9 @@
else:
self._base_branch_props = lazy_dict({}, self.repository.branchprop_list.get_properties, self.base_path, self.base_revnum)
self.supports_custom_revprops = self.repository.transport.has_capability("commit-revprops")
- if self.supports_custom_revprops is None and self.base_mapping.supports_custom_revprops() and self.repository.seen_bzr_revprops():
+ if (self.supports_custom_revprops is None and
+ self.base_mapping.supports_custom_revprops() and
+ self.repository.seen_bzr_revprops()):
raise BzrError("Please upgrade your Subversion client libraries to 1.5 or higher to be able to commit with Subversion mapping %s" % self.base_mapping.name)
if self.supports_custom_revprops == True:
@@ -199,7 +201,7 @@
self._svn_revprops[mapping.SVN_REVPROP_BZR_SIGNATURE] = opt_signature
else:
self._svn_revprops = None
- self._svnprops = dict(self._base_branch_props.items())
+ self._svnprops = lazy_dict({}, lambda: dict(self._base_branch_props.items()))
self.base_mapping.export_revision(
self.branch.get_branch_path(), timestamp, timezone, committer, revprops,
revision_id, self.base_revno+1, merges, self._svn_revprops, self._svnprops)
@@ -532,7 +534,7 @@
branch_editors[-1])
# Set all the revprops
- if self.push_metadata:
+ if self.push_metadata and self._svnprops.is_loaded:
for prop, value in self._svnprops.items():
if value == self._base_branch_props.get(prop):
continue
=== modified file 'layout.py'
--- a/layout.py 2008-08-26 03:32:23 +0000
+++ b/layout.py 2008-08-30 00:40:33 +0000
@@ -13,10 +13,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from bzrlib import urlutils
from bzrlib.errors import NotBranchError
class RepositoryLayout(object):
"""Describes a repository layout."""
+
def get_tag_path(self, name, project=""):
"""Return the path at which the tag with specified name should be found.
@@ -100,3 +102,82 @@
:result: Iterator over tuples with (project, branch path)
"""
raise NotImplementedError
+
+
+class ConfigBasedLayout(RepositoryLayout):
+
+ def __init__(self, repository):
+ self._config = repository.get_config()
+
+ 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 urlutils.join(project, "tags", name)
+
+ def get_tag_name(self, path, project=""):
+ """Determine the tag name from a tag path.
+
+ :param path: Path inside the repository.
+ """
+ return urlutils.basename(path)
+
+ 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 self._config.get_push_merged_revisions()
+
+ 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 urlutils.join(project, "branches", name)
+
+ def parse(self, path):
+ """Parse a path.
+
+ :return: Tuple with type ('tag', 'branch'), project name, branch path and path
+ inside the branch
+ """
+ parts = path.split("/")
+ for i, p in enumerate(parts):
+ if (i > 0 and parts[i-1] in ("branches", "tags")) or p == "trunk":
+ if p == "tags":
+ t = "tag"
+ j = i-1
+ elif p == "branches":
+ t = "branch"
+ j = i-1
+ else:
+ t = "branch"
+ j = i
+ return (t, "/".join(parts[:j-1]).strip("/"), "/".join(parts[:i]).strip("/"), "/".join(parts[i+1:]))
+ raise InvalidSvnBranchPath(path, self)
+
+ def get_branches(self, revnum, project="", pb=None):
+ """Retrieve a list of paths that refer to branches in a specific revision.
+
+ :result: Iterator over tuples with (project, branch path)
+ """
+ raise NotImplementedError
+
+ def get_tags(self, revnum, project="", pb=None):
+ """Retrieve a list of paths that refer to tags in a specific revision.
+
+ :result: Iterator over tuples with (project, branch path)
+ """
+ raise NotImplementedError
+
+ def __repr__(self):
+ return "%s()" % self.__class__.__name__
+
=== modified file 'logwalker.py'
--- a/logwalker.py 2008-08-29 23:55:41 +0000
+++ b/logwalker.py 2008-08-30 00:40:33 +0000
@@ -32,11 +32,13 @@
self.create_fn = create_fn
self.args = args
self.dict = None
+ self.is_loaded = False
def _ensure_init(self):
if self.dict is None:
self.dict = self.create_fn(*self.args)
self.create_fn = None
+ self.is_loaded = True
def __len__(self):
self._ensure_init()
=== modified file 'mapping.py'
--- a/mapping.py 2008-08-30 00:15:33 +0000
+++ b/mapping.py 2008-08-30 00:40:33 +0000
@@ -691,7 +691,7 @@
mapping_registry.register_lazy('v4', 'bzrlib.plugins.svn.mapping4',
'BzrSvnMappingv4',
'Fourth format (bzr-svn 0.5.x)')
-mapping_registry.set_default('v3')
+mapping_registry.set_default('v4')
def parse_mapping_name(name):
assert isinstance(name, str)
=== modified file 'mapping4.py'
--- a/mapping4.py 2008-08-29 23:55:41 +0000
+++ b/mapping4.py 2008-08-30 00:40:33 +0000
@@ -15,7 +15,7 @@
from bzrlib import errors
-from bzrlib.plugins.svn import mapping
+from bzrlib.plugins.svn import layout, mapping
supported_features = set()
@@ -137,4 +137,5 @@
else:
self.fileprops.import_revision(svn_revprops, fileprops, uuid, branch, revnum, rev)
-
+ def get_mandated_layout(self, repository):
+ return layout.ConfigBasedLayout(repository)
=== modified file 'repository.py'
--- a/repository.py 2008-08-29 23:55:41 +0000
+++ b/repository.py 2008-08-30 00:40:33 +0000
@@ -279,6 +279,7 @@
def _clear_cached_state(self):
self._cached_tags = {}
self._cached_revnum = None
+ self._layout = None
self._parents_provider = CachingParentsProvider(self._real_parents_provider)
def lock_write(self):
@@ -403,9 +404,9 @@
self._layout = layout
def get_layout(self):
- if self._layout is not None:
- return self._layout
- return self.get_mapping().get_mandated_layout(self)
+ if self._layout is None:
+ self._layout = self.get_mapping().get_mandated_layout(self)
+ return self._layout
def get_guessed_layout(self):
return self.get_mapping().get_guessed_layout(self)
More information about the bazaar-commits
mailing list