Rev 1687: Implement v4 mapping, preferring revprops but falling back to fileprops. in file:///data/jelmer/bzr-svn/trunk/
Jelmer Vernooij
jelmer at samba.org
Fri Aug 29 11:52:52 BST 2008
At file:///data/jelmer/bzr-svn/trunk/
------------------------------------------------------------
revno: 1687
revision-id: jelmer at samba.org-20080829105234-9gm342uxerkggujw
parent: jelmer at samba.org-20080829102701-1983rtloixvei4ng
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-08-29 12:52:34 +0200
message:
Implement v4 mapping, preferring revprops but falling back to fileprops.
modified:
mapping.py mapping.py-20080128201303-6cp01phc0dmc0kiv-1
mapping3/__init__.py __init__.py-20080502174630-9324zh25kka98vlw-1
mapping4.py mapping4.py-20080827182338-y4xzpsf43vyiwcir-1
tests/test_mapping.py test_mapping.py-20080201131338-0zd86eznn4bojtee-1
=== modified file 'mapping.py'
--- a/mapping.py 2008-08-28 14:25:50 +0000
+++ b/mapping.py 2008-08-29 10:52:34 +0000
@@ -451,6 +451,11 @@
def parse_fileid_property(text):
+ """Pares a fileid file or revision property.
+
+ :param text: Property value
+ :return: Map of path -> fileid
+ """
ret = {}
for line in text.splitlines():
(path, key) = line.split("\t", 1)
@@ -459,7 +464,11 @@
def generate_fileid_property(fileids):
- """Marshall a dictionary with file ids."""
+ """Marshall a dictionary with file ids.
+
+ :param fileids: Map of path -> fileid
+ :return: Property value
+ """
return "".join(["%s\t%s\n" % (urllib.quote(path.encode("utf-8")), fileids[path]) for path in sorted(fileids.keys())])
@@ -476,6 +485,9 @@
class BzrSvnMappingFileProps(object):
+ def __init__(self, name):
+ self.name = name
+
@classmethod
def supports_custom_fileprops(cls):
"""Whether this mapping can be used with custom file properties."""
=== modified file 'mapping3/__init__.py'
--- a/mapping3/__init__.py 2008-08-27 19:29:40 +0000
+++ b/mapping3/__init__.py 2008-08-29 10:52:34 +0000
@@ -372,54 +372,4 @@
return (revprops, fileprops)
-class BzrSvnMappingv3Hybrid(BzrSvnMappingv3):
- def __init__(self, scheme):
- BzrSvnMappingv3.__init__(self, scheme)
- self.revprops = BzrSvnMappingv3RevProps(scheme)
- self.fileprops = BzrSvnMappingv3FileProps(scheme)
-
- def get_rhs_parents(self, branch_path, svn_revprops, fileprops):
- if svn_revprops.has_key(mapping.SVN_REVPROP_BZR_MAPPING_VERSION):
- return self.revprops.get_rhs_parents(branch_path, svn_revprops, fileprops)
- else:
- return self.fileprops.get_rhs_parents(branch_path, svn_revprops, fileprops)
-
- def get_revision_id(self, branch_path, revprops, fileprops):
- if revprops.has_key(mapping.SVN_REVPROP_BZR_MAPPING_VERSION):
- return self.revprops.get_revision_id(branch_path, revprops, fileprops)
- else:
- return self.fileprops.get_revision_id(branch_path, revprops, fileprops)
-
- def import_text_parents(self, svn_revprops, fileprops):
- if svn_revprops.has_key(mapping.SVN_REVPROP_BZR_TEXT_PARENTS):
- return self.revprops.import_text_parents(svn_revprops, fileprops)
- else:
- return self.fileprops.import_text_parents(svn_revprops, fileprops)
-
- def import_fileid_map(self, svn_revprops, fileprops):
- if svn_revprops.has_key(mapping.SVN_REVPROP_BZR_MAPPING_VERSION):
- return self.revprops.import_fileid_map(svn_revprops, fileprops)
- else:
- return self.fileprops.import_fileid_map(svn_revprops, fileprops)
-
- def export_revision(self, can_use_custom_revprops, branch_root, timestamp, timezone, committer, revprops, revision_id,
- revno, merges, fileprops):
- (_, fileprops) = self.fileprops.export_revision(can_use_custom_revprops, branch_root, timestamp, timezone, committer,
- revprops, revision_id, revno, merges, fileprops)
- (revprops, _) = self.revprops.export_revision(can_use_custom_revprops, branch_root, timestamp, timezone, committer,
- revprops, revision_id, revno, merges, fileprops)
- return (revprops, fileprops)
-
- def export_fileid_map(self, can_use_custom_revprops, fileids, revprops, fileprops):
- self.fileprops.export_fileid_map(can_use_custom_revprops, fileids, revprops, fileprops)
- self.revprops.export_fileid_map(can_use_custom_revprops, fileids, revprops, fileprops)
-
- def export_text_parents(self, can_use_custom_revprops, text_parents, revprops, fileprops):
- self.fileprops.export_text_parents(can_use_custom_revprops, text_parents, revprops, fileprops)
- self.revprops.export_text_parents(can_use_custom_revprops, text_parents, revprops, fileprops)
-
- def import_revision(self, svn_revprops, fileprops, uuid, branch, revnum, rev):
- self.fileprops.import_revision(svn_revprops, fileprops, uuid, branch, revnum, rev)
- self.revprops.import_revision(svn_revprops, fileprops, uuid, branch, revnum, rev)
-
=== modified file 'mapping4.py'
--- a/mapping4.py 2008-08-28 00:55:50 +0000
+++ b/mapping4.py 2008-08-29 10:52:34 +0000
@@ -20,7 +20,7 @@
supported_features = set()
-class BzrSvnMappingv4(mapping.BzrSvnMappingRevProps):
+class BzrSvnMappingv4(mapping.BzrSvnMapping):
"""Mapping between Subversion and Bazaar, introduced in bzr-svn 0.5.
Tries to use revision properties when possible.
@@ -28,23 +28,18 @@
TODO: Add variable with required features.
"""
revid_prefix = "svn-v4"
+ upgrade_suffix = "-svn4"
experimental = True
+ def __init__(self):
+ self.name = "v4"
+ self.revprops = mapping.BzrSvnMappingRevProps()
+ self.fileprops = mapping.BzrSvnMappingFileProps(self.name)
+
@staticmethod
def supports_roundtripping():
return True
- def import_revision(self, svn_revprops, fileprops, uuid, branch, revnum, rev):
- super(BzrSvnMappingv4, self).import_revision(svn_revprops, fileprops, uuid, branch, revnum, rev)
- if svn_revprops.has_key(mapping.SVN_REVPROP_BZR_REQUIRED_FEATURES):
- features = set(svn_revprops[mapping.SVN_REVPROP_BZR_REQUIRED_FEATURES].split(","))
- assert features.issubset(supported_features), "missing feature: %r" % features.difference(supported_features)
-
- def export_revision(self, can_use_custom_revprops, branch_root, timestamp, timezone, committer, revprops, revision_id, revno, merges, fileprops):
- (revprops, fileprops) = mapping.BzrSvnMappingRevProps.export_revision(self, can_use_custom_revprops, branch_root, timestamp, timezone, committer, revprops, revision_id, revno, merges, fileprops)
- revprops[mapping.SVN_REVPROP_BZR_MAPPING_VERSION] = "4"
- return (revprops, fileprops)
-
@classmethod
def parse_revision_id(cls, revid):
assert isinstance(revid, str)
@@ -76,5 +71,60 @@
def __eq__(self, other):
return type(self) == type(other)
+ def get_rhs_parents(self, branch_path, svn_revprops, fileprops):
+ if svn_revprops.has_key(mapping.SVN_REVPROP_BZR_MAPPING_VERSION):
+ return self.revprops.get_rhs_parents(branch_path, svn_revprops, fileprops)
+ else:
+ return self.fileprops.get_rhs_parents(branch_path, svn_revprops, fileprops)
+
+ def get_revision_id(self, branch_path, revprops, fileprops):
+ if revprops.has_key(mapping.SVN_REVPROP_BZR_MAPPING_VERSION):
+ return self.revprops.get_revision_id(branch_path, revprops, fileprops)
+ else:
+ return self.fileprops.get_revision_id(branch_path, revprops, fileprops)
+
+ def import_text_parents(self, svn_revprops, fileprops):
+ if svn_revprops.has_key(mapping.SVN_REVPROP_BZR_TEXT_PARENTS):
+ return self.revprops.import_text_parents(svn_revprops, fileprops)
+ else:
+ return self.fileprops.import_text_parents(svn_revprops, fileprops)
+
+ def import_fileid_map(self, svn_revprops, fileprops):
+ if svn_revprops.has_key(mapping.SVN_REVPROP_BZR_MAPPING_VERSION):
+ return self.revprops.import_fileid_map(svn_revprops, fileprops)
+ else:
+ return self.fileprops.import_fileid_map(svn_revprops, fileprops)
+
+ def export_revision(self, can_use_custom_revprops, branch_root, timestamp, timezone, committer, revprops, revision_id,
+ revno, merges, fileprops):
+ if can_use_custom_revprops:
+ (svn_revprops, fileprops) = self.revprops.export_revision(can_use_custom_revprops, branch_root, timestamp, timezone, committer,
+ revprops, revision_id, revno, merges, fileprops)
+ svn_revprops[mapping.SVN_REVPROP_BZR_MAPPING_VERSION] = "4"
+ return (svn_revprops, fileprops)
+ else:
+ return self.fileprops.export_revision(can_use_custom_revprops, branch_root, timestamp, timezone, committer,
+ revprops, revision_id, revno, merges, fileprops)
+
+ def export_fileid_map(self, can_use_custom_revprops, fileids, revprops, fileprops):
+ if can_use_custom_revprops:
+ self.revprops.export_fileid_map(can_use_custom_revprops, fileids, revprops, fileprops)
+ else:
+ self.fileprops.export_fileid_map(can_use_custom_revprops, fileids, revprops, fileprops)
+
+ def export_text_parents(self, can_use_custom_revprops, text_parents, revprops, fileprops):
+ if can_use_custom_revprops:
+ self.revprops.export_text_parents(can_use_custom_revprops, text_parents, revprops, fileprops)
+ else:
+ self.fileprops.export_text_parents(can_use_custom_revprops, text_parents, revprops, fileprops)
+
+ def import_revision(self, svn_revprops, fileprops, uuid, branch, revnum, rev):
+ if svn_revprops.has_key(mapping.SVN_REVPROP_BZR_REQUIRED_FEATURES):
+ features = set(svn_revprops[mapping.SVN_REVPROP_BZR_REQUIRED_FEATURES].split(","))
+ assert features.issubset(supported_features), "missing feature: %r" % features.difference(supported_features)
+ if svn_revprops.has_key(mapping.SVN_REVPROP_BZR_MAPPING_VERSION):
+ self.revprops.import_revision(svn_revprops, fileprops, uuid, branch, revnum, rev)
+ else:
+ self.fileprops.import_revision(svn_revprops, fileprops, uuid, branch, revnum, rev)
=== modified file 'tests/test_mapping.py'
--- a/tests/test_mapping.py 2008-08-27 19:06:48 +0000
+++ b/tests/test_mapping.py 2008-08-29 10:52:34 +0000
@@ -26,8 +26,7 @@
parse_revid_property, parse_merge_property, parse_text_parents_property,
generate_text_parents_property, BzrSvnMappingv1, BzrSvnMappingv2,
parse_revision_id)
-from bzrlib.plugins.svn.mapping3 import (BzrSvnMappingv3FileProps, BzrSvnMappingv3RevProps,
- BzrSvnMappingv3Hybrid)
+from bzrlib.plugins.svn.mapping3 import (BzrSvnMappingv3FileProps, BzrSvnMappingv3RevProps)
from bzrlib.plugins.svn.mapping4 import BzrSvnMappingv4
from bzrlib.plugins.svn.mapping3.scheme import NoBranchingScheme
@@ -153,9 +152,8 @@
def test_fileid_map(self):
if not self.mapping.supports_roundtripping():
raise TestNotApplicable
- revprops = {}
- fileprops = {}
fileids = {"": "some-id", "bla/blie": "other-id"}
+ (revprops, fileprops) = self.mapping.export_revision(True, "branchp", 432432432.0, 0, "somebody", {}, "arevid", 4, ["merge1"], dict())
self.mapping.export_fileid_map(True, fileids, revprops, fileprops)
revprops["svn:date"] = "2008-11-03T09:33:00.716938Z"
self.assertEquals(fileids,
@@ -302,11 +300,6 @@
self.mapping = BzrSvnMappingv3RevProps(NoBranchingScheme())
-class Mappingv3HybridTests(MappingTestAdapter, TestCase):
- def setUp(self):
- self.mapping = BzrSvnMappingv3Hybrid(NoBranchingScheme())
-
-
class Mappingv4TestAdapter(MappingTestAdapter, TestCase):
def setUp(self):
self.mapping = BzrSvnMappingv4()
More information about the bazaar-commits
mailing list