Rev 496: Implement needs_format_conversion(). in file:///data/jelmer/bzr-svn/0.4/

Jelmer Vernooij jelmer at samba.org
Thu Jul 12 09:28:27 BST 2007


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

------------------------------------------------------------
revno: 496
revision-id: jelmer at samba.org-20070624231937-ikhtyqlkourqqorc
parent: jelmer at samba.org-20070624214328-jd6mfvyep9ug32ao
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Mon 2007-06-25 01:19:37 +0200
message:
  Implement needs_format_conversion().
modified:
  format.py                      format.py-20060406233823-b6fa009fe35dfde7
  tests/test_radir.py            test_radir.py-20061231173434-31utf9o4byu7wktm-1
=== modified file 'format.py'
--- a/format.py	2007-06-24 17:52:51 +0000
+++ b/format.py	2007-06-24 23:19:37 +0000
@@ -132,6 +132,14 @@
         """
         raise NotLocalUrl(self.root_transport.base)
 
+    def needs_format_conversion(self, format=None):
+        """See BzrDir.needs_format_conversion()."""
+        # if the format is not the same as the system default,
+        # an upgrade is needed.
+        if format is None:
+            format = BzrDirFormat.get_default_format()
+        return not isinstance(self._format, format.__class__)
+
     def create_branch(self):
         """See BzrDir.create_branch()."""
         from branch import SvnBranch
@@ -160,6 +168,9 @@
     """Format for the Subversion smart server."""
     _lock_class = TransportLock
 
+    def __init__(self):
+        super(SvnFormat, self).__init__()
+
     @classmethod
     def probe_transport(klass, transport):
         format = klass()

=== modified file 'tests/test_radir.py'
--- a/tests/test_radir.py	2007-05-28 12:24:15 +0000
+++ b/tests/test_radir.py	2007-06-24 23:19:37 +0000
@@ -16,12 +16,13 @@
 
 """Remote access tests."""
 
-from bzrlib.bzrdir import BzrDir
+from bzrlib.bzrdir import BzrDir, format_registry
 from bzrlib.errors import (NoRepositoryPresent, NotBranchError, NotLocalUrl,
                            NoWorkingTree)
 
 import svn
 
+from format import SvnFormat
 from tests import TestCaseWithSubversionRepository
 from transport import SvnRaTransport
 
@@ -104,3 +105,19 @@
         self.client_commit("dc", "data")
         x = BzrDir.open(repos_url+"/trunk")
         self.assertRaises(NoRepositoryPresent, x.open_repository)
+
+    def test_needs_format_upgrade_other(self):
+        repos_url = self.make_client("d", "dc")
+        x = BzrDir.open(repos_url+"/trunk")
+        self.assertTrue(x.needs_format_conversion(format_registry.make_bzrdir("dirstate-with-subtree")))
+
+    def test_needs_format_upgrade_default(self):
+        repos_url = self.make_client("d", "dc")
+        x = BzrDir.open(repos_url+"/trunk")
+        self.assertTrue(x.needs_format_conversion())
+
+    def test_needs_format_upgrade_self(self):
+        repos_url = self.make_client("d", "dc")
+        x = BzrDir.open(repos_url+"/trunk")
+        self.assertTrue(x.needs_format_conversion(SvnFormat()))
+




More information about the bazaar-commits mailing list