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