34
34
UnknownFormatError,
35
35
UnsupportedFormatError,
37
import bzrlib.repository as repository
37
from bzrlib.repository import RepositoryFormat
38
38
from bzrlib.tests import TestCase, TestCaseWithTransport
39
39
from bzrlib.transport import get_transport
40
40
from bzrlib.transport.memory import MemoryServer
41
from bzrlib import upgrade, workingtree
44
48
class TestDefaultFormat(TestCase):
46
50
def test_get_set_default_format(self):
47
private_default = repository._default_format.__class__
48
old_format = repository.RepositoryFormat.get_default_format()
49
self.assertTrue(isinstance(old_format, private_default))
50
self.applyDeprecated(symbol_versioning.zero_fourteen,
51
repository.RepositoryFormat.set_default_format,
52
SampleRepositoryFormat())
53
# creating a repository should now create an instrumented dir.
51
old_format = RepositoryFormat.get_default_format()
52
test_format = SampleRepositoryFormat()
53
RepositoryFormat.register_format(test_format)
55
# the default branch format is used by the meta dir format
56
# which is not the default bzrdir format at this point
57
dir = bzrdir.BzrDirMetaFormat1().initialize('memory:///')
58
result = dir.create_repository()
59
self.assertEqual(result, 'A bzr repository dir')
61
55
self.applyDeprecated(symbol_versioning.zero_fourteen,
62
repository.RepositoryFormat.set_default_format, old_format)
63
self.assertEqual(old_format, repository.RepositoryFormat.get_default_format())
56
RepositoryFormat.set_default_format,
58
# creating a repository should now create an instrumented dir.
60
# the default branch format is used by the meta dir format
61
# which is not the default bzrdir format at this point
62
dir = bzrdir.BzrDirMetaFormat1().initialize('memory:///')
63
result = dir.create_repository()
64
self.assertEqual(result, 'A bzr repository dir')
66
self.applyDeprecated(symbol_versioning.zero_fourteen,
67
RepositoryFormat.set_default_format, old_format)
69
RepositoryFormat.unregister_format(test_format)
70
self.assertEqual(old_format, RepositoryFormat.get_default_format())
66
73
class SampleRepositoryFormat(repository.RepositoryFormat):