/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_reconfigure.py

  • Committer: John Arbash Meinel
  • Date: 2006-04-25 15:05:42 UTC
  • mfrom: (1185.85.85 bzr-encoding)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060425150542-c7b518dca9928691
[merge] the old bzr-encoding changes, reparenting them on bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008, 2009, 2011, 2012 Canonical Ltd
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
from breezy import (
18
 
    branch as _mod_branch,
19
 
    controldir,
20
 
    errors,
21
 
    reconfigure,
22
 
    repository,
23
 
    tests,
24
 
    workingtree,
25
 
    )
26
 
from breezy.bzr import (
27
 
    branch as _mod_bzrbranch,
28
 
    vf_repository,
29
 
    )
30
 
 
31
 
 
32
 
class TestReconfigure(tests.TestCaseWithTransport):
33
 
 
34
 
    def test_tree_to_branch(self):
35
 
        tree = self.make_branch_and_tree('tree')
36
 
        reconfiguration = reconfigure.Reconfigure.to_branch(tree.controldir)
37
 
        reconfiguration.apply()
38
 
        self.assertRaises(errors.NoWorkingTree, workingtree.WorkingTree.open,
39
 
                          'tree')
40
 
 
41
 
    def test_modified_tree_to_branch(self):
42
 
        tree = self.make_branch_and_tree('tree')
43
 
        self.build_tree(['tree/file'])
44
 
        tree.add('file')
45
 
        reconfiguration = reconfigure.Reconfigure.to_branch(tree.controldir)
46
 
        self.assertRaises(errors.UncommittedChanges, reconfiguration.apply)
47
 
        reconfiguration.apply(force=True)
48
 
        self.assertRaises(errors.NoWorkingTree, workingtree.WorkingTree.open,
49
 
                          'tree')
50
 
 
51
 
    def test_tree_with_pending_merge_to_branch(self):
52
 
        tree = self.make_branch_and_tree('tree')
53
 
        tree.commit('unchanged')
54
 
        other_tree = tree.controldir.sprout('other').open_workingtree()
55
 
        other_tree.commit('mergeable commit')
56
 
        tree.merge_from_branch(other_tree.branch)
57
 
        reconfiguration = reconfigure.Reconfigure.to_branch(tree.controldir)
58
 
        self.assertRaises(errors.UncommittedChanges, reconfiguration.apply)
59
 
        reconfiguration.apply(force=True)
60
 
        self.assertRaises(errors.NoWorkingTree, workingtree.WorkingTree.open,
61
 
                          'tree')
62
 
 
63
 
    def test_branch_to_branch(self):
64
 
        branch = self.make_branch('branch')
65
 
        self.assertRaises(reconfigure.AlreadyBranch,
66
 
                          reconfigure.Reconfigure.to_branch, branch.controldir)
67
 
 
68
 
    def test_repo_to_branch(self):
69
 
        repo = self.make_repository('repo')
70
 
        reconfiguration = reconfigure.Reconfigure.to_branch(repo.controldir)
71
 
        reconfiguration.apply()
72
 
 
73
 
    def test_checkout_to_branch(self):
74
 
        branch = self.make_branch('branch')
75
 
        checkout = branch.create_checkout('checkout')
76
 
        reconfiguration = reconfigure.Reconfigure.to_branch(
77
 
            checkout.controldir)
78
 
        reconfiguration.apply()
79
 
        reconfigured = controldir.ControlDir.open('checkout').open_branch()
80
 
        self.assertIs(None, reconfigured.get_bound_location())
81
 
 
82
 
    def prepare_lightweight_checkout_to_branch(self):
83
 
        branch = self.make_branch('branch')
84
 
        checkout = branch.create_checkout('checkout', lightweight=True)
85
 
        checkout.commit('first commit', rev_id=b'rev1')
86
 
        reconfiguration = reconfigure.Reconfigure.to_branch(
87
 
            checkout.controldir)
88
 
        return reconfiguration, checkout
89
 
 
90
 
    def test_lightweight_checkout_to_branch(self):
91
 
        reconfiguration, checkout = \
92
 
            self.prepare_lightweight_checkout_to_branch()
93
 
        reconfiguration.apply()
94
 
        checkout_branch = checkout.controldir.open_branch()
95
 
        self.assertEqual(checkout_branch.controldir.root_transport.base,
96
 
                         checkout.controldir.root_transport.base)
97
 
        self.assertEqual(b'rev1', checkout_branch.last_revision())
98
 
        repo = checkout.controldir.open_repository()
99
 
        repo.get_revision(b'rev1')
100
 
 
101
 
    def test_lightweight_checkout_to_branch_tags(self):
102
 
        reconfiguration, checkout = \
103
 
            self.prepare_lightweight_checkout_to_branch()
104
 
        checkout.branch.tags.set_tag('foo', b'bar')
105
 
        reconfiguration.apply()
106
 
        checkout_branch = checkout.controldir.open_branch()
107
 
        self.assertEqual(b'bar', checkout_branch.tags.lookup_tag('foo'))
108
 
 
109
 
    def prepare_lightweight_checkout_to_checkout(self):
110
 
        branch = self.make_branch('branch')
111
 
        checkout = branch.create_checkout('checkout', lightweight=True)
112
 
        reconfiguration = reconfigure.Reconfigure.to_checkout(
113
 
            checkout.controldir)
114
 
        return reconfiguration, checkout
115
 
 
116
 
    def test_lightweight_checkout_to_checkout(self):
117
 
        reconfiguration, checkout = \
118
 
            self.prepare_lightweight_checkout_to_checkout()
119
 
        reconfiguration.apply()
120
 
        checkout_branch = checkout.controldir.open_branch()
121
 
        self.assertIsNot(checkout_branch.get_bound_location(), None)
122
 
 
123
 
    def test_lightweight_checkout_to_checkout_tags(self):
124
 
        reconfiguration, checkout = \
125
 
            self.prepare_lightweight_checkout_to_checkout()
126
 
        checkout.branch.tags.set_tag('foo', b'bar')
127
 
        reconfiguration.apply()
128
 
        checkout_branch = checkout.controldir.open_branch()
129
 
        self.assertEqual(b'bar', checkout_branch.tags.lookup_tag('foo'))
130
 
 
131
 
    def test_lightweight_conversion_uses_shared_repo(self):
132
 
        parent = self.make_branch('parent')
133
 
        shared_repo = self.make_repository('repo', shared=True)
134
 
        checkout = parent.create_checkout('repo/checkout', lightweight=True)
135
 
        reconfigure.Reconfigure.to_tree(checkout.controldir).apply()
136
 
        checkout_repo = checkout.controldir.open_branch().repository
137
 
        self.assertEqual(shared_repo.controldir.root_transport.base,
138
 
                         checkout_repo.controldir.root_transport.base)
139
 
 
140
 
    def test_branch_to_tree(self):
141
 
        branch = self.make_branch('branch')
142
 
        reconfiguration = reconfigure.Reconfigure.to_tree(branch.controldir)
143
 
        reconfiguration.apply()
144
 
        branch.controldir.open_workingtree()
145
 
 
146
 
    def test_tree_to_tree(self):
147
 
        tree = self.make_branch_and_tree('tree')
148
 
        self.assertRaises(reconfigure.AlreadyTree,
149
 
                          reconfigure.Reconfigure.to_tree, tree.controldir)
150
 
 
151
 
    def test_select_bind_location(self):
152
 
        branch = self.make_branch('branch')
153
 
        reconfiguration = reconfigure.Reconfigure(branch.controldir)
154
 
        self.assertRaises(reconfigure.NoBindLocation,
155
 
                          reconfiguration._select_bind_location)
156
 
        branch.set_parent('http://parent')
157
 
        reconfiguration = reconfigure.Reconfigure(branch.controldir)
158
 
        self.assertEqual('http://parent',
159
 
                         reconfiguration._select_bind_location())
160
 
        branch.set_push_location('sftp://push')
161
 
        reconfiguration = reconfigure.Reconfigure(branch.controldir)
162
 
        self.assertEqual('sftp://push',
163
 
                         reconfiguration._select_bind_location())
164
 
        branch.lock_write()
165
 
        try:
166
 
            branch.set_bound_location('bzr://foo/old-bound')
167
 
            branch.set_bound_location(None)
168
 
        finally:
169
 
            branch.unlock()
170
 
        reconfiguration = reconfigure.Reconfigure(branch.controldir)
171
 
        self.assertEqual('bzr://foo/old-bound',
172
 
                         reconfiguration._select_bind_location())
173
 
        branch.set_bound_location('bzr://foo/cur-bound')
174
 
        reconfiguration = reconfigure.Reconfigure(branch.controldir)
175
 
        self.assertEqual('bzr://foo/cur-bound',
176
 
                         reconfiguration._select_bind_location())
177
 
        reconfiguration.new_bound_location = 'ftp://user-specified'
178
 
        self.assertEqual('ftp://user-specified',
179
 
                         reconfiguration._select_bind_location())
180
 
 
181
 
    def test_select_reference_bind_location(self):
182
 
        branch = self.make_branch('branch')
183
 
        checkout = branch.create_checkout('checkout', lightweight=True)
184
 
        reconfiguration = reconfigure.Reconfigure(checkout.controldir)
185
 
        self.assertEqual(branch.base,
186
 
                         reconfiguration._select_bind_location())
187
 
 
188
 
    def test_tree_to_checkout(self):
189
 
        # A tree with no related branches and no supplied bind location cannot
190
 
        # become a checkout
191
 
        parent = self.make_branch('parent')
192
 
 
193
 
        tree = self.make_branch_and_tree('tree')
194
 
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree.controldir)
195
 
        self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply)
196
 
        # setting a parent allows it to become a checkout
197
 
        tree.branch.set_parent(parent.base)
198
 
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree.controldir)
199
 
        reconfiguration.apply()
200
 
        # supplying a location allows it to become a checkout
201
 
        tree2 = self.make_branch_and_tree('tree2')
202
 
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree2.controldir,
203
 
                                                              parent.base)
204
 
        reconfiguration.apply()
205
 
 
206
 
    def test_tree_to_lightweight_checkout(self):
207
 
        # A tree with no related branches and no supplied bind location cannot
208
 
        # become a checkout
209
 
        parent = self.make_branch('parent')
210
 
 
211
 
        tree = self.make_branch_and_tree('tree')
212
 
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
213
 
            tree.controldir)
214
 
        self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply)
215
 
        # setting a parent allows it to become a checkout
216
 
        tree.branch.set_parent(parent.base)
217
 
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
218
 
            tree.controldir)
219
 
        reconfiguration.apply()
220
 
        # supplying a location allows it to become a checkout
221
 
        tree2 = self.make_branch_and_tree('tree2')
222
 
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
223
 
            tree2.controldir, parent.base)
224
 
        reconfiguration.apply()
225
 
 
226
 
    def test_checkout_to_checkout(self):
227
 
        parent = self.make_branch('parent')
228
 
        checkout = parent.create_checkout('checkout')
229
 
        self.assertRaises(reconfigure.AlreadyCheckout,
230
 
                          reconfigure.Reconfigure.to_checkout, checkout.controldir)
231
 
 
232
 
    def make_unsynced_checkout(self):
233
 
        parent = self.make_branch('parent')
234
 
        checkout = parent.create_checkout('checkout')
235
 
        checkout.commit('test', rev_id=b'new-commit', local=True)
236
 
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
237
 
            checkout.controldir)
238
 
        return checkout, parent, reconfiguration
239
 
 
240
 
    def test_unsynced_checkout_to_lightweight(self):
241
 
        checkout, parent, reconfiguration = self.make_unsynced_checkout()
242
 
        self.assertRaises(reconfigure.UnsyncedBranches, reconfiguration.apply)
243
 
 
244
 
    def test_synced_checkout_to_lightweight(self):
245
 
        checkout, parent, reconfiguration = self.make_unsynced_checkout()
246
 
        parent.pull(checkout.branch)
247
 
        reconfiguration.apply()
248
 
        wt = checkout.controldir.open_workingtree()
249
 
        self.assertTrue(parent.repository.has_same_location(
250
 
            wt.branch.repository))
251
 
        parent.repository.get_revision(b'new-commit')
252
 
        self.assertRaises(errors.NoRepositoryPresent,
253
 
                          checkout.controldir.open_repository)
254
 
 
255
 
    def prepare_branch_to_lightweight_checkout(self):
256
 
        parent = self.make_branch('parent')
257
 
        child = parent.controldir.sprout('child').open_workingtree()
258
 
        child.commit('test', rev_id=b'new-commit')
259
 
        parent.pull(child.branch)
260
 
        child.controldir.destroy_workingtree()
261
 
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
262
 
            child.controldir)
263
 
        return parent, child, reconfiguration
264
 
 
265
 
    def test_branch_to_lightweight_checkout(self):
266
 
        parent, child, reconfiguration = \
267
 
            self.prepare_branch_to_lightweight_checkout()
268
 
        reconfiguration.apply()
269
 
        self.assertTrue(reconfiguration._destroy_branch)
270
 
        wt = child.controldir.open_workingtree()
271
 
        self.assertTrue(parent.repository.has_same_location(
272
 
            wt.branch.repository))
273
 
        parent.repository.get_revision(b'new-commit')
274
 
        self.assertRaises(errors.NoRepositoryPresent,
275
 
                          child.controldir.open_repository)
276
 
 
277
 
    def test_branch_to_lightweight_checkout_failure(self):
278
 
        parent, child, reconfiguration = \
279
 
            self.prepare_branch_to_lightweight_checkout()
280
 
        old_Repository_fetch = vf_repository.VersionedFileRepository.fetch
281
 
        vf_repository.VersionedFileRepository.fetch = None
282
 
        try:
283
 
            self.assertRaises(TypeError, reconfiguration.apply)
284
 
        finally:
285
 
            vf_repository.VersionedFileRepository.fetch = old_Repository_fetch
286
 
        child = _mod_branch.Branch.open('child')
287
 
        self.assertContainsRe(child.base, 'child/$')
288
 
 
289
 
    def test_branch_to_lightweight_checkout_fetch_tags(self):
290
 
        parent, child, reconfiguration = \
291
 
            self.prepare_branch_to_lightweight_checkout()
292
 
        child.branch.tags.set_tag('foo', b'bar')
293
 
        reconfiguration.apply()
294
 
        child = _mod_branch.Branch.open('child')
295
 
        self.assertEqual(b'bar', parent.tags.lookup_tag('foo'))
296
 
 
297
 
    def test_lightweight_checkout_to_lightweight_checkout(self):
298
 
        parent = self.make_branch('parent')
299
 
        checkout = parent.create_checkout('checkout', lightweight=True)
300
 
        self.assertRaises(reconfigure.AlreadyLightweightCheckout,
301
 
                          reconfigure.Reconfigure.to_lightweight_checkout,
302
 
                          checkout.controldir)
303
 
 
304
 
    def test_repo_to_tree(self):
305
 
        repo = self.make_repository('repo')
306
 
        reconfiguration = reconfigure.Reconfigure.to_tree(repo.controldir)
307
 
        reconfiguration.apply()
308
 
        workingtree.WorkingTree.open('repo')
309
 
 
310
 
    def test_shared_repo_to_lightweight_checkout(self):
311
 
        repo = self.make_repository('repo', shared=True)
312
 
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
313
 
            repo.controldir)
314
 
        self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply)
315
 
        self.make_branch('branch')
316
 
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
317
 
            repo.controldir, 'branch')
318
 
        reconfiguration.apply()
319
 
        workingtree.WorkingTree.open('repo')
320
 
        repository.Repository.open('repo')
321
 
 
322
 
    def test_unshared_repo_to_lightweight_checkout(self):
323
 
        repo = self.make_repository('repo', shared=False)
324
 
        self.make_branch('branch')
325
 
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
326
 
            repo.controldir, 'branch')
327
 
        reconfiguration.apply()
328
 
        workingtree.WorkingTree.open('repo')
329
 
        self.assertRaises(errors.NoRepositoryPresent,
330
 
                          repository.Repository.open, 'repo')
331
 
 
332
 
    def test_standalone_to_use_shared(self):
333
 
        self.build_tree(['root/'])
334
 
        tree = self.make_branch_and_tree('root/tree')
335
 
        tree.commit('Hello', rev_id=b'hello-id')
336
 
        repo = self.make_repository('root', shared=True)
337
 
        reconfiguration = reconfigure.Reconfigure.to_use_shared(
338
 
            tree.controldir)
339
 
        reconfiguration.apply()
340
 
        tree = workingtree.WorkingTree.open('root/tree')
341
 
        self.assertTrue(repo.has_same_location(tree.branch.repository))
342
 
        self.assertEqual('Hello', repo.get_revision(b'hello-id').message)
343
 
 
344
 
    def add_dead_head(self, tree):
345
 
        revno, revision_id = tree.branch.last_revision_info()
346
 
        tree.commit('Dead head', rev_id=b'dead-head-id')
347
 
        tree.branch.set_last_revision_info(revno, revision_id)
348
 
        tree.set_last_revision(revision_id)
349
 
 
350
 
    def test_standalone_to_use_shared_preserves_dead_heads(self):
351
 
        self.build_tree(['root/'])
352
 
        tree = self.make_branch_and_tree('root/tree')
353
 
        self.add_dead_head(tree)
354
 
        tree.commit('Hello', rev_id=b'hello-id')
355
 
        repo = self.make_repository('root', shared=True)
356
 
        reconfiguration = reconfigure.Reconfigure.to_use_shared(
357
 
            tree.controldir)
358
 
        reconfiguration.apply()
359
 
        tree = workingtree.WorkingTree.open('root/tree')
360
 
        message = repo.get_revision(b'dead-head-id').message
361
 
        self.assertEqual('Dead head', message)
362
 
 
363
 
    def make_repository_tree(self):
364
 
        self.build_tree(['root/'])
365
 
        self.make_repository('root', shared=True)
366
 
        tree = self.make_branch_and_tree('root/tree')
367
 
        reconfigure.Reconfigure.to_use_shared(tree.controldir).apply()
368
 
        return workingtree.WorkingTree.open('root/tree')
369
 
 
370
 
    def test_use_shared_to_use_shared(self):
371
 
        tree = self.make_repository_tree()
372
 
        self.assertRaises(reconfigure.AlreadyUsingShared,
373
 
                          reconfigure.Reconfigure.to_use_shared, tree.controldir)
374
 
 
375
 
    def test_use_shared_to_standalone(self):
376
 
        tree = self.make_repository_tree()
377
 
        tree.commit('Hello', rev_id=b'hello-id')
378
 
        reconfigure.Reconfigure.to_standalone(tree.controldir).apply()
379
 
        tree = workingtree.WorkingTree.open('root/tree')
380
 
        repo = tree.branch.repository
381
 
        self.assertEqual(repo.controldir.root_transport.base,
382
 
                         tree.controldir.root_transport.base)
383
 
        self.assertEqual('Hello', repo.get_revision(b'hello-id').message)
384
 
 
385
 
    def test_use_shared_to_standalone_preserves_dead_heads(self):
386
 
        tree = self.make_repository_tree()
387
 
        self.add_dead_head(tree)
388
 
        tree.commit('Hello', rev_id=b'hello-id')
389
 
        reconfigure.Reconfigure.to_standalone(tree.controldir).apply()
390
 
        tree = workingtree.WorkingTree.open('root/tree')
391
 
        repo = tree.branch.repository
392
 
        self.assertRaises(errors.NoSuchRevision, repo.get_revision,
393
 
                          b'dead-head-id')
394
 
 
395
 
    def test_standalone_to_standalone(self):
396
 
        tree = self.make_branch_and_tree('tree')
397
 
        self.assertRaises(reconfigure.AlreadyStandalone,
398
 
                          reconfigure.Reconfigure.to_standalone, tree.controldir)
399
 
 
400
 
    def make_unsynced_branch_reconfiguration(self):
401
 
        parent = self.make_branch_and_tree('parent')
402
 
        parent.commit('commit 1')
403
 
        child = parent.controldir.sprout('child').open_workingtree()
404
 
        child.commit('commit 2')
405
 
        return reconfigure.Reconfigure.to_lightweight_checkout(child.controldir)
406
 
 
407
 
    def test_unsynced_branch_to_lightweight_checkout_unforced(self):
408
 
        reconfiguration = self.make_unsynced_branch_reconfiguration()
409
 
        self.assertRaises(reconfigure.UnsyncedBranches, reconfiguration.apply)
410
 
 
411
 
    def test_unsynced_branch_to_lightweight_checkout_forced(self):
412
 
        reconfiguration = self.make_unsynced_branch_reconfiguration()
413
 
        reconfiguration.apply(force=True)
414
 
 
415
 
    def make_repository_with_without_trees(self, with_trees):
416
 
        repo = self.make_repository('repo', shared=True)
417
 
        repo.set_make_working_trees(with_trees)
418
 
        return repo
419
 
 
420
 
    def test_make_with_trees(self):
421
 
        repo = self.make_repository_with_without_trees(False)
422
 
        reconfiguration = reconfigure.Reconfigure.set_repository_trees(
423
 
            repo.controldir, True)
424
 
        reconfiguration.apply()
425
 
        self.assertIs(True, repo.make_working_trees())
426
 
 
427
 
    def test_make_without_trees(self):
428
 
        repo = self.make_repository_with_without_trees(True)
429
 
        reconfiguration = reconfigure.Reconfigure.set_repository_trees(
430
 
            repo.controldir, False)
431
 
        reconfiguration.apply()
432
 
        self.assertIs(False, repo.make_working_trees())
433
 
 
434
 
    def test_make_with_trees_already_with_trees(self):
435
 
        repo = self.make_repository_with_without_trees(True)
436
 
        e = self.assertRaises(reconfigure.AlreadyWithTrees,
437
 
                              reconfigure.Reconfigure.set_repository_trees, repo.controldir, True)
438
 
        self.assertContainsRe(str(e),
439
 
                              r"Shared repository '.*' already creates working trees.")
440
 
 
441
 
    def test_make_without_trees_already_no_trees(self):
442
 
        repo = self.make_repository_with_without_trees(False)
443
 
        e = self.assertRaises(
444
 
            reconfigure.AlreadyWithNoTrees,
445
 
            reconfigure.Reconfigure.set_repository_trees, repo.controldir,
446
 
            False)
447
 
        self.assertContainsRe(
448
 
            str(e),
449
 
            r"Shared repository '.*' already doesn't create working trees.")
450
 
 
451
 
    def test_repository_tree_reconfiguration_not_supported(self):
452
 
        tree = self.make_branch_and_tree('tree')
453
 
        e = self.assertRaises(
454
 
            reconfigure.ReconfigurationNotSupported,
455
 
            reconfigure.Reconfigure.set_repository_trees, tree.controldir,
456
 
            None)
457
 
        self.assertContainsRe(
458
 
            str(e), r"Requested reconfiguration of '.*' is not supported.")
459
 
 
460
 
    def test_lightweight_checkout_to_tree_preserves_reference_locations(self):
461
 
        format = controldir.format_registry.make_controldir('1.9')
462
 
        format.set_branch_format(_mod_bzrbranch.BzrBranchFormat8())
463
 
        tree = self.make_branch_and_tree('tree', format=format)
464
 
        tree.branch.set_reference_info(b'file_id', '../location', 'path')
465
 
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
466
 
        reconfiguration = reconfigure.Reconfigure.to_tree(checkout.controldir)
467
 
        reconfiguration.apply()
468
 
        checkout_branch = checkout.controldir.open_branch()
469
 
        self.assertEqual(('../location', 'path'),
470
 
                         checkout_branch.get_reference_info(b'file_id'))