1
# Copyright (C) 2006-2012 Canonical Ltd
1
# Copyright (C) 2006-2012, 2016 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
81
81
branch = BzrBranchFormat5().initialize(bdir)
82
82
t = self.get_transport()
83
83
self.log("branch instance is %r" % branch)
84
self.assert_(isinstance(branch, BzrBranch5))
84
self.assertTrue(isinstance(branch, BzrBranch5))
85
85
self.assertIsDirectory('.', t)
86
86
self.assertIsDirectory('.bzr/branch', t)
87
87
self.assertIsDirectory('.bzr/branch/lock', t)
226
226
tree.branch.update_feature_flags({"name": "optional"})
227
227
found_format = _mod_branch.BranchFormatMetadir.find_format(tree.bzrdir)
228
228
self.assertIsInstance(found_format, _mod_branch.BranchFormatMetadir)
229
self.assertEquals(found_format.features.get("name"), "optional")
229
self.assertEqual(found_format.features.get("name"), "optional")
230
230
tree.branch.update_feature_flags({"name": None})
231
231
branch = _mod_branch.Branch.open('.')
232
self.assertEquals(branch._format.features, {})
232
self.assertEqual(branch._format.features, {})
235
235
class TestBranchFormatRegistry(tests.TestCase):
242
242
self.assertIs(None, self.registry.get_default())
243
243
format = SampleBranchFormat()
244
244
self.registry.set_default(format)
245
self.assertEquals(format, self.registry.get_default())
245
self.assertEqual(format, self.registry.get_default())
247
247
def test_register_unregister_format(self):
248
248
format = SampleBranchFormat()
249
249
self.registry.register(format)
250
self.assertEquals(format,
250
self.assertEqual(format,
251
251
self.registry.get("Sample branch format."))
252
252
self.registry.remove(format)
253
253
self.assertRaises(KeyError, self.registry.get,
256
256
def test_get_all(self):
257
257
format = SampleBranchFormat()
258
self.assertEquals([], self.registry._get_all())
258
self.assertEqual([], self.registry._get_all())
259
259
self.registry.register(format)
260
self.assertEquals([format], self.registry._get_all())
260
self.assertEqual([format], self.registry._get_all())
262
262
def test_register_extra(self):
263
263
format = SampleExtraBranchFormat()
264
self.assertEquals([], self.registry._get_all())
264
self.assertEqual([], self.registry._get_all())
265
265
self.registry.register_extra(format)
266
self.assertEquals([format], self.registry._get_all())
266
self.assertEqual([format], self.registry._get_all())
268
268
def test_register_extra_lazy(self):
269
self.assertEquals([], self.registry._get_all())
269
self.assertEqual([], self.registry._get_all())
270
270
self.registry.register_extra_lazy("bzrlib.tests.test_branch",
271
271
"SampleExtraBranchFormat")
272
272
formats = self.registry._get_all()
273
self.assertEquals(1, len(formats))
273
self.assertEqual(1, len(formats))
274
274
self.assertIsInstance(formats[0], SampleExtraBranchFormat)
634
634
self.branch.get_append_revisions_only())
636
636
def test_valid_append_revisions_only(self):
637
self.assertEquals(None,
637
self.assertEqual(None,
638
638
self.config_stack.get('append_revisions_only'))
639
639
self.check_append_revisions_only(None)
640
640
self.check_append_revisions_only(False, 'False')