31
31
def test_describe_standalone_layout(self):
32
32
tree = self.make_branch_and_tree('tree')
33
33
self.assertEqual('Empty control directory', info.describe_layout())
34
self.assertEqual('Unshared repository with trees',
35
info.describe_layout(tree.branch.repository))
35
'Unshared repository with trees and colocated branches',
36
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
36
37
tree.branch.repository.set_make_working_trees(False)
37
self.assertEqual('Unshared repository',
38
info.describe_layout(tree.branch.repository))
38
self.assertEqual('Unshared repository with colocated branches',
39
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
39
40
self.assertEqual('Standalone branch',
40
info.describe_layout(tree.branch.repository, tree.branch))
41
info.describe_layout(tree.branch.repository, tree.branch,
41
43
self.assertEqual('Standalone branchless tree',
42
info.describe_layout(tree.branch.repository, None, tree))
44
info.describe_layout(tree.branch.repository, None, tree,
43
46
self.assertEqual('Standalone tree',
44
info.describe_layout(tree.branch.repository, tree.branch, tree))
47
info.describe_layout(tree.branch.repository, tree.branch, tree,
45
49
tree.branch.bind(tree.branch)
46
50
self.assertEqual('Bound branch',
47
info.describe_layout(tree.branch.repository, tree.branch))
51
info.describe_layout(tree.branch.repository, tree.branch,
48
53
self.assertEqual('Checkout',
49
info.describe_layout(tree.branch.repository, tree.branch, tree))
54
info.describe_layout(tree.branch.repository, tree.branch, tree,
50
56
checkout = tree.branch.create_checkout('checkout', lightweight=True)
51
57
self.assertEqual('Lightweight checkout',
52
58
info.describe_layout(checkout.branch.repository, checkout.branch,
59
checkout, control=tree.bzrdir))
55
61
def test_describe_repository_layout(self):
56
62
repository = self.make_repository('.', shared=True)
57
tree = bzrdir.BzrDir.create_branch_convenience('tree',
63
tree = controldir.ControlDir.create_branch_convenience('tree',
58
64
force_new_tree=True).bzrdir.open_workingtree()
59
self.assertEqual('Shared repository with trees',
60
info.describe_layout(tree.branch.repository))
65
self.assertEqual('Shared repository with trees and colocated branches',
66
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
61
67
repository.set_make_working_trees(False)
62
self.assertEqual('Shared repository',
63
info.describe_layout(tree.branch.repository))
68
self.assertEqual('Shared repository with colocated branches',
69
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
64
70
self.assertEqual('Repository branch',
65
info.describe_layout(tree.branch.repository, tree.branch))
71
info.describe_layout(tree.branch.repository, tree.branch,
66
73
self.assertEqual('Repository branchless tree',
67
info.describe_layout(tree.branch.repository, None, tree))
74
info.describe_layout(tree.branch.repository, None, tree,
68
76
self.assertEqual('Repository tree',
69
info.describe_layout(tree.branch.repository, tree.branch, tree))
77
info.describe_layout(tree.branch.repository, tree.branch, tree,
70
79
tree.branch.bind(tree.branch)
71
80
self.assertEqual('Repository checkout',
72
info.describe_layout(tree.branch.repository, tree.branch, tree))
81
info.describe_layout(tree.branch.repository, tree.branch, tree,
73
83
checkout = tree.branch.create_checkout('checkout', lightweight=True)
74
84
self.assertEqual('Lightweight checkout',
75
85
info.describe_layout(checkout.branch.repository, checkout.branch,
86
checkout, control=tree.bzrdir))
78
88
def assertTreeDescription(self, format):
79
89
"""Assert a tree's format description matches expectations"""
124
134
repo, None, None))
126
136
def test_describe_tree_format(self):
127
for key in bzrdir.format_registry.keys():
128
if key in bzrdir.format_registry.aliases():
137
for key in controldir.format_registry.keys():
138
if key in controldir.format_registry.aliases():
130
140
self.assertTreeDescription(key)
132
142
def test_describe_checkout_format(self):
133
for key in bzrdir.format_registry.keys():
134
if key in bzrdir.format_registry.aliases():
143
for key in controldir.format_registry.keys():
144
if key in controldir.format_registry.aliases():
135
145
# Aliases will not describe correctly in the UI because the
136
146
# real format is found.
138
148
# legacy: weave does not support checkouts
139
149
if key == 'weave':
141
if bzrdir.format_registry.get_info(key).experimental:
151
if controldir.format_registry.get_info(key).experimental:
142
152
# We don't require that experimental formats support checkouts
143
153
# or describe correctly in the UI.
145
if bzrdir.format_registry.get_info(key).hidden:
155
if controldir.format_registry.get_info(key).hidden:
148
158
if key in ('pack-0.92',):
149
159
expected = 'pack-0.92'
150
160
elif key in ('knit', 'metaweave'):
151
if 'metaweave' in bzrdir.format_registry:
161
if 'metaweave' in controldir.format_registry:
152
162
expected = 'knit or metaweave'
154
164
expected = 'knit'
186
196
expected = '1.14-rich-root'
187
197
self.assertRepoDescription(key, expected)
189
format = bzrdir.format_registry.make_bzrdir('knit')
199
format = controldir.format_registry.make_bzrdir('knit')
190
200
format.set_branch_format(_mod_branch.BzrBranchFormat6())
191
201
tree = self.make_branch_and_tree('unknown', format=format)
192
202
self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
193
203
tree.branch.repository, tree.branch, tree))
205
def test_gather_location_controldir_only(self):
206
bzrdir = self.make_bzrdir('.')
207
self.assertEqual([('control directory', bzrdir.user_url)],
208
info.gather_location_info(control=bzrdir))
195
210
def test_gather_location_standalone(self):
196
211
tree = self.make_branch_and_tree('tree')
197
212
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
198
info.gather_location_info(tree.branch.repository, tree.branch,
213
info.gather_location_info(
214
tree.branch.repository, tree.branch, tree, control=tree.bzrdir))
200
215
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
201
info.gather_location_info(tree.branch.repository, tree.branch))
216
info.gather_location_info(
217
tree.branch.repository, tree.branch, control=tree.bzrdir))
204
220
def test_gather_location_repo(self):
205
221
srepo = self.make_repository('shared', shared=True)
206
self.assertEqual([('shared repository',
207
srepo.bzrdir.root_transport.base)],
208
info.gather_location_info(srepo))
223
[('shared repository', srepo.bzrdir.root_transport.base)],
224
info.gather_location_info(srepo, control=srepo.bzrdir))
209
225
urepo = self.make_repository('unshared')
210
self.assertEqual([('repository',
211
urepo.bzrdir.root_transport.base)],
212
info.gather_location_info(urepo))
227
[('repository', urepo.bzrdir.root_transport.base)],
228
info.gather_location_info(urepo, control=urepo.bzrdir))
214
230
def test_gather_location_repo_branch(self):
215
231
srepo = self.make_repository('shared', shared=True)
216
self.assertEqual([('shared repository',
217
srepo.bzrdir.root_transport.base)],
218
info.gather_location_info(srepo))
233
[('shared repository', srepo.bzrdir.root_transport.base)],
234
info.gather_location_info(srepo, control=srepo.bzrdir))
219
235
tree = self.make_branch_and_tree('shared/tree')
220
self.assertEqual([('shared repository',
221
srepo.bzrdir.root_transport.base),
222
('repository branch', tree.branch.base)],
223
info.gather_location_info(srepo, tree.branch, tree))
237
[('shared repository', srepo.bzrdir.root_transport.base),
238
('repository branch', tree.branch.base)],
239
info.gather_location_info(srepo, tree.branch, tree, srepo.bzrdir))
225
241
def test_gather_location_light_checkout(self):
226
242
tree = self.make_branch_and_tree('tree')
269
285
self.assertEqual(
270
286
[('branch root', bound_branch.bzrdir.root_transport.base),
271
287
('bound to branch', branch.bzrdir.root_transport.base)],
288
info.gather_location_info(
289
bound_branch.repository, bound_branch, control=bound_branch.bzrdir)
292
def test_gather_location_bound_in_repository(self):
293
repo = self.make_repository('repo', shared=True)
294
repo.set_make_working_trees(False)
295
branch = self.make_branch('branch')
296
bound_branch = controldir.ControlDir.create_branch_convenience(
298
bound_branch.bind(branch)
300
[('shared repository', bound_branch.repository.bzrdir.user_url),
301
('repository branch', bound_branch.bzrdir.user_url),
302
('bound to branch', branch.bzrdir.user_url)],
272
303
info.gather_location_info(bound_branch.repository, bound_branch)