1011
1011
self.assertEqual(2, rpc_count)
1014
class TestFormat5(TestCaseWithTransport):
1015
"""Tests specific to the version 5 bzrdir format."""
1017
def test_same_lockfiles_between_tree_repo_branch(self):
1018
# this checks that only a single lockfiles instance is created
1019
# for format 5 objects
1020
dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
1021
def check_dir_components_use_same_lock(dir):
1022
ctrl_1 = dir.open_repository().control_files
1023
ctrl_2 = dir.open_branch().control_files
1024
ctrl_3 = dir.open_workingtree()._control_files
1025
self.assertTrue(ctrl_1 is ctrl_2)
1026
self.assertTrue(ctrl_2 is ctrl_3)
1027
check_dir_components_use_same_lock(dir)
1028
# and if we open it normally.
1029
dir = bzrdir.BzrDir.open(self.get_url())
1030
check_dir_components_use_same_lock(dir)
1032
def test_can_convert(self):
1033
# format 5 dirs are convertable
1034
dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
1035
self.assertTrue(dir.can_convert_format())
1037
def test_needs_conversion(self):
1038
# format 5 dirs need a conversion if they are not the default,
1040
dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
1041
# don't need to convert it to itself
1042
self.assertFalse(dir.needs_format_conversion(bzrdir.BzrDirFormat5()))
1043
# do need to convert it to the current default
1044
self.assertTrue(dir.needs_format_conversion(
1045
bzrdir.BzrDirFormat.get_default_format()))
1048
class TestFormat6(TestCaseWithTransport):
1049
"""Tests specific to the version 6 bzrdir format."""
1051
def test_same_lockfiles_between_tree_repo_branch(self):
1052
# this checks that only a single lockfiles instance is created
1053
# for format 6 objects
1054
dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
1055
def check_dir_components_use_same_lock(dir):
1056
ctrl_1 = dir.open_repository().control_files
1057
ctrl_2 = dir.open_branch().control_files
1058
ctrl_3 = dir.open_workingtree()._control_files
1059
self.assertTrue(ctrl_1 is ctrl_2)
1060
self.assertTrue(ctrl_2 is ctrl_3)
1061
check_dir_components_use_same_lock(dir)
1062
# and if we open it normally.
1063
dir = bzrdir.BzrDir.open(self.get_url())
1064
check_dir_components_use_same_lock(dir)
1066
def test_can_convert(self):
1067
# format 6 dirs are convertable
1068
dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
1069
self.assertTrue(dir.can_convert_format())
1071
def test_needs_conversion(self):
1072
# format 6 dirs need an conversion if they are not the default.
1073
dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
1074
self.assertTrue(dir.needs_format_conversion(
1075
bzrdir.BzrDirFormat.get_default_format()))
1078
1014
class NonLocalTests(TestCaseWithTransport):
1079
1015
"""Tests for bzrdir static behaviour on non local paths."""