40
39
info.describe_layout(tree.branch.repository, control=tree.controldir))
41
40
tree.branch.repository.set_make_working_trees(False)
42
41
self.assertEqual('Unshared repository with colocated branches',
43
info.describe_layout(tree.branch.repository, control=tree.controldir))
42
info.describe_layout(tree.branch.repository, control=tree.controldir))
44
43
self.assertEqual('Standalone branch',
45
info.describe_layout(tree.branch.repository, tree.branch,
46
control=tree.controldir))
44
info.describe_layout(tree.branch.repository, tree.branch,
45
control=tree.controldir))
47
46
self.assertEqual('Standalone branchless tree',
48
info.describe_layout(tree.branch.repository, None, tree,
49
control=tree.controldir))
47
info.describe_layout(tree.branch.repository, None, tree,
48
control=tree.controldir))
50
49
self.assertEqual('Standalone tree',
51
info.describe_layout(tree.branch.repository, tree.branch, tree,
52
control=tree.controldir))
50
info.describe_layout(tree.branch.repository, tree.branch, tree,
51
control=tree.controldir))
53
52
tree.branch.bind(tree.branch)
54
53
self.assertEqual('Bound branch',
55
info.describe_layout(tree.branch.repository, tree.branch,
56
control=tree.controldir))
54
info.describe_layout(tree.branch.repository, tree.branch,
55
control=tree.controldir))
57
56
self.assertEqual('Checkout',
58
info.describe_layout(tree.branch.repository, tree.branch, tree,
59
control=tree.controldir))
57
info.describe_layout(tree.branch.repository, tree.branch, tree,
58
control=tree.controldir))
60
59
checkout = tree.branch.create_checkout('checkout', lightweight=True)
61
60
self.assertEqual('Lightweight checkout',
62
info.describe_layout(checkout.branch.repository, checkout.branch,
63
checkout, control=tree.controldir))
61
info.describe_layout(checkout.branch.repository, checkout.branch,
62
checkout, control=tree.controldir))
65
64
def test_describe_repository_layout(self):
66
65
repository = self.make_repository('.', shared=True)
67
66
tree = controldir.ControlDir.create_branch_convenience('tree',
68
force_new_tree=True).controldir.open_workingtree()
67
force_new_tree=True).controldir.open_workingtree()
69
68
self.assertEqual('Shared repository with trees and colocated branches',
70
info.describe_layout(tree.branch.repository, control=tree.controldir))
69
info.describe_layout(tree.branch.repository, control=tree.controldir))
71
70
repository.set_make_working_trees(False)
72
71
self.assertEqual('Shared repository with colocated branches',
73
info.describe_layout(tree.branch.repository, control=tree.controldir))
72
info.describe_layout(tree.branch.repository, control=tree.controldir))
74
73
self.assertEqual('Repository branch',
75
info.describe_layout(tree.branch.repository, tree.branch,
76
control=tree.controldir))
74
info.describe_layout(tree.branch.repository, tree.branch,
75
control=tree.controldir))
77
76
self.assertEqual('Repository branchless tree',
78
info.describe_layout(tree.branch.repository, None, tree,
79
control=tree.controldir))
77
info.describe_layout(tree.branch.repository, None, tree,
78
control=tree.controldir))
80
79
self.assertEqual('Repository tree',
81
info.describe_layout(tree.branch.repository, tree.branch, tree,
82
control=tree.controldir))
80
info.describe_layout(tree.branch.repository, tree.branch, tree,
81
control=tree.controldir))
83
82
tree.branch.bind(tree.branch)
84
83
self.assertEqual('Repository checkout',
85
info.describe_layout(tree.branch.repository, tree.branch, tree,
86
control=tree.controldir))
84
info.describe_layout(tree.branch.repository, tree.branch, tree,
85
control=tree.controldir))
87
86
checkout = tree.branch.create_checkout('checkout', lightweight=True)
88
87
self.assertEqual('Lightweight checkout',
89
info.describe_layout(checkout.branch.repository, checkout.branch,
90
checkout, control=tree.controldir))
88
info.describe_layout(checkout.branch.repository, checkout.branch,
89
checkout, control=tree.controldir))
92
91
def assertTreeDescription(self, format):
93
92
"""Assert a tree's format description matches expectations"""
94
93
self.make_branch_and_tree('%s_tree' % format, format=format)
95
94
tree = workingtree.WorkingTree.open('%s_tree' % format)
96
95
self.assertEqual(format, info.describe_format(tree.controldir,
97
tree.branch.repository, tree.branch, tree))
96
tree.branch.repository, tree.branch, tree))
99
98
def assertCheckoutDescription(self, format, expected=None):
100
99
"""Assert a checkout's format description matches expectations"""
103
102
branch = self.make_branch('%s_cobranch' % format, format=format)
104
103
# this ought to be easier...
105
104
branch.create_checkout('%s_co' % format,
106
lightweight=True).controldir.destroy_workingtree()
105
lightweight=True).controldir.destroy_workingtree()
107
106
control = controldir.ControlDir.open('%s_co' % format)
108
107
old_format = control._format.workingtree_format
110
109
control._format.workingtree_format = \
111
controldir.format_registry.make_controldir(
112
format).workingtree_format
110
controldir.format_registry.make_controldir(format).workingtree_format
113
111
control.create_workingtree()
114
112
tree = workingtree.WorkingTree.open('%s_co' % format)
115
113
format_description = info.describe_format(tree.controldir,
116
tree.branch.repository, tree.branch, tree)
114
tree.branch.repository, tree.branch, tree)
117
115
self.assertEqual(expected, format_description,
118
"checkout of format called %r was described as %r" %
119
(expected, format_description))
116
"checkout of format called %r was described as %r" %
117
(expected, format_description))
121
119
control._format.workingtree_format = old_format
210
203
format.set_branch_format(_mod_bzrbranch.BzrBranchFormat6())
211
204
tree = self.make_branch_and_tree('unknown', format=format)
212
205
self.assertEqual('unnamed', info.describe_format(tree.controldir,
213
tree.branch.repository, tree.branch, tree))
206
tree.branch.repository, tree.branch, tree))
215
208
def test_gather_location_controldir_only(self):
216
209
bzrdir = self.make_controldir('.')
217
210
self.assertEqual([('control directory', bzrdir.user_url)],
218
info.gather_location_info(control=bzrdir))
211
info.gather_location_info(control=bzrdir))
220
213
def test_gather_location_standalone(self):
221
214
tree = self.make_branch_and_tree('tree')
222
215
self.assertEqual([('branch root', tree.controldir.root_transport.base)],
223
info.gather_location_info(
224
tree.branch.repository, tree.branch, tree, control=tree.controldir))
216
info.gather_location_info(
217
tree.branch.repository, tree.branch, tree, control=tree.controldir))
225
218
self.assertEqual([('branch root', tree.controldir.root_transport.base)],
226
info.gather_location_info(
227
tree.branch.repository, tree.branch, control=tree.controldir))
219
info.gather_location_info(
220
tree.branch.repository, tree.branch, control=tree.controldir))
230
223
def test_gather_location_repo(self):