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.bzrdir))
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.bzrdir))
40
41
self.assertEqual('Standalone branch',
41
info.describe_layout(tree.branch.repository, tree.branch))
42
info.describe_layout(tree.branch.repository, tree.branch,
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,
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,
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,
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,
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.bzrdir))
56
62
def test_describe_repository_layout(self):
57
63
repository = self.make_repository('.', shared=True)
58
tree = bzrdir.BzrDir.create_branch_convenience('tree',
64
tree = controldir.ControlDir.create_branch_convenience('tree',
59
65
force_new_tree=True).bzrdir.open_workingtree()
60
self.assertEqual('Shared repository with trees',
61
info.describe_layout(tree.branch.repository))
66
self.assertEqual('Shared repository with trees and colocated branches',
67
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
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.bzrdir))
65
71
self.assertEqual('Repository branch',
66
info.describe_layout(tree.branch.repository, tree.branch))
72
info.describe_layout(tree.branch.repository, tree.branch,
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,
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,
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,
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.bzrdir))
79
89
def assertTreeDescription(self, format):
80
90
"""Assert a tree's format description matches expectations"""
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_bzrdir('knit')
201
format.set_branch_format(_mod_bzrbranch.BzrBranchFormat6())
189
202
tree = self.make_branch_and_tree('unknown', format=format)
190
203
self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
191
204
tree.branch.repository, tree.branch, tree))
206
def test_gather_location_controldir_only(self):
207
bzrdir = self.make_bzrdir('.')
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
213
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
196
info.gather_location_info(tree.branch.repository, tree.branch,
214
info.gather_location_info(
215
tree.branch.repository, tree.branch, tree, control=tree.bzrdir))
198
216
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
199
info.gather_location_info(tree.branch.repository, tree.branch))
217
info.gather_location_info(
218
tree.branch.repository, tree.branch, control=tree.bzrdir))
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.bzrdir.root_transport.base)],
225
info.gather_location_info(srepo, control=srepo.bzrdir))
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.bzrdir.root_transport.base)],
229
info.gather_location_info(urepo, control=urepo.bzrdir))
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.bzrdir.root_transport.base)],
235
info.gather_location_info(srepo, control=srepo.bzrdir))
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.bzrdir.root_transport.base),
239
('repository branch', tree.branch.base)],
240
info.gather_location_info(srepo, tree.branch, tree, srepo.bzrdir))
223
242
def test_gather_location_light_checkout(self):
224
243
tree = self.make_branch_and_tree('tree')
267
286
self.assertEqual(
268
287
[('branch root', bound_branch.bzrdir.root_transport.base),
269
288
('bound to branch', branch.bzrdir.root_transport.base)],
289
info.gather_location_info(
290
bound_branch.repository, bound_branch, control=bound_branch.bzrdir)
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.bzrdir.user_url),
302
('repository branch', bound_branch.bzrdir.user_url),
303
('bound to branch', branch.bzrdir.user_url)],
270
304
info.gather_location_info(bound_branch.repository, bound_branch)