37
33
self.assertEqual('Empty control directory', info.describe_layout())
39
35
'Unshared repository with trees and colocated branches',
40
info.describe_layout(tree.branch.repository, control=tree.controldir))
36
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
41
37
tree.branch.repository.set_make_working_trees(False)
42
38
self.assertEqual('Unshared repository with colocated branches',
43
info.describe_layout(tree.branch.repository, control=tree.controldir))
39
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
44
40
self.assertEqual('Standalone branch',
45
info.describe_layout(tree.branch.repository, tree.branch,
46
control=tree.controldir))
41
info.describe_layout(tree.branch.repository, tree.branch,
47
43
self.assertEqual('Standalone branchless tree',
48
info.describe_layout(tree.branch.repository, None, tree,
49
control=tree.controldir))
44
info.describe_layout(tree.branch.repository, None, tree,
50
46
self.assertEqual('Standalone tree',
51
info.describe_layout(tree.branch.repository, tree.branch, tree,
52
control=tree.controldir))
47
info.describe_layout(tree.branch.repository, tree.branch, tree,
53
49
tree.branch.bind(tree.branch)
54
50
self.assertEqual('Bound branch',
55
info.describe_layout(tree.branch.repository, tree.branch,
56
control=tree.controldir))
51
info.describe_layout(tree.branch.repository, tree.branch,
57
53
self.assertEqual('Checkout',
58
info.describe_layout(tree.branch.repository, tree.branch, tree,
59
control=tree.controldir))
54
info.describe_layout(tree.branch.repository, tree.branch, tree,
60
56
checkout = tree.branch.create_checkout('checkout', lightweight=True)
61
57
self.assertEqual('Lightweight checkout',
62
info.describe_layout(checkout.branch.repository, checkout.branch,
63
checkout, control=tree.controldir))
58
info.describe_layout(checkout.branch.repository, checkout.branch,
59
checkout, control=tree.bzrdir))
65
61
def test_describe_repository_layout(self):
66
62
repository = self.make_repository('.', shared=True)
67
63
tree = controldir.ControlDir.create_branch_convenience('tree',
68
force_new_tree=True).controldir.open_workingtree()
64
force_new_tree=True).bzrdir.open_workingtree()
69
65
self.assertEqual('Shared repository with trees and colocated branches',
70
info.describe_layout(tree.branch.repository, control=tree.controldir))
66
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
71
67
repository.set_make_working_trees(False)
72
68
self.assertEqual('Shared repository with colocated branches',
73
info.describe_layout(tree.branch.repository, control=tree.controldir))
69
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
74
70
self.assertEqual('Repository branch',
75
info.describe_layout(tree.branch.repository, tree.branch,
76
control=tree.controldir))
71
info.describe_layout(tree.branch.repository, tree.branch,
77
73
self.assertEqual('Repository branchless tree',
78
info.describe_layout(tree.branch.repository, None, tree,
79
control=tree.controldir))
74
info.describe_layout(tree.branch.repository, None, tree,
80
76
self.assertEqual('Repository tree',
81
info.describe_layout(tree.branch.repository, tree.branch, tree,
82
control=tree.controldir))
77
info.describe_layout(tree.branch.repository, tree.branch, tree,
83
79
tree.branch.bind(tree.branch)
84
80
self.assertEqual('Repository checkout',
85
info.describe_layout(tree.branch.repository, tree.branch, tree,
86
control=tree.controldir))
81
info.describe_layout(tree.branch.repository, tree.branch, tree,
87
83
checkout = tree.branch.create_checkout('checkout', lightweight=True)
88
84
self.assertEqual('Lightweight checkout',
89
info.describe_layout(checkout.branch.repository, checkout.branch,
90
checkout, control=tree.controldir))
85
info.describe_layout(checkout.branch.repository, checkout.branch,
86
checkout, control=tree.bzrdir))
92
88
def assertTreeDescription(self, format):
93
89
"""Assert a tree's format description matches expectations"""
94
90
self.make_branch_and_tree('%s_tree' % format, format=format)
95
91
tree = workingtree.WorkingTree.open('%s_tree' % format)
96
self.assertEqual(format, info.describe_format(tree.controldir,
97
tree.branch.repository, tree.branch, tree))
92
self.assertEqual(format, info.describe_format(tree.bzrdir,
93
tree.branch.repository, tree.branch, tree))
99
95
def assertCheckoutDescription(self, format, expected=None):
100
96
"""Assert a checkout's format description matches expectations"""
103
99
branch = self.make_branch('%s_cobranch' % format, format=format)
104
100
# this ought to be easier...
105
101
branch.create_checkout('%s_co' % format,
106
lightweight=True).controldir.destroy_workingtree()
102
lightweight=True).bzrdir.destroy_workingtree()
107
103
control = controldir.ControlDir.open('%s_co' % format)
108
104
old_format = control._format.workingtree_format
110
106
control._format.workingtree_format = \
111
controldir.format_registry.make_controldir(
112
format).workingtree_format
107
controldir.format_registry.make_bzrdir(format).workingtree_format
113
108
control.create_workingtree()
114
109
tree = workingtree.WorkingTree.open('%s_co' % format)
115
format_description = info.describe_format(tree.controldir,
116
tree.branch.repository, tree.branch, tree)
110
format_description = info.describe_format(tree.bzrdir,
111
tree.branch.repository, tree.branch, tree)
117
112
self.assertEqual(expected, format_description,
118
"checkout of format called %r was described as %r" %
119
(expected, format_description))
113
"checkout of format called %r was described as %r" %
114
(expected, format_description))
121
116
control._format.workingtree_format = old_format
206
196
expected = '1.14-rich-root'
207
197
self.assertRepoDescription(key, expected)
209
format = controldir.format_registry.make_controldir('knit')
210
format.set_branch_format(_mod_bzrbranch.BzrBranchFormat6())
199
format = controldir.format_registry.make_bzrdir('knit')
200
format.set_branch_format(_mod_branch.BzrBranchFormat6())
211
201
tree = self.make_branch_and_tree('unknown', format=format)
212
self.assertEqual('unnamed', info.describe_format(tree.controldir,
213
tree.branch.repository, tree.branch, tree))
202
self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
203
tree.branch.repository, tree.branch, tree))
215
205
def test_gather_location_controldir_only(self):
216
bzrdir = self.make_controldir('.')
206
bzrdir = self.make_bzrdir('.')
217
207
self.assertEqual([('control directory', bzrdir.user_url)],
218
info.gather_location_info(control=bzrdir))
208
info.gather_location_info(control=bzrdir))
220
210
def test_gather_location_standalone(self):
221
211
tree = self.make_branch_and_tree('tree')
222
self.assertEqual([('branch root', tree.controldir.root_transport.base)],
223
info.gather_location_info(
224
tree.branch.repository, tree.branch, tree, control=tree.controldir))
225
self.assertEqual([('branch root', tree.controldir.root_transport.base)],
226
info.gather_location_info(
227
tree.branch.repository, tree.branch, control=tree.controldir))
212
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
213
info.gather_location_info(
214
tree.branch.repository, tree.branch, tree, control=tree.bzrdir))
215
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
216
info.gather_location_info(
217
tree.branch.repository, tree.branch, control=tree.bzrdir))
230
220
def test_gather_location_repo(self):
231
221
srepo = self.make_repository('shared', shared=True)
232
222
self.assertEqual(
233
[('shared repository', srepo.controldir.root_transport.base)],
234
info.gather_location_info(srepo, control=srepo.controldir))
223
[('shared repository', srepo.bzrdir.root_transport.base)],
224
info.gather_location_info(srepo, control=srepo.bzrdir))
235
225
urepo = self.make_repository('unshared')
236
226
self.assertEqual(
237
[('repository', urepo.controldir.root_transport.base)],
238
info.gather_location_info(urepo, control=urepo.controldir))
227
[('repository', urepo.bzrdir.root_transport.base)],
228
info.gather_location_info(urepo, control=urepo.bzrdir))
240
230
def test_gather_location_repo_branch(self):
241
231
srepo = self.make_repository('shared', shared=True)
242
232
self.assertEqual(
243
[('shared repository', srepo.controldir.root_transport.base)],
244
info.gather_location_info(srepo, control=srepo.controldir))
233
[('shared repository', srepo.bzrdir.root_transport.base)],
234
info.gather_location_info(srepo, control=srepo.bzrdir))
245
235
tree = self.make_branch_and_tree('shared/tree')
246
236
self.assertEqual(
247
[('shared repository', srepo.controldir.root_transport.base),
237
[('shared repository', srepo.bzrdir.root_transport.base),
248
238
('repository branch', tree.branch.base)],
249
info.gather_location_info(srepo, tree.branch, tree, srepo.controldir))
239
info.gather_location_info(srepo, tree.branch, tree, srepo.bzrdir))
251
241
def test_gather_location_light_checkout(self):
252
242
tree = self.make_branch_and_tree('tree')
253
243
lcheckout = tree.branch.create_checkout('lcheckout', lightweight=True)
254
244
self.assertEqual(
255
[('light checkout root', lcheckout.controldir.root_transport.base),
256
('checkout of branch', tree.controldir.root_transport.base)],
245
[('light checkout root', lcheckout.bzrdir.root_transport.base),
246
('checkout of branch', tree.bzrdir.root_transport.base)],
257
247
self.gather_tree_location_info(lcheckout))
259
249
def test_gather_location_heavy_checkout(self):
260
250
tree = self.make_branch_and_tree('tree')
261
251
checkout = tree.branch.create_checkout('checkout')
262
252
self.assertEqual(
263
[('checkout root', checkout.controldir.root_transport.base),
264
('checkout of branch', tree.controldir.root_transport.base)],
253
[('checkout root', checkout.bzrdir.root_transport.base),
254
('checkout of branch', tree.bzrdir.root_transport.base)],
265
255
self.gather_tree_location_info(checkout))
266
256
light_checkout = checkout.branch.create_checkout('light_checkout',
267
257
lightweight=True)
268
258
self.assertEqual(
269
259
[('light checkout root',
270
light_checkout.controldir.root_transport.base),
271
('checkout root', checkout.controldir.root_transport.base),
272
('checkout of branch', tree.controldir.root_transport.base)],
273
self.gather_tree_location_info(light_checkout)
260
light_checkout.bzrdir.root_transport.base),
261
('checkout root', checkout.bzrdir.root_transport.base),
262
('checkout of branch', tree.bzrdir.root_transport.base)],
263
self.gather_tree_location_info(light_checkout)
276
266
def test_gather_location_shared_repo_checkout(self):
277
267
tree = self.make_branch_and_tree('tree')
279
269
shared_checkout = tree.branch.create_checkout('shared/checkout')
280
270
self.assertEqual(
281
271
[('repository checkout root',
282
shared_checkout.controldir.root_transport.base),
283
('checkout of branch', tree.controldir.root_transport.base),
284
('shared repository', srepo.controldir.root_transport.base)],
285
self.gather_tree_location_info(shared_checkout))
272
shared_checkout.bzrdir.root_transport.base),
273
('checkout of branch', tree.bzrdir.root_transport.base),
274
('shared repository', srepo.bzrdir.root_transport.base)],
275
self.gather_tree_location_info(shared_checkout))
287
277
def gather_tree_location_info(self, tree):
288
278
return info.gather_location_info(
289
tree.branch.repository, tree.branch, tree, tree.controldir)
279
tree.branch.repository, tree.branch, tree, tree.bzrdir)
291
281
def test_gather_location_bound(self):
292
282
branch = self.make_branch('branch')
293
283
bound_branch = self.make_branch('bound_branch')
294
284
bound_branch.bind(branch)
295
285
self.assertEqual(
296
[('branch root', bound_branch.controldir.root_transport.base),
297
('bound to branch', branch.controldir.root_transport.base)],
286
[('branch root', bound_branch.bzrdir.root_transport.base),
287
('bound to branch', branch.bzrdir.root_transport.base)],
298
288
info.gather_location_info(
299
bound_branch.repository, bound_branch, control=bound_branch.controldir)
289
bound_branch.repository, bound_branch, control=bound_branch.bzrdir)
302
292
def test_gather_location_bound_in_repository(self):