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