31
32
def test_describe_standalone_layout(self):
32
33
tree = self.make_branch_and_tree('tree')
33
34
self.assertEqual('Empty control directory', info.describe_layout())
35
'Unshared repository with trees and colocated branches',
36
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
35
self.assertEqual('Unshared repository with trees',
36
info.describe_layout(tree.branch.repository))
37
37
tree.branch.repository.set_make_working_trees(False)
38
self.assertEqual('Unshared repository with colocated branches',
39
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
38
self.assertEqual('Unshared repository',
39
info.describe_layout(tree.branch.repository))
40
40
self.assertEqual('Standalone branch',
41
info.describe_layout(tree.branch.repository, tree.branch,
41
info.describe_layout(tree.branch.repository, tree.branch))
43
42
self.assertEqual('Standalone branchless tree',
44
info.describe_layout(tree.branch.repository, None, tree,
43
info.describe_layout(tree.branch.repository, None, tree))
46
44
self.assertEqual('Standalone tree',
47
info.describe_layout(tree.branch.repository, tree.branch, tree,
45
info.describe_layout(tree.branch.repository, tree.branch, tree))
49
46
tree.branch.bind(tree.branch)
50
47
self.assertEqual('Bound branch',
51
info.describe_layout(tree.branch.repository, tree.branch,
48
info.describe_layout(tree.branch.repository, tree.branch))
53
49
self.assertEqual('Checkout',
54
info.describe_layout(tree.branch.repository, tree.branch, tree,
50
info.describe_layout(tree.branch.repository, tree.branch, tree))
56
51
checkout = tree.branch.create_checkout('checkout', lightweight=True)
57
52
self.assertEqual('Lightweight checkout',
58
53
info.describe_layout(checkout.branch.repository, checkout.branch,
59
checkout, control=tree.bzrdir))
61
56
def test_describe_repository_layout(self):
62
57
repository = self.make_repository('.', shared=True)
63
tree = controldir.ControlDir.create_branch_convenience('tree',
58
tree = bzrdir.BzrDir.create_branch_convenience('tree',
64
59
force_new_tree=True).bzrdir.open_workingtree()
65
self.assertEqual('Shared repository with trees and colocated branches',
66
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
60
self.assertEqual('Shared repository with trees',
61
info.describe_layout(tree.branch.repository))
67
62
repository.set_make_working_trees(False)
68
self.assertEqual('Shared repository with colocated branches',
69
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
63
self.assertEqual('Shared repository',
64
info.describe_layout(tree.branch.repository))
70
65
self.assertEqual('Repository branch',
71
info.describe_layout(tree.branch.repository, tree.branch,
66
info.describe_layout(tree.branch.repository, tree.branch))
73
67
self.assertEqual('Repository branchless tree',
74
info.describe_layout(tree.branch.repository, None, tree,
68
info.describe_layout(tree.branch.repository, None, tree))
76
69
self.assertEqual('Repository tree',
77
info.describe_layout(tree.branch.repository, tree.branch, tree,
70
info.describe_layout(tree.branch.repository, tree.branch, tree))
79
71
tree.branch.bind(tree.branch)
80
72
self.assertEqual('Repository checkout',
81
info.describe_layout(tree.branch.repository, tree.branch, tree,
73
info.describe_layout(tree.branch.repository, tree.branch, tree))
83
74
checkout = tree.branch.create_checkout('checkout', lightweight=True)
84
75
self.assertEqual('Lightweight checkout',
85
76
info.describe_layout(checkout.branch.repository, checkout.branch,
86
checkout, control=tree.bzrdir))
88
79
def assertTreeDescription(self, format):
89
80
"""Assert a tree's format description matches expectations"""
134
125
repo, None, None))
136
127
def test_describe_tree_format(self):
137
for key in controldir.format_registry.keys():
138
if key in controldir.format_registry.aliases():
128
for key in bzrdir.format_registry.keys():
129
if key in bzrdir.format_registry.aliases():
140
131
self.assertTreeDescription(key)
142
133
def test_describe_checkout_format(self):
143
for key in controldir.format_registry.keys():
144
if key in controldir.format_registry.aliases():
134
for key in bzrdir.format_registry.keys():
135
if key in bzrdir.format_registry.aliases():
145
136
# Aliases will not describe correctly in the UI because the
146
137
# real format is found.
148
139
# legacy: weave does not support checkouts
149
140
if key == 'weave':
151
if controldir.format_registry.get_info(key).experimental:
142
if bzrdir.format_registry.get_info(key).experimental:
152
143
# We don't require that experimental formats support checkouts
153
144
# or describe correctly in the UI.
155
if controldir.format_registry.get_info(key).hidden:
158
if key in ('pack-0.92',):
159
expected = 'pack-0.92'
160
elif key in ('knit', 'metaweave'):
161
if 'metaweave' in controldir.format_registry:
162
expected = 'knit or metaweave'
165
elif key in ('1.14', '1.14-rich-root'):
166
expected = '1.14 or 1.14-rich-root'
147
if key in ('dirstate', 'dirstate-tags', 'dirstate-with-subtree',
148
'pack-0.92', 'pack-0.92-subtree', 'rich-root',
149
'rich-root-pack', '1.6', '1.6.1-rich-root'):
150
expected = '1.6 or 1.6.1-rich-root or ' \
151
'dirstate or dirstate-tags or pack-0.92 or'\
152
' rich-root or rich-root-pack'
153
if key in ('knit', 'metaweave'):
154
expected = 'knit or metaweave'
167
155
self.assertCheckoutDescription(key, expected)
169
157
def test_describe_branch_format(self):
170
for key in controldir.format_registry.keys():
171
if key in controldir.format_registry.aliases():
173
if controldir.format_registry.get_info(key).hidden:
158
for key in bzrdir.format_registry.keys():
159
if key in bzrdir.format_registry.aliases():
176
162
if key in ('dirstate', 'knit'):
177
163
expected = 'dirstate or knit'
178
elif key in ('1.14',):
180
elif key in ('1.14-rich-root',):
181
expected = '1.14-rich-root'
182
164
self.assertBranchDescription(key, expected)
184
166
def test_describe_repo_format(self):
185
for key in controldir.format_registry.keys():
186
if key in controldir.format_registry.aliases():
188
if controldir.format_registry.get_info(key).hidden:
167
for key in bzrdir.format_registry.keys():
168
if key in bzrdir.format_registry.aliases():
191
171
if key in ('dirstate', 'knit', 'dirstate-tags'):
192
172
expected = 'dirstate or dirstate-tags or knit'
193
elif key in ('1.14',):
195
elif key in ('1.14-rich-root',):
196
expected = '1.14-rich-root'
197
173
self.assertRepoDescription(key, expected)
199
format = controldir.format_registry.make_bzrdir('knit')
175
format = bzrdir.format_registry.make_bzrdir('metaweave')
200
176
format.set_branch_format(_mod_branch.BzrBranchFormat6())
201
177
tree = self.make_branch_and_tree('unknown', format=format)
202
178
self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
203
179
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))
210
181
def test_gather_location_standalone(self):
211
182
tree = self.make_branch_and_tree('tree')
212
183
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
213
info.gather_location_info(
214
tree.branch.repository, tree.branch, tree, control=tree.bzrdir))
184
info.gather_location_info(tree.branch.repository, tree.branch,
215
186
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
216
info.gather_location_info(
217
tree.branch.repository, tree.branch, control=tree.bzrdir))
187
info.gather_location_info(tree.branch.repository, tree.branch))
220
190
def test_gather_location_repo(self):
221
191
srepo = self.make_repository('shared', shared=True)
223
[('shared repository', srepo.bzrdir.root_transport.base)],
224
info.gather_location_info(srepo, control=srepo.bzrdir))
192
self.assertEqual([('shared repository',
193
srepo.bzrdir.root_transport.base)],
194
info.gather_location_info(srepo))
225
195
urepo = self.make_repository('unshared')
227
[('repository', urepo.bzrdir.root_transport.base)],
228
info.gather_location_info(urepo, control=urepo.bzrdir))
196
self.assertEqual([('repository',
197
urepo.bzrdir.root_transport.base)],
198
info.gather_location_info(urepo))
230
200
def test_gather_location_repo_branch(self):
231
201
srepo = self.make_repository('shared', shared=True)
233
[('shared repository', srepo.bzrdir.root_transport.base)],
234
info.gather_location_info(srepo, control=srepo.bzrdir))
202
self.assertEqual([('shared repository',
203
srepo.bzrdir.root_transport.base)],
204
info.gather_location_info(srepo))
235
205
tree = self.make_branch_and_tree('shared/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))
206
self.assertEqual([('shared repository',
207
srepo.bzrdir.root_transport.base),
208
('repository branch', tree.branch.base)],
209
info.gather_location_info(srepo, tree.branch, tree))
241
211
def test_gather_location_light_checkout(self):
242
212
tree = self.make_branch_and_tree('tree')