69
69
def test_get_set_default_format(self):
70
70
old_default = bzrdir.format_registry.get('default')
71
71
private_default = old_default().repository_format.__class__
72
old_format = repository.format_registry.get_default()
72
old_format = repository.RepositoryFormat.get_default_format()
73
73
self.assertTrue(isinstance(old_format, private_default))
74
74
def make_sample_bzrdir():
75
75
my_bzrdir = bzrdir.BzrDirMetaFormat1()
158
149
def test_register_unregister_format(self):
159
# Test deprecated format registration functions
160
150
format = SampleRepositoryFormat()
161
151
# make a control dir
162
152
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
164
154
format.initialize(dir)
165
155
# register a format for it.
166
self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
167
repository.RepositoryFormat.register_format, format)
156
repository.RepositoryFormat.register_format(format)
168
157
# which repository.Open will refuse (not supported)
169
self.assertRaises(UnsupportedFormatError, repository.Repository.open,
158
self.assertRaises(UnsupportedFormatError, repository.Repository.open, self.get_url())
171
159
# but open(unsupported) will work
172
160
self.assertEqual(format.open(dir), "opened repository.")
173
161
# unregister the format
174
self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
175
repository.RepositoryFormat.unregister_format, format)
178
class TestRepositoryFormatRegistry(TestCase):
181
super(TestRepositoryFormatRegistry, self).setUp()
182
self.registry = repository.RepositoryFormatRegistry()
184
def test_register_unregister_format(self):
185
format = SampleRepositoryFormat()
186
self.registry.register(format)
187
self.assertEquals(format, self.registry.get("Sample .bzr repository format."))
188
self.registry.remove(format)
189
self.assertRaises(KeyError, self.registry.get, "Sample .bzr repository format.")
191
def test_get_all(self):
192
format = SampleRepositoryFormat()
193
self.assertEquals([], self.registry._get_all())
194
self.registry.register(format)
195
self.assertEquals([format], self.registry._get_all())
197
def test_register_extra(self):
198
format = SampleExtraRepositoryFormat()
199
self.assertEquals([], self.registry._get_all())
200
self.registry.register_extra(format)
201
self.assertEquals([format], self.registry._get_all())
203
def test_register_extra_lazy(self):
204
self.assertEquals([], self.registry._get_all())
205
self.registry.register_extra_lazy("bzrlib.tests.test_repository",
206
"SampleExtraRepositoryFormat")
207
formats = self.registry._get_all()
208
self.assertEquals(1, len(formats))
209
self.assertIsInstance(formats[0], SampleExtraRepositoryFormat)
162
repository.RepositoryFormat.unregister_format(format)
212
165
class TestFormat6(TestCaseWithTransport):
1020
973
def setUp(self):
1021
974
super(TestDevelopment6FindParentIdsOfRevisions, self).setUp()
1022
self.builder = self.make_branch_builder('source')
975
self.builder = self.make_branch_builder('source',
976
format='development6-rich-root')
1023
977
self.builder.start_series()
1024
978
self.builder.build_snapshot('initial', None,
1025
979
[('add', ('', 'tree-root', 'directory', None))])
1706
1660
self.orig_pack = target.pack
1707
1661
target.pack = self.log_pack
1708
1662
search = target.search_missing_revision_ids(
1709
source_tree.branch.repository, revision_ids=[tip])
1663
source_tree.branch.repository, tip)
1710
1664
stream = source.get_stream(search)
1711
1665
from_format = source_tree.branch.repository._format
1712
1666
sink = target._get_sink()