Rev 1811: Fix remaining v1/v2 tests. in file:///data/jelmer/bzr-svn/trunk/

Jelmer Vernooij jelmer at samba.org
Fri Sep 5 18:12:17 BST 2008


At file:///data/jelmer/bzr-svn/trunk/

------------------------------------------------------------
revno: 1811
revision-id: jelmer at samba.org-20080905171211-0mw7mckfevm2haad
parent: jelmer at samba.org-20080905123820-6hvfkbgdc2nw9z2g
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-09-05 19:12:11 +0200
message:
  Fix remaining v1/v2 tests.
modified:
  layout.py                      layout.py-20080323165407-y9qw8nx4oykvoe1k-1
  mapping2.py                    mapping.py-20080904055555-lw057kjuadn0r2ma-2
  mapping3/scheme.py             scheme.py-20060516195850-95181aae6b272f9e
  tests/mapping3/__init__.py     __init__.py-20080831152358-oy04n53cpnh64aj6-1
  tests/mapping_implementations/test_repository.py test_repository.py-20080902013845-ity7d1ymye69sobm-2
=== modified file 'layout.py'
--- a/layout.py	2008-09-04 21:14:18 +0000
+++ b/layout.py	2008-09-05 17:12:11 +0000
@@ -267,14 +267,14 @@
 
         :result: Iterator over tuples with (project, branch path)
         """
-        raise [""]
+        return [("", "", "trunk")]
 
     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)
         """
-        raise []
+        return []
 
     def __repr__(self):
         return "%s()" % self.__class__.__name__

=== modified file 'mapping2.py'
--- a/mapping2.py	2008-09-05 12:38:20 +0000
+++ b/mapping2.py	2008-09-05 17:12:11 +0000
@@ -98,10 +98,11 @@
 
     def check_layout(self, repository, layout):
         if isinstance(layout, RootLayout):
-            return RootLegacyLayout()
+            self._layout = RootLegacyLayout()
         elif isinstance(layout, TrunkLayout):
-            return TrunkLegacyLayout(layout.level or 0)
-        raise LayoutUnusable(layout, self)
+            self._layout = TrunkLegacyLayout(layout.level or 0)
+        else:
+            raise LayoutUnusable(layout, self)
 
 
 class BzrSvnMappingv2(BzrSvnMappingv1):
@@ -203,7 +204,7 @@
         return path == ""
 
     def get_branches(self, repository, revnum, project="", pb=None):
-        return [""]
+        return [("", "", "trunk")]
 
     def get_tags(self, repository, revnum, project="", pb=None):
         return []

=== modified file 'mapping3/scheme.py'
--- a/mapping3/scheme.py	2008-09-04 10:15:15 +0000
+++ b/mapping3/scheme.py	2008-09-05 17:12:11 +0000
@@ -20,8 +20,8 @@
 from bzrlib.trace import mutter
 
 from base64 import urlsafe_b64decode, urlsafe_b64encode
-from bzrlib.plugins.svn.layout import TrunkLayout, RootLayout
-from bzrlib.plugins.svn.errors import InvalidSvnBranchPath
+from bzrlib.plugins.svn.layout import TrunkLayout, RootLayout, CustomLayout
+from bzrlib.plugins.svn.errors import InvalidSvnBranchPath, LayoutUnusable
 from bzrlib.plugins.svn import properties
 import bz2
 
@@ -542,9 +542,9 @@
         return TrunkBranchingScheme(layout.level or 0)
     if isinstance(layout, RootLayout):
         return NoBranchingScheme()
-    # FIXME: Handle CustomLayout
-    # FIXME: What about WildcardLayout
-    return TrunkBranchingScheme()
+    if isinstance(layout, CustomLayout) and len(layout.branches) == 1:
+        return SingleBranchingScheme(layout.branches[0])
+    raise LayoutUnusable(layout, self)
 
 
 help_schemes = """Subversion Branching Schemes

=== modified file 'tests/mapping3/__init__.py'
--- a/tests/mapping3/__init__.py	2008-09-05 12:38:20 +0000
+++ b/tests/mapping3/__init__.py	2008-09-05 17:12:11 +0000
@@ -13,13 +13,14 @@
 # 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.branch import Branch
 from bzrlib.bzrdir import BzrDir
 from bzrlib.errors import NoSuchRevision
 from bzrlib.repository import Repository
 from bzrlib.tests import TestCase
 
 from bzrlib.plugins.svn import format
-from bzrlib.plugins.svn.layout import TrunkLayout
+from bzrlib.plugins.svn.layout import TrunkLayout, RootLayout
 from bzrlib.plugins.svn.mapping import SVN_PROP_BZR_REVISION_ID, mapping_registry
 from bzrlib.plugins.svn.mapping3 import BzrSvnMappingv3FileProps, SVN_PROP_BZR_BRANCHING_SCHEME, set_property_scheme
 from bzrlib.plugins.svn.mapping3.scheme import NoBranchingScheme, ListBranchingScheme
@@ -389,4 +390,17 @@
         repository = Repository.open(self.repos_url)
         self.assertEquals("trunk42", str(repository.get_mapping().scheme))
 
+    def test_revision_fileidmap(self):
+        dc = self.get_commit_editor(self.repos_url)
+        dc.add_file("foo").modify("data")
+        dc.change_prop("bzr:revision-info", "")
+        dc.change_prop("bzr:file-ids", "foo\tsomeid\n")
+        dc.close()
+
+        repository = Repository.open(self.repos_url)
+        repository.set_layout(RootLayout())
+        tree = repository.revision_tree(Branch.open(self.repos_url).last_revision())
+        self.assertEqual("someid", tree.inventory.path2id("foo"))
+        self.assertFalse("1@%s::foo" % repository.uuid in tree.inventory)
+
 

=== modified file 'tests/mapping_implementations/test_repository.py'
--- a/tests/mapping_implementations/test_repository.py	2008-09-04 15:23:13 +0000
+++ b/tests/mapping_implementations/test_repository.py	2008-09-05 17:12:11 +0000
@@ -24,7 +24,7 @@
 from bzrlib.revision import NULL_REVISION
 from bzrlib.tests import TestCase, TestSkipped, TestNotApplicable
 
-from bzrlib.plugins.svn import format, ra
+from bzrlib.plugins.svn import errors as svn_errors, format, ra
 from bzrlib.plugins.svn.layout import TrunkLayout, RootLayout, CustomLayout
 from bzrlib.plugins.svn.mapping import mapping_registry
 from bzrlib.plugins.svn.tests import SubversionTestCase
@@ -49,6 +49,7 @@
         cb.close()
 
         repos = Repository.open(repos_url)
+        repos.set_layout(RootLayout())
 
         self.assertEqual([
             ('', {'foo': ('A', None, -1)}, 1), 
@@ -68,7 +69,10 @@
         dc.close()
 
         repos = Repository.open(repos_url)
-        repos.set_layout(CustomLayout(["bla/bar"]))
+        try:
+            repos.set_layout(CustomLayout(["bla/bar"]))
+        except svn_errors.LayoutUnusable:
+            raise TestNotApplicable
         ret = list(repos._revmeta_provider.iter_changes('bla/bar', 2, 0, repos.get_mapping()))
         self.assertEquals(1, len(ret))
         self.assertEquals("bla/bar", ret[0][0])
@@ -166,7 +170,10 @@
         dc.close()
 
         repos = Repository.open(repos_url)
-        repos.set_layout(CustomLayout(["pygments"]))
+        try:
+            repos.set_layout(CustomLayout(["pygments"]))
+        except svn_errors.LayoutUnusable:
+            raise TestNotApplicable
         changes = repos._revmeta_provider.iter_reverse_branch_changes("pygments", 2, 0)
         self.assertEquals([('pygments',
               {'pygments/bla': ('A', None, -1), 'pygments': ('A', None, -1)},
@@ -185,8 +192,8 @@
 
         repos = Repository.open(repos_url)
 
-        self.assertEqual(2, 
-                   len(set(repos.all_revision_ids(repos.get_layout()))))
+        self.assertEqual(1, 
+                   len(set(repos.all_revision_ids(TrunkLayout()))))
 
     def test_all_revs_empty(self):
         repos_url = self.make_repository("a")
@@ -564,20 +571,6 @@
             repository.get_parent_map([revid]))
         self.assertEqual({}, repository.get_parent_map(["notexisting"]))
 
-    def test_revision_fileidmap(self):
-        repos_url = self.make_repository('d')
-
-        dc = self.get_commit_editor(repos_url)
-        dc.add_file("foo").modify("data")
-        dc.change_prop("bzr:revision-info", "")
-        dc.change_prop("bzr:file-ids", "foo\tsomeid\n")
-        dc.close()
-
-        repository = Repository.open(repos_url)
-        tree = repository.revision_tree(Branch.open(repos_url).last_revision())
-        self.assertEqual("someid", tree.inventory.path2id("foo"))
-        self.assertFalse("1@%s::foo" % repository.uuid in tree.inventory)
-
     def test_get_revision_delta(self):
         repos_url = self.make_repository('d')
 
@@ -590,6 +583,7 @@
         dc.close()
 
         r = Repository.open(repos_url)
+        r.set_layout(RootLayout())
         d1 = r.get_revision_delta(r.get_revision(r.generate_revision_id(1, "", r.get_mapping())))
         self.assertEquals(None, d1.unchanged)
         self.assertEquals(1, len(d1.added))
@@ -813,6 +807,7 @@
         self.client_add("dc/bar")
         self.client_commit("dc", "Second Message")
         repository = Repository.open(repos_url)
+        repository.set_layout(RootLayout())
         mapping = repository.get_mapping()
 
         to_bzrdir = BzrDir.create("e", format.get_rich_root_format())




More information about the bazaar-commits mailing list