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