Rev 634: Add more roundtripping tests. in file:///data/jelmer/bzr-svn/revprops/
Jelmer Vernooij
jelmer at samba.org
Sat Feb 2 23:33:20 GMT 2008
At file:///data/jelmer/bzr-svn/revprops/
------------------------------------------------------------
revno: 634
revision-id:jelmer at samba.org-20080202233318-5bha7uh543h63stq
parent: jelmer at samba.org-20080202225528-732o641jnqyt351f
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: revprops
timestamp: Sun 2008-02-03 00:33:18 +0100
message:
Add more roundtripping tests.
modified:
mapping.py mapping.py-20080128201303-6cp01phc0dmc0kiv-1
tests/test_mapping.py test_mapping.py-20080201131338-0zd86eznn4bojtee-1
=== modified file 'mapping.py'
--- a/mapping.py 2008-02-02 22:55:28 +0000
+++ b/mapping.py 2008-02-02 23:33:18 +0000
@@ -252,6 +252,10 @@
"""Class that maps between Subversion and Bazaar semantics."""
@staticmethod
+ def supports_roundtripping():
+ return False
+
+ @staticmethod
def parse_revision_id(revid):
"""Parse an existing Subversion-based revision id.
@@ -403,6 +407,10 @@
"""
revid_prefix = "svn-v3-"
+ @staticmethod
+ def supports_roundtripping():
+ return True
+
@classmethod
def parse_revision_id(cls, revid):
assert revid is not None
@@ -573,6 +581,10 @@
class BzrSvnMappingv4:
@staticmethod
+ def supports_roundtripping():
+ return True
+
+ @staticmethod
def import_revision(svn_revprops, get_branch_file_property, rev):
parse_svn_revprops(svn_revprops, rev)
if svn_revprops.get(SVN_REVPROP_BZR_MAPPING_VERSION) == str(MAPPING_VERSION):
@@ -624,6 +636,8 @@
svn_revprops[SVN_REVPROP_BZR_MERGE] = "".join([x+"\n" for x in merges])
svn_revprops[SVN_REVPROP_BZR_REVNO] = str(revno)
+ return (svn_revprops, {})
+
@staticmethod
def export_fileid_map(fileids, revprops, fileprops):
revprops[SVN_REVPROP_BZR_FILEIDS] = generate_fileid_property(fileids)
@@ -650,6 +664,10 @@
class BzrSvnMappingHybrid:
+ @staticmethod
+ def supports_roundtripping():
+ return True
+
@classmethod
def get_rhs_parents(cls, svn_revprops, get_branch_file_property, scheme):
if svn_revprops.has_key(SVN_REVPROP_BZR_MAPPING_VERSION):
@@ -674,10 +692,11 @@
@classmethod
def export_revision(cls, branch_root, timestamp, timezone, committer, revprops, revision_id, revno,
merges, get_branch_file_property, scheme):
- BzrSvnMappingv3.export_revision(branch_root, timestamp, timezone, committer, revprops, revision_id,
- revno, merges, get_branch_file_property, scheme)
- BzrSvnMappingv4.export_revision(branch_root, timestamp, timezone, committer, revprops, revision_id,
- revno, merges, get_branch_file_property, scheme)
+ (_, fileprops) = BzrSvnMappingv3.export_revision(branch_root, timestamp, timezone, committer,
+ revprops, revision_id, revno, merges, get_branch_file_property, scheme)
+ (revprops, _) = BzrSvnMappingv4.export_revision(branch_root, timestamp, timezone, committer,
+ revprops, revision_id, revno, merges, get_branch_file_property, scheme)
+ return (revprops, fileprops)
@staticmethod
def parse_revision_id(revid):
=== modified file 'tests/test_mapping.py'
--- a/tests/test_mapping.py 2008-02-02 22:55:28 +0000
+++ b/tests/test_mapping.py 2008-02-02 23:33:18 +0000
@@ -19,7 +19,9 @@
from mapping import (generate_revision_metadata, parse_revision_metadata,
parse_revid_property, parse_merge_property, BzrSvnMappingv1, BzrSvnMappingv2,
BzrSvnMappingv3, BzrSvnMappingv4, BzrSvnMappingHybrid)
-from bzrlib.tests import (TestCase, adapt_tests)
+from scheme import NoBranchingScheme
+
+from bzrlib.tests import (TestCase, adapt_tests, TestSkipped)
from bzrlib.revision import Revision
from bzrlib.trace import mutter
@@ -125,6 +127,28 @@
if scheme is not None:
self.assertEquals(scheme, "somescheme")
+ def test_fileid_map(self):
+ if not self.mapping.supports_roundtripping():
+ raise TestSkipped
+ revprops = {}
+ fileprops = {}
+ fileids = {"": "some-id", "bla/blie": "other-id"}
+ self.mapping.export_fileid_map(fileids, revprops, fileprops)
+ self.assertEquals(fileids,
+ self.mapping.import_fileid_map(revprops, fileprops.get))
+
+ def test_revision(self):
+ if not self.mapping.supports_roundtripping():
+ raise TestSkipped
+ (revprops, fileprops) = self.mapping.export_revision("branchp", 432432432.0, 0, "somebody",
+ {"arevprop": "val"}, "arevid", 4, ["merge1"], dict().get, NoBranchingScheme())
+ targetrev = Revision(None)
+ self.mapping.import_revision(revprops, fileprops.get, targetrev)
+ self.assertEquals(targetrev.committer, "somebody")
+ self.assertEquals(targetrev.properties, {"arevprop": "val"})
+ self.assertEquals(targetrev.timestamp, 432432432.0)
+ self.assertEquals(targetrev.timezone, 0)
+
class Mappingv1TestAdapter(MappingTestAdapter,TestCase):
def setUp(self):
More information about the bazaar-commits
mailing list