30
31
def test_describe_standalone_layout(self):
31
32
tree = self.make_branch_and_tree('tree')
32
33
self.assertEqual('Empty control directory', info.describe_layout())
33
self.assertEqual('Unshared repository with trees',
34
info.describe_layout(tree.branch.repository))
35
'Unshared repository with trees and colocated branches',
36
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
35
37
tree.branch.repository.set_make_working_trees(False)
36
self.assertEqual('Unshared repository',
37
info.describe_layout(tree.branch.repository))
38
self.assertEqual('Unshared repository with colocated branches',
39
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
38
40
self.assertEqual('Standalone branch',
39
info.describe_layout(tree.branch.repository, tree.branch))
41
info.describe_layout(tree.branch.repository, tree.branch,
40
43
self.assertEqual('Standalone branchless tree',
41
info.describe_layout(tree.branch.repository, None, tree))
44
info.describe_layout(tree.branch.repository, None, tree,
42
46
self.assertEqual('Standalone tree',
43
info.describe_layout(tree.branch.repository, tree.branch, tree))
47
info.describe_layout(tree.branch.repository, tree.branch, tree,
44
49
tree.branch.bind(tree.branch)
45
50
self.assertEqual('Bound branch',
46
info.describe_layout(tree.branch.repository, tree.branch))
51
info.describe_layout(tree.branch.repository, tree.branch,
47
53
self.assertEqual('Checkout',
48
info.describe_layout(tree.branch.repository, tree.branch, tree))
54
info.describe_layout(tree.branch.repository, tree.branch, tree,
49
56
checkout = tree.branch.create_checkout('checkout', lightweight=True)
50
57
self.assertEqual('Lightweight checkout',
51
58
info.describe_layout(checkout.branch.repository, checkout.branch,
59
checkout, control=tree.bzrdir))
54
61
def test_describe_repository_layout(self):
55
62
repository = self.make_repository('.', shared=True)
56
tree = bzrdir.BzrDir.create_branch_convenience('tree',
63
tree = controldir.ControlDir.create_branch_convenience('tree',
57
64
force_new_tree=True).bzrdir.open_workingtree()
58
self.assertEqual('Shared repository with trees',
59
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))
60
67
repository.set_make_working_trees(False)
61
self.assertEqual('Shared repository',
62
info.describe_layout(tree.branch.repository))
68
self.assertEqual('Shared repository with colocated branches',
69
info.describe_layout(tree.branch.repository, control=tree.bzrdir))
63
70
self.assertEqual('Repository branch',
64
info.describe_layout(tree.branch.repository, tree.branch))
71
info.describe_layout(tree.branch.repository, tree.branch,
65
73
self.assertEqual('Repository branchless tree',
66
info.describe_layout(tree.branch.repository, None, tree))
74
info.describe_layout(tree.branch.repository, None, tree,
67
76
self.assertEqual('Repository tree',
68
info.describe_layout(tree.branch.repository, tree.branch, tree))
77
info.describe_layout(tree.branch.repository, tree.branch, tree,
69
79
tree.branch.bind(tree.branch)
70
80
self.assertEqual('Repository checkout',
71
info.describe_layout(tree.branch.repository, tree.branch, tree))
81
info.describe_layout(tree.branch.repository, tree.branch, tree,
72
83
checkout = tree.branch.create_checkout('checkout', lightweight=True)
73
84
self.assertEqual('Lightweight checkout',
74
85
info.describe_layout(checkout.branch.repository, checkout.branch,
86
checkout, control=tree.bzrdir))
77
88
def assertTreeDescription(self, format):
78
89
"""Assert a tree's format description matches expectations"""
89
100
# this ought to be easier...
90
101
branch.create_checkout('%s_co' % format,
91
102
lightweight=True).bzrdir.destroy_workingtree()
92
control = bzrdir.BzrDir.open('%s_co' % format)
103
control = controldir.ControlDir.open('%s_co' % format)
93
104
old_format = control._format.workingtree_format
95
106
control._format.workingtree_format = \
96
bzrdir.format_registry.make_bzrdir(format).workingtree_format
107
controldir.format_registry.make_bzrdir(format).workingtree_format
97
108
control.create_workingtree()
98
109
tree = workingtree.WorkingTree.open('%s_co' % format)
99
self.assertEqual(expected, info.describe_format(tree.bzrdir,
100
tree.branch.repository, tree.branch, tree))
110
format_description = info.describe_format(tree.bzrdir,
111
tree.branch.repository, tree.branch, tree)
112
self.assertEqual(expected, format_description,
113
"checkout of format called %r was described as %r" %
114
(expected, format_description))
102
116
control._format.workingtree_format = old_format
120
134
repo, None, None))
122
136
def test_describe_tree_format(self):
123
for key in bzrdir.format_registry.keys():
137
for key in controldir.format_registry.keys():
138
if key in controldir.format_registry.aliases():
126
140
self.assertTreeDescription(key)
128
142
def test_describe_checkout_format(self):
129
for key in bzrdir.format_registry.keys():
130
if key in ('default', 'weave'):
143
for key in controldir.format_registry.keys():
144
if key in controldir.format_registry.aliases():
145
# Aliases will not describe correctly in the UI because the
146
# real format is found.
148
# legacy: weave does not support checkouts
151
if controldir.format_registry.get_info(key).experimental:
152
# We don't require that experimental formats support checkouts
153
# or describe correctly in the UI.
155
if controldir.format_registry.get_info(key).hidden:
133
if key in ('dirstate', 'dirstate-tags', 'dirstate-with-subtree'):
134
expected = 'dirstate or dirstate-tags'
135
if key in ('knit', 'metaweave'):
136
expected = 'knit or metaweave'
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'
137
167
self.assertCheckoutDescription(key, expected)
139
169
def test_describe_branch_format(self):
140
for key in bzrdir.format_registry.keys():
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:
144
176
if key in ('dirstate', 'knit'):
145
177
expected = 'dirstate or knit'
178
elif key in ('1.14',):
180
elif key in ('1.14-rich-root',):
181
expected = '1.14-rich-root'
146
182
self.assertBranchDescription(key, expected)
148
184
def test_describe_repo_format(self):
149
for key in bzrdir.format_registry.keys():
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:
153
191
if key in ('dirstate', 'knit', 'dirstate-tags'):
154
192
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'
155
197
self.assertRepoDescription(key, expected)
157
format = bzrdir.format_registry.make_bzrdir('metaweave')
199
format = controldir.format_registry.make_bzrdir('knit')
158
200
format.set_branch_format(_mod_branch.BzrBranchFormat6())
159
201
tree = self.make_branch_and_tree('unknown', format=format)
160
202
self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
161
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))
163
210
def test_gather_location_standalone(self):
164
211
tree = self.make_branch_and_tree('tree')
165
212
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
166
info.gather_location_info(tree.branch.repository, tree.branch,
213
info.gather_location_info(
214
tree.branch.repository, tree.branch, tree, control=tree.bzrdir))
168
215
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
169
info.gather_location_info(tree.branch.repository, tree.branch))
216
info.gather_location_info(
217
tree.branch.repository, tree.branch, control=tree.bzrdir))
172
220
def test_gather_location_repo(self):
173
221
srepo = self.make_repository('shared', shared=True)
174
self.assertEqual([('shared repository',
175
srepo.bzrdir.root_transport.base)],
176
info.gather_location_info(srepo))
223
[('shared repository', srepo.bzrdir.root_transport.base)],
224
info.gather_location_info(srepo, control=srepo.bzrdir))
177
225
urepo = self.make_repository('unshared')
178
self.assertEqual([('repository',
179
urepo.bzrdir.root_transport.base)],
180
info.gather_location_info(urepo))
227
[('repository', urepo.bzrdir.root_transport.base)],
228
info.gather_location_info(urepo, control=urepo.bzrdir))
182
230
def test_gather_location_repo_branch(self):
183
231
srepo = self.make_repository('shared', shared=True)
184
self.assertEqual([('shared repository',
185
srepo.bzrdir.root_transport.base)],
186
info.gather_location_info(srepo))
233
[('shared repository', srepo.bzrdir.root_transport.base)],
234
info.gather_location_info(srepo, control=srepo.bzrdir))
187
235
tree = self.make_branch_and_tree('shared/tree')
188
self.assertEqual([('shared repository',
189
srepo.bzrdir.root_transport.base),
190
('repository branch', 'tree')],
191
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))
193
241
def test_gather_location_light_checkout(self):
194
242
tree = self.make_branch_and_tree('tree')
237
285
self.assertEqual(
238
286
[('branch root', bound_branch.bzrdir.root_transport.base),
239
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)],
240
303
info.gather_location_info(bound_branch.repository, bound_branch)
306
def test_location_list(self):
307
if sys.platform == 'win32':
308
raise tests.TestSkipped('Windows-unfriendly test')
309
locs = info.LocationList('/home/foo')
310
locs.add_url('a', 'file:///home/foo/')
311
locs.add_url('b', 'file:///home/foo/bar/')
312
locs.add_url('c', 'file:///home/bar/bar')
313
locs.add_url('d', 'http://example.com/example/')
314
locs.add_url('e', None)
315
self.assertEqual(locs.locs, [('a', '.'),
317
('c', '/home/bar/bar'),
318
('d', 'http://example.com/example/')])
319
self.assertEqualDiff(' a: .\n b: bar\n c: /home/bar/bar\n'
320
' d: http://example.com/example/\n',
321
''.join(locs.get_lines()))
323
def test_gather_related_braches(self):
324
branch = self.make_branch('.')
327
branch.set_public_branch('baz')
328
branch.set_push_location('bar')
329
branch.set_parent('foo')
330
branch.set_submit_branch('qux')
334
[('public branch', 'baz'), ('push branch', 'bar'),
335
('parent branch', 'foo'), ('submit branch', 'qux')],
336
info._gather_related_branches(branch).locs)