35
32
def test_describe_standalone_layout(self):
36
33
tree = self.make_branch_and_tree('tree')
37
34
self.assertEqual('Empty control directory', info.describe_layout())
39
'Unshared repository with trees and colocated branches',
40
info.describe_layout(tree.branch.repository, control=tree.controldir))
35
self.assertEqual('Unshared repository with trees',
36
info.describe_layout(tree.branch.repository))
41
37
tree.branch.repository.set_make_working_trees(False)
42
self.assertEqual('Unshared repository with colocated branches',
43
info.describe_layout(tree.branch.repository, control=tree.controldir))
38
self.assertEqual('Unshared repository',
39
info.describe_layout(tree.branch.repository))
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
42
self.assertEqual('Standalone branchless tree',
48
info.describe_layout(tree.branch.repository, None, tree,
49
control=tree.controldir))
43
info.describe_layout(tree.branch.repository, None, tree))
50
44
self.assertEqual('Standalone tree',
51
info.describe_layout(tree.branch.repository, tree.branch, tree,
52
control=tree.controldir))
45
info.describe_layout(tree.branch.repository, tree.branch, tree))
53
46
tree.branch.bind(tree.branch)
54
47
self.assertEqual('Bound branch',
55
info.describe_layout(tree.branch.repository, tree.branch,
56
control=tree.controldir))
48
info.describe_layout(tree.branch.repository, tree.branch))
57
49
self.assertEqual('Checkout',
58
info.describe_layout(tree.branch.repository, tree.branch, tree,
59
control=tree.controldir))
50
info.describe_layout(tree.branch.repository, tree.branch, tree))
60
51
checkout = tree.branch.create_checkout('checkout', lightweight=True)
61
52
self.assertEqual('Lightweight checkout',
62
info.describe_layout(checkout.branch.repository, checkout.branch,
63
checkout, control=tree.controldir))
53
info.describe_layout(checkout.branch.repository, checkout.branch,
65
56
def test_describe_repository_layout(self):
66
57
repository = self.make_repository('.', shared=True)
67
tree = controldir.ControlDir.create_branch_convenience('tree',
68
force_new_tree=True).controldir.open_workingtree()
69
self.assertEqual('Shared repository with trees and colocated branches',
70
info.describe_layout(tree.branch.repository, control=tree.controldir))
58
tree = bzrdir.BzrDir.create_branch_convenience('tree',
59
force_new_tree=True).bzrdir.open_workingtree()
60
self.assertEqual('Shared repository with trees',
61
info.describe_layout(tree.branch.repository))
71
62
repository.set_make_working_trees(False)
72
self.assertEqual('Shared repository with colocated branches',
73
info.describe_layout(tree.branch.repository, control=tree.controldir))
63
self.assertEqual('Shared repository',
64
info.describe_layout(tree.branch.repository))
74
65
self.assertEqual('Repository branch',
75
info.describe_layout(tree.branch.repository, tree.branch,
76
control=tree.controldir))
66
info.describe_layout(tree.branch.repository, tree.branch))
77
67
self.assertEqual('Repository branchless tree',
78
info.describe_layout(tree.branch.repository, None, tree,
79
control=tree.controldir))
68
info.describe_layout(tree.branch.repository, None, tree))
80
69
self.assertEqual('Repository tree',
81
info.describe_layout(tree.branch.repository, tree.branch, tree,
82
control=tree.controldir))
70
info.describe_layout(tree.branch.repository, tree.branch, tree))
83
71
tree.branch.bind(tree.branch)
84
72
self.assertEqual('Repository checkout',
85
info.describe_layout(tree.branch.repository, tree.branch, tree,
86
control=tree.controldir))
73
info.describe_layout(tree.branch.repository, tree.branch, tree))
87
74
checkout = tree.branch.create_checkout('checkout', lightweight=True)
88
75
self.assertEqual('Lightweight checkout',
89
info.describe_layout(checkout.branch.repository, checkout.branch,
90
checkout, control=tree.controldir))
76
info.describe_layout(checkout.branch.repository, checkout.branch,
92
79
def assertTreeDescription(self, format):
93
80
"""Assert a tree's format description matches expectations"""
94
81
self.make_branch_and_tree('%s_tree' % format, format=format)
95
82
tree = workingtree.WorkingTree.open('%s_tree' % format)
96
self.assertEqual(format, info.describe_format(tree.controldir,
97
tree.branch.repository, tree.branch, tree))
83
self.assertEqual(format, info.describe_format(tree.bzrdir,
84
tree.branch.repository, tree.branch, tree))
99
86
def assertCheckoutDescription(self, format, expected=None):
100
87
"""Assert a checkout's format description matches expectations"""
103
90
branch = self.make_branch('%s_cobranch' % format, format=format)
104
91
# this ought to be easier...
105
92
branch.create_checkout('%s_co' % format,
106
lightweight=True).controldir.destroy_workingtree()
107
control = controldir.ControlDir.open('%s_co' % format)
93
lightweight=True).bzrdir.destroy_workingtree()
94
control = bzrdir.BzrDir.open('%s_co' % format)
108
95
old_format = control._format.workingtree_format
110
97
control._format.workingtree_format = \
111
controldir.format_registry.make_controldir(
112
format).workingtree_format
98
bzrdir.format_registry.make_bzrdir(format).workingtree_format
113
99
control.create_workingtree()
114
100
tree = workingtree.WorkingTree.open('%s_co' % format)
115
format_description = info.describe_format(tree.controldir,
116
tree.branch.repository, tree.branch, tree)
101
format_description = info.describe_format(tree.bzrdir,
102
tree.branch.repository, tree.branch, tree)
117
103
self.assertEqual(expected, format_description,
118
"checkout of format called %r was described as %r" %
119
(expected, format_description))
104
"checkout of format called %r was described as %r" %
105
(expected, format_description))
121
107
control._format.workingtree_format = old_format
135
121
expected = format
136
122
self.make_repository('%s_repo' % format, format=format)
137
123
repo = _mod_repository.Repository.open('%s_repo' % format)
138
self.assertEqual(expected, info.describe_format(repo.controldir,
124
self.assertEqual(expected, info.describe_format(repo.bzrdir,
141
127
def test_describe_tree_format(self):
142
for key, format in controldir.format_registry.iteritems():
143
if key in controldir.format_registry.aliases():
145
if not format().supports_workingtrees:
128
for key in bzrdir.format_registry.keys():
129
if key in bzrdir.format_registry.aliases():
147
131
self.assertTreeDescription(key)
149
133
def test_describe_checkout_format(self):
150
for key in controldir.format_registry.keys():
151
if key in controldir.format_registry.aliases():
134
for key in bzrdir.format_registry.keys():
135
if key in bzrdir.format_registry.aliases():
152
136
# Aliases will not describe correctly in the UI because the
153
137
# real format is found.
155
139
# legacy: weave does not support checkouts
156
140
if key == 'weave':
158
# foreign: git checkouts can actually be bzr controldirs
159
if key in ('git', 'git-bare'):
161
if controldir.format_registry.get_info(key).experimental:
142
if bzrdir.format_registry.get_info(key).experimental:
162
143
# We don't require that experimental formats support checkouts
163
144
# or describe correctly in the UI.
165
if controldir.format_registry.get_info(key).hidden:
146
if bzrdir.format_registry.get_info(key).hidden:
168
149
if key in ('pack-0.92',):
169
150
expected = 'pack-0.92'
170
151
elif key in ('knit', 'metaweave'):
171
if 'metaweave' in controldir.format_registry:
172
expected = 'knit or metaweave'
152
expected = 'knit or metaweave'
175
153
elif key in ('1.14', '1.14-rich-root'):
176
154
expected = '1.14 or 1.14-rich-root'
177
155
self.assertCheckoutDescription(key, expected)
179
157
def test_describe_branch_format(self):
180
for key in controldir.format_registry.keys():
181
if key in controldir.format_registry.aliases():
158
for key in bzrdir.format_registry.keys():
159
if key in bzrdir.format_registry.aliases():
183
if controldir.format_registry.get_info(key).hidden:
161
if bzrdir.format_registry.get_info(key).hidden:
186
164
if key in ('dirstate', 'knit'):
206
184
expected = '1.14-rich-root'
207
185
self.assertRepoDescription(key, expected)
209
format = controldir.format_registry.make_controldir('knit')
210
format.set_branch_format(_mod_bzrbranch.BzrBranchFormat6())
187
format = bzrdir.format_registry.make_bzrdir('metaweave')
188
format.set_branch_format(_mod_branch.BzrBranchFormat6())
211
189
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))
215
def test_gather_location_controldir_only(self):
216
bzrdir = self.make_controldir('.')
217
self.assertEqual([('control directory', bzrdir.user_url)],
218
info.gather_location_info(control=bzrdir))
190
self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
191
tree.branch.repository, tree.branch, tree))
220
193
def test_gather_location_standalone(self):
221
194
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))
195
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
196
info.gather_location_info(tree.branch.repository, tree.branch,
198
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
199
info.gather_location_info(tree.branch.repository, tree.branch))
230
202
def test_gather_location_repo(self):
231
203
srepo = self.make_repository('shared', shared=True)
233
[('shared repository', srepo.controldir.root_transport.base)],
234
info.gather_location_info(srepo, control=srepo.controldir))
204
self.assertEqual([('shared repository',
205
srepo.bzrdir.root_transport.base)],
206
info.gather_location_info(srepo))
235
207
urepo = self.make_repository('unshared')
237
[('repository', urepo.controldir.root_transport.base)],
238
info.gather_location_info(urepo, control=urepo.controldir))
208
self.assertEqual([('repository',
209
urepo.bzrdir.root_transport.base)],
210
info.gather_location_info(urepo))
240
212
def test_gather_location_repo_branch(self):
241
213
srepo = self.make_repository('shared', shared=True)
243
[('shared repository', srepo.controldir.root_transport.base)],
244
info.gather_location_info(srepo, control=srepo.controldir))
214
self.assertEqual([('shared repository',
215
srepo.bzrdir.root_transport.base)],
216
info.gather_location_info(srepo))
245
217
tree = self.make_branch_and_tree('shared/tree')
247
[('shared repository', srepo.controldir.root_transport.base),
248
('repository branch', tree.branch.base)],
249
info.gather_location_info(srepo, tree.branch, tree, srepo.controldir))
218
self.assertEqual([('shared repository',
219
srepo.bzrdir.root_transport.base),
220
('repository branch', tree.branch.base)],
221
info.gather_location_info(srepo, tree.branch, tree))
251
223
def test_gather_location_light_checkout(self):
252
224
tree = self.make_branch_and_tree('tree')
253
225
lcheckout = tree.branch.create_checkout('lcheckout', lightweight=True)
254
226
self.assertEqual(
255
[('light checkout root', lcheckout.controldir.root_transport.base),
256
('checkout of branch', tree.controldir.root_transport.base)],
227
[('light checkout root', lcheckout.bzrdir.root_transport.base),
228
('checkout of branch', tree.bzrdir.root_transport.base)],
257
229
self.gather_tree_location_info(lcheckout))
259
231
def test_gather_location_heavy_checkout(self):
260
232
tree = self.make_branch_and_tree('tree')
261
233
checkout = tree.branch.create_checkout('checkout')
262
234
self.assertEqual(
263
[('checkout root', checkout.controldir.root_transport.base),
264
('checkout of branch', tree.controldir.root_transport.base)],
235
[('checkout root', checkout.bzrdir.root_transport.base),
236
('checkout of branch', tree.bzrdir.root_transport.base)],
265
237
self.gather_tree_location_info(checkout))
266
238
light_checkout = checkout.branch.create_checkout('light_checkout',
267
239
lightweight=True)
268
240
self.assertEqual(
269
241
[('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)
242
light_checkout.bzrdir.root_transport.base),
243
('checkout root', checkout.bzrdir.root_transport.base),
244
('checkout of branch', tree.bzrdir.root_transport.base)],
245
self.gather_tree_location_info(light_checkout)
276
248
def test_gather_location_shared_repo_checkout(self):
277
249
tree = self.make_branch_and_tree('tree')
279
251
shared_checkout = tree.branch.create_checkout('shared/checkout')
280
252
self.assertEqual(
281
253
[('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))
254
shared_checkout.bzrdir.root_transport.base),
255
('checkout of branch', tree.bzrdir.root_transport.base),
256
('shared repository', srepo.bzrdir.root_transport.base)],
257
self.gather_tree_location_info(shared_checkout))
287
259
def gather_tree_location_info(self, tree):
288
return info.gather_location_info(
289
tree.branch.repository, tree.branch, tree, tree.controldir)
260
return info.gather_location_info(tree.branch.repository, tree.branch,
291
263
def test_gather_location_bound(self):
292
264
branch = self.make_branch('branch')
293
265
bound_branch = self.make_branch('bound_branch')
294
266
bound_branch.bind(branch)
295
267
self.assertEqual(
296
[('branch root', bound_branch.controldir.root_transport.base),
297
('bound to branch', branch.controldir.root_transport.base)],
298
info.gather_location_info(
299
bound_branch.repository, bound_branch, control=bound_branch.controldir)
302
def test_gather_location_bound_in_repository(self):
303
repo = self.make_repository('repo', shared=True)
304
repo.set_make_working_trees(False)
305
branch = self.make_branch('branch')
306
bound_branch = controldir.ControlDir.create_branch_convenience(
308
bound_branch.bind(branch)
310
[('shared repository', bound_branch.repository.controldir.user_url),
311
('repository branch', bound_branch.controldir.user_url),
312
('bound to branch', branch.controldir.user_url)],
268
[('branch root', bound_branch.bzrdir.root_transport.base),
269
('bound to branch', branch.bzrdir.root_transport.base)],
313
270
info.gather_location_info(bound_branch.repository, bound_branch)