98
95
bzrdir.format_registry.make_bzrdir(format).workingtree_format
99
96
control.create_workingtree()
100
97
tree = workingtree.WorkingTree.open('%s_co' % format)
101
format_description = info.describe_format(tree.bzrdir,
102
tree.branch.repository, tree.branch, tree)
103
self.assertEqual(expected, format_description,
104
"checkout of format called %r was described as %r" %
105
(expected, format_description))
98
self.assertEqual(expected, info.describe_format(tree.bzrdir,
99
tree.branch.repository, tree.branch, tree))
107
101
control._format.workingtree_format = old_format
109
103
def assertBranchDescription(self, format, expected=None):
110
"""Assert branch's format description matches expectations"""
111
104
if expected is None:
112
105
expected = format
113
106
self.make_branch('%s_branch' % format, format=format)
124
116
self.assertEqual(expected, info.describe_format(repo.bzrdir,
125
117
repo, None, None))
127
def test_describe_tree_format(self):
119
def test_describe_format(self):
128
120
for key in bzrdir.format_registry.keys():
129
if key in bzrdir.format_registry.aliases():
131
123
self.assertTreeDescription(key)
133
def test_describe_checkout_format(self):
134
125
for key in bzrdir.format_registry.keys():
135
if key in bzrdir.format_registry.aliases():
136
# Aliases will not describe correctly in the UI because the
137
# real format is found.
139
# legacy: weave does not support checkouts
142
if bzrdir.format_registry.get_info(key).experimental:
143
# We don't require that experimental formats support checkouts
144
# or describe correctly in the UI.
146
if bzrdir.format_registry.get_info(key).hidden:
126
if key in ('default', 'weave'):
149
if key in ('pack-0.92',):
150
expected = 'pack-0.92'
151
elif key in ('knit', 'metaweave'):
152
expected = 'knit or metaweave'
153
elif key in ('1.14', '1.14-rich-root'):
154
expected = '1.14 or 1.14-rich-root'
129
if key in ('dirstate', 'dirstate-tags', 'dirstate-with-subtree'):
130
expected = 'dirstate / dirstate-tags'
131
if key in ('knit', 'metaweave'):
132
expected = 'knit / metaweave'
155
133
self.assertCheckoutDescription(key, expected)
157
def test_describe_branch_format(self):
158
135
for key in bzrdir.format_registry.keys():
159
if key in bzrdir.format_registry.aliases():
161
if bzrdir.format_registry.get_info(key).hidden:
164
139
if key in ('dirstate', 'knit'):
165
expected = 'dirstate or knit'
166
elif key in ('1.14',):
168
elif key in ('1.14-rich-root',):
169
expected = '1.14-rich-root'
140
expected = 'dirstate / knit'
170
141
self.assertBranchDescription(key, expected)
172
def test_describe_repo_format(self):
173
143
for key in bzrdir.format_registry.keys():
174
if key in bzrdir.format_registry.aliases():
176
if bzrdir.format_registry.get_info(key).hidden:
179
147
if key in ('dirstate', 'knit', 'dirstate-tags'):
180
expected = 'dirstate or dirstate-tags or knit'
181
elif key in ('1.14',):
183
elif key in ('1.14-rich-root',):
184
expected = '1.14-rich-root'
148
expected = 'dirstate / dirstate-tags / knit'
185
149
self.assertRepoDescription(key, expected)
187
151
format = bzrdir.format_registry.make_bzrdir('metaweave')
189
153
tree = self.make_branch_and_tree('unknown', format=format)
190
154
self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
191
155
tree.branch.repository, tree.branch, tree))
193
def test_gather_location_standalone(self):
194
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))
202
def test_gather_location_repo(self):
203
srepo = self.make_repository('shared', shared=True)
204
self.assertEqual([('shared repository',
205
srepo.bzrdir.root_transport.base)],
206
info.gather_location_info(srepo))
207
urepo = self.make_repository('unshared')
208
self.assertEqual([('repository',
209
urepo.bzrdir.root_transport.base)],
210
info.gather_location_info(urepo))
212
def test_gather_location_repo_branch(self):
213
srepo = self.make_repository('shared', shared=True)
214
self.assertEqual([('shared repository',
215
srepo.bzrdir.root_transport.base)],
216
info.gather_location_info(srepo))
217
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))
223
def test_gather_location_light_checkout(self):
224
tree = self.make_branch_and_tree('tree')
225
lcheckout = tree.branch.create_checkout('lcheckout', lightweight=True)
227
[('light checkout root', lcheckout.bzrdir.root_transport.base),
228
('checkout of branch', tree.bzrdir.root_transport.base)],
229
self.gather_tree_location_info(lcheckout))
231
def test_gather_location_heavy_checkout(self):
232
tree = self.make_branch_and_tree('tree')
233
checkout = tree.branch.create_checkout('checkout')
235
[('checkout root', checkout.bzrdir.root_transport.base),
236
('checkout of branch', tree.bzrdir.root_transport.base)],
237
self.gather_tree_location_info(checkout))
238
light_checkout = checkout.branch.create_checkout('light_checkout',
241
[('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)
248
def test_gather_location_shared_repo_checkout(self):
249
tree = self.make_branch_and_tree('tree')
250
srepo = self.make_repository('shared', shared=True)
251
shared_checkout = tree.branch.create_checkout('shared/checkout')
253
[('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))
259
def gather_tree_location_info(self, tree):
260
return info.gather_location_info(tree.branch.repository, tree.branch,
263
def test_gather_location_bound(self):
264
branch = self.make_branch('branch')
265
bound_branch = self.make_branch('bound_branch')
266
bound_branch.bind(branch)
268
[('branch root', bound_branch.bzrdir.root_transport.base),
269
('bound to branch', branch.bzrdir.root_transport.base)],
270
info.gather_location_info(bound_branch.repository, bound_branch)
273
def test_location_list(self):
274
if sys.platform == 'win32':
275
raise tests.TestSkipped('Windows-unfriendly test')
276
locs = info.LocationList('/home/foo')
277
locs.add_url('a', 'file:///home/foo/')
278
locs.add_url('b', 'file:///home/foo/bar/')
279
locs.add_url('c', 'file:///home/bar/bar')
280
locs.add_url('d', 'http://example.com/example/')
281
locs.add_url('e', None)
282
self.assertEqual(locs.locs, [('a', '.'),
284
('c', '/home/bar/bar'),
285
('d', 'http://example.com/example/')])
286
self.assertEqualDiff(' a: .\n b: bar\n c: /home/bar/bar\n'
287
' d: http://example.com/example/\n',
288
''.join(locs.get_lines()))
290
def test_gather_related_braches(self):
291
branch = self.make_branch('.')
292
branch.set_public_branch('baz')
293
branch.set_push_location('bar')
294
branch.set_parent('foo')
295
branch.set_submit_branch('qux')
297
[('public branch', 'baz'), ('push branch', 'bar'),
298
('parent branch', 'foo'), ('submit branch', 'qux')],
299
info._gather_related_branches(branch).locs)