91
90
# this ought to be easier...
92
91
branch.create_checkout('%s_co' % format,
93
92
lightweight=True).bzrdir.destroy_workingtree()
94
control = bzrdir.BzrDir.open('%s_co' % format)
93
control = controldir.ControlDir.open('%s_co' % format)
95
94
old_format = control._format.workingtree_format
97
96
control._format.workingtree_format = \
98
bzrdir.format_registry.make_bzrdir(format).workingtree_format
97
controldir.format_registry.make_bzrdir(format).workingtree_format
99
98
control.create_workingtree()
100
99
tree = workingtree.WorkingTree.open('%s_co' % format)
101
100
format_description = info.describe_format(tree.bzrdir,
125
124
repo, None, None))
127
126
def test_describe_tree_format(self):
128
for key in bzrdir.format_registry.keys():
129
if key in bzrdir.format_registry.aliases():
127
for key in controldir.format_registry.keys():
128
if key in controldir.format_registry.aliases():
131
130
self.assertTreeDescription(key)
133
132
def test_describe_checkout_format(self):
134
for key in bzrdir.format_registry.keys():
135
if key in bzrdir.format_registry.aliases():
133
for key in controldir.format_registry.keys():
134
if key in controldir.format_registry.aliases():
136
135
# Aliases will not describe correctly in the UI because the
137
136
# real format is found.
139
138
# legacy: weave does not support checkouts
140
139
if key == 'weave':
142
if bzrdir.format_registry.get_info(key).experimental:
141
if controldir.format_registry.get_info(key).experimental:
143
142
# We don't require that experimental formats support checkouts
144
143
# or describe correctly in the UI.
146
if bzrdir.format_registry.get_info(key).hidden:
145
if controldir.format_registry.get_info(key).hidden:
149
148
if key in ('pack-0.92',):
150
149
expected = 'pack-0.92'
151
150
elif key in ('knit', 'metaweave'):
152
expected = 'knit or metaweave'
151
if 'metaweave' in controldir.format_registry:
152
expected = 'knit or metaweave'
153
155
elif key in ('1.14', '1.14-rich-root'):
154
156
expected = '1.14 or 1.14-rich-root'
155
157
self.assertCheckoutDescription(key, expected)
157
159
def test_describe_branch_format(self):
158
for key in bzrdir.format_registry.keys():
159
if key in bzrdir.format_registry.aliases():
160
for key in controldir.format_registry.keys():
161
if key in controldir.format_registry.aliases():
161
if bzrdir.format_registry.get_info(key).hidden:
163
if controldir.format_registry.get_info(key).hidden:
164
166
if key in ('dirstate', 'knit'):
184
186
expected = '1.14-rich-root'
185
187
self.assertRepoDescription(key, expected)
187
format = bzrdir.format_registry.make_bzrdir('metaweave')
189
format = controldir.format_registry.make_bzrdir('knit')
188
190
format.set_branch_format(_mod_branch.BzrBranchFormat6())
189
191
tree = self.make_branch_and_tree('unknown', format=format)
190
192
self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
191
193
tree.branch.repository, tree.branch, tree))
195
def test_gather_location_controldir_only(self):
196
bzrdir = self.make_bzrdir('.')
197
self.assertEqual([('control directory', bzrdir.user_url)],
198
info.gather_location_info(control=bzrdir))
193
200
def test_gather_location_standalone(self):
194
201
tree = self.make_branch_and_tree('tree')
195
202
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
196
info.gather_location_info(tree.branch.repository, tree.branch,
203
info.gather_location_info(
204
tree.branch.repository, tree.branch, tree, control=tree.bzrdir))
198
205
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
199
info.gather_location_info(tree.branch.repository, tree.branch))
206
info.gather_location_info(
207
tree.branch.repository, tree.branch, control=tree.bzrdir))
202
210
def test_gather_location_repo(self):
203
211
srepo = self.make_repository('shared', shared=True)
204
self.assertEqual([('shared repository',
205
srepo.bzrdir.root_transport.base)],
206
info.gather_location_info(srepo))
213
[('shared repository', srepo.bzrdir.root_transport.base)],
214
info.gather_location_info(srepo, control=srepo.bzrdir))
207
215
urepo = self.make_repository('unshared')
208
self.assertEqual([('repository',
209
urepo.bzrdir.root_transport.base)],
210
info.gather_location_info(urepo))
217
[('repository', urepo.bzrdir.root_transport.base)],
218
info.gather_location_info(urepo, control=urepo.bzrdir))
212
220
def test_gather_location_repo_branch(self):
213
221
srepo = self.make_repository('shared', shared=True)
214
self.assertEqual([('shared repository',
215
srepo.bzrdir.root_transport.base)],
216
info.gather_location_info(srepo))
223
[('shared repository', srepo.bzrdir.root_transport.base)],
224
info.gather_location_info(srepo, control=srepo.bzrdir))
217
225
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))
227
[('shared repository', srepo.bzrdir.root_transport.base),
228
('repository branch', tree.branch.base)],
229
info.gather_location_info(srepo, tree.branch, tree, srepo.bzrdir))
223
231
def test_gather_location_light_checkout(self):
224
232
tree = self.make_branch_and_tree('tree')
267
275
self.assertEqual(
268
276
[('branch root', bound_branch.bzrdir.root_transport.base),
269
277
('bound to branch', branch.bzrdir.root_transport.base)],
278
info.gather_location_info(
279
bound_branch.repository, bound_branch, control=bound_branch.bzrdir)
282
def test_gather_location_bound_in_repository(self):
283
repo = self.make_repository('repo', shared=True)
284
repo.set_make_working_trees(False)
285
branch = self.make_branch('branch')
286
bound_branch = controldir.ControlDir.create_branch_convenience(
288
bound_branch.bind(branch)
290
[('shared repository', bound_branch.repository.bzrdir.user_url),
291
('repository branch', bound_branch.bzrdir.user_url),
292
('bound to branch', branch.bzrdir.user_url)],
270
293
info.gather_location_info(bound_branch.repository, bound_branch)