/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: Jelmer Vernooij
  • Date: 2018-05-19 13:16:11 UTC
  • mto: (6968.4.3 git-archive)
  • mto: This revision was merged to the branch mainline in revision 6972.
  • Revision ID: jelmer@jelmer.uk-20180519131611-l9h9ud41j7qg1m03
Move tar/zip to breezy.archive.

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(checkout.controldir)
 
77
        reconfiguration.apply()
 
78
        reconfigured = controldir.ControlDir.open('checkout').open_branch()
 
79
        self.assertIs(None, reconfigured.get_bound_location())
 
80
 
 
81
    def prepare_lightweight_checkout_to_branch(self):
 
82
        branch = self.make_branch('branch')
 
83
        checkout = branch.create_checkout('checkout', lightweight=True)
 
84
        checkout.commit('first commit', rev_id=b'rev1')
 
85
        reconfiguration = reconfigure.Reconfigure.to_branch(checkout.controldir)
 
86
        return reconfiguration, checkout
 
87
 
 
88
    def test_lightweight_checkout_to_branch(self):
 
89
        reconfiguration, checkout = \
 
90
            self.prepare_lightweight_checkout_to_branch()
 
91
        reconfiguration.apply()
 
92
        checkout_branch = checkout.controldir.open_branch()
 
93
        self.assertEqual(checkout_branch.controldir.root_transport.base,
 
94
                         checkout.controldir.root_transport.base)
 
95
        self.assertEqual('rev1', checkout_branch.last_revision())
 
96
        repo = checkout.controldir.open_repository()
 
97
        repo.get_revision('rev1')
 
98
 
 
99
    def test_lightweight_checkout_to_branch_tags(self):
 
100
        reconfiguration, checkout = \
 
101
            self.prepare_lightweight_checkout_to_branch()
 
102
        checkout.branch.tags.set_tag('foo', 'bar')
 
103
        reconfiguration.apply()
 
104
        checkout_branch = checkout.controldir.open_branch()
 
105
        self.assertEqual('bar', checkout_branch.tags.lookup_tag('foo'))
 
106
 
 
107
    def prepare_lightweight_checkout_to_checkout(self):
 
108
        branch = self.make_branch('branch')
 
109
        checkout = branch.create_checkout('checkout', lightweight=True)
 
110
        reconfiguration = reconfigure.Reconfigure.to_checkout(checkout.controldir)
 
111
        return reconfiguration, checkout
 
112
 
 
113
    def test_lightweight_checkout_to_checkout(self):
 
114
        reconfiguration, checkout = \
 
115
            self.prepare_lightweight_checkout_to_checkout()
 
116
        reconfiguration.apply()
 
117
        checkout_branch = checkout.controldir.open_branch()
 
118
        self.assertIsNot(checkout_branch.get_bound_location(), None)
 
119
 
 
120
    def test_lightweight_checkout_to_checkout_tags(self):
 
121
        reconfiguration, checkout = \
 
122
            self.prepare_lightweight_checkout_to_checkout()
 
123
        checkout.branch.tags.set_tag('foo', 'bar')
 
124
        reconfiguration.apply()
 
125
        checkout_branch = checkout.controldir.open_branch()
 
126
        self.assertEqual('bar', checkout_branch.tags.lookup_tag('foo'))
 
127
 
 
128
    def test_lightweight_conversion_uses_shared_repo(self):
 
129
        parent = self.make_branch('parent')
 
130
        shared_repo = self.make_repository('repo', shared=True)
 
131
        checkout = parent.create_checkout('repo/checkout', lightweight=True)
 
132
        reconfigure.Reconfigure.to_tree(checkout.controldir).apply()
 
133
        checkout_repo = checkout.controldir.open_branch().repository
 
134
        self.assertEqual(shared_repo.controldir.root_transport.base,
 
135
                         checkout_repo.controldir.root_transport.base)
 
136
 
 
137
    def test_branch_to_tree(self):
 
138
        branch = self.make_branch('branch')
 
139
        reconfiguration=reconfigure.Reconfigure.to_tree(branch.controldir)
 
140
        reconfiguration.apply()
 
141
        branch.controldir.open_workingtree()
 
142
 
 
143
    def test_tree_to_tree(self):
 
144
        tree = self.make_branch_and_tree('tree')
 
145
        self.assertRaises(reconfigure.AlreadyTree,
 
146
                          reconfigure.Reconfigure.to_tree, tree.controldir)
 
147
 
 
148
    def test_select_bind_location(self):
 
149
        branch = self.make_branch('branch')
 
150
        reconfiguration = reconfigure.Reconfigure(branch.controldir)
 
151
        self.assertRaises(reconfigure.NoBindLocation,
 
152
                          reconfiguration._select_bind_location)
 
153
        branch.set_parent('http://parent')
 
154
        reconfiguration = reconfigure.Reconfigure(branch.controldir)
 
155
        self.assertEqual('http://parent',
 
156
                         reconfiguration._select_bind_location())
 
157
        branch.set_push_location('sftp://push')
 
158
        reconfiguration = reconfigure.Reconfigure(branch.controldir)
 
159
        self.assertEqual('sftp://push',
 
160
                         reconfiguration._select_bind_location())
 
161
        branch.lock_write()
 
162
        try:
 
163
            branch.set_bound_location('bzr://foo/old-bound')
 
164
            branch.set_bound_location(None)
 
165
        finally:
 
166
            branch.unlock()
 
167
        reconfiguration = reconfigure.Reconfigure(branch.controldir)
 
168
        self.assertEqual('bzr://foo/old-bound',
 
169
                         reconfiguration._select_bind_location())
 
170
        branch.set_bound_location('bzr://foo/cur-bound')
 
171
        reconfiguration = reconfigure.Reconfigure(branch.controldir)
 
172
        self.assertEqual('bzr://foo/cur-bound',
 
173
                         reconfiguration._select_bind_location())
 
174
        reconfiguration.new_bound_location = 'ftp://user-specified'
 
175
        self.assertEqual('ftp://user-specified',
 
176
                         reconfiguration._select_bind_location())
 
177
 
 
178
    def test_select_reference_bind_location(self):
 
179
        branch = self.make_branch('branch')
 
180
        checkout = branch.create_checkout('checkout', lightweight=True)
 
181
        reconfiguration = reconfigure.Reconfigure(checkout.controldir)
 
182
        self.assertEqual(branch.base,
 
183
                         reconfiguration._select_bind_location())
 
184
 
 
185
    def test_tree_to_checkout(self):
 
186
        # A tree with no related branches and no supplied bind location cannot
 
187
        # become a checkout
 
188
        parent = self.make_branch('parent')
 
189
 
 
190
        tree = self.make_branch_and_tree('tree')
 
191
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree.controldir)
 
192
        self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply)
 
193
        # setting a parent allows it to become a checkout
 
194
        tree.branch.set_parent(parent.base)
 
195
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree.controldir)
 
196
        reconfiguration.apply()
 
197
        # supplying a location allows it to become a checkout
 
198
        tree2 = self.make_branch_and_tree('tree2')
 
199
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree2.controldir,
 
200
                                                              parent.base)
 
201
        reconfiguration.apply()
 
202
 
 
203
    def test_tree_to_lightweight_checkout(self):
 
204
        # A tree with no related branches and no supplied bind location cannot
 
205
        # become a checkout
 
206
        parent = self.make_branch('parent')
 
207
 
 
208
        tree = self.make_branch_and_tree('tree')
 
209
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
210
            tree.controldir)
 
211
        self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply)
 
212
        # setting a parent allows it to become a checkout
 
213
        tree.branch.set_parent(parent.base)
 
214
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
215
            tree.controldir)
 
216
        reconfiguration.apply()
 
217
        # supplying a location allows it to become a checkout
 
218
        tree2 = self.make_branch_and_tree('tree2')
 
219
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
220
            tree2.controldir, parent.base)
 
221
        reconfiguration.apply()
 
222
 
 
223
    def test_checkout_to_checkout(self):
 
224
        parent = self.make_branch('parent')
 
225
        checkout = parent.create_checkout('checkout')
 
226
        self.assertRaises(reconfigure.AlreadyCheckout,
 
227
                          reconfigure.Reconfigure.to_checkout, checkout.controldir)
 
228
 
 
229
    def make_unsynced_checkout(self):
 
230
        parent = self.make_branch('parent')
 
231
        checkout = parent.create_checkout('checkout')
 
232
        checkout.commit('test', rev_id=b'new-commit', local=True)
 
233
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
234
            checkout.controldir)
 
235
        return checkout, parent, reconfiguration
 
236
 
 
237
    def test_unsynced_checkout_to_lightweight(self):
 
238
        checkout, parent, reconfiguration = self.make_unsynced_checkout()
 
239
        self.assertRaises(reconfigure.UnsyncedBranches, reconfiguration.apply)
 
240
 
 
241
    def test_synced_checkout_to_lightweight(self):
 
242
        checkout, parent, reconfiguration = self.make_unsynced_checkout()
 
243
        parent.pull(checkout.branch)
 
244
        reconfiguration.apply()
 
245
        wt = checkout.controldir.open_workingtree()
 
246
        self.assertTrue(parent.repository.has_same_location(
 
247
            wt.branch.repository))
 
248
        parent.repository.get_revision('new-commit')
 
249
        self.assertRaises(errors.NoRepositoryPresent,
 
250
                          checkout.controldir.open_repository)
 
251
 
 
252
    def prepare_branch_to_lightweight_checkout(self):
 
253
        parent = self.make_branch('parent')
 
254
        child = parent.controldir.sprout('child').open_workingtree()
 
255
        child.commit('test', rev_id=b'new-commit')
 
256
        parent.pull(child.branch)
 
257
        child.controldir.destroy_workingtree()
 
258
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
259
            child.controldir)
 
260
        return parent, child, reconfiguration
 
261
 
 
262
    def test_branch_to_lightweight_checkout(self):
 
263
        parent, child, reconfiguration = \
 
264
            self.prepare_branch_to_lightweight_checkout()
 
265
        reconfiguration.apply()
 
266
        self.assertTrue(reconfiguration._destroy_branch)
 
267
        wt = child.controldir.open_workingtree()
 
268
        self.assertTrue(parent.repository.has_same_location(
 
269
            wt.branch.repository))
 
270
        parent.repository.get_revision('new-commit')
 
271
        self.assertRaises(errors.NoRepositoryPresent,
 
272
                          child.controldir.open_repository)
 
273
 
 
274
    def test_branch_to_lightweight_checkout_failure(self):
 
275
        parent, child, reconfiguration = \
 
276
            self.prepare_branch_to_lightweight_checkout()
 
277
        old_Repository_fetch = vf_repository.VersionedFileRepository.fetch
 
278
        vf_repository.VersionedFileRepository.fetch = None
 
279
        try:
 
280
            self.assertRaises(TypeError, reconfiguration.apply)
 
281
        finally:
 
282
            vf_repository.VersionedFileRepository.fetch = old_Repository_fetch
 
283
        child = _mod_branch.Branch.open('child')
 
284
        self.assertContainsRe(child.base, 'child/$')
 
285
 
 
286
    def test_branch_to_lightweight_checkout_fetch_tags(self):
 
287
        parent, child, reconfiguration = \
 
288
            self.prepare_branch_to_lightweight_checkout()
 
289
        child.branch.tags.set_tag('foo', 'bar')
 
290
        reconfiguration.apply()
 
291
        child = _mod_branch.Branch.open('child')
 
292
        self.assertEqual('bar', parent.tags.lookup_tag('foo'))
 
293
 
 
294
    def test_lightweight_checkout_to_lightweight_checkout(self):
 
295
        parent = self.make_branch('parent')
 
296
        checkout = parent.create_checkout('checkout', lightweight=True)
 
297
        self.assertRaises(reconfigure.AlreadyLightweightCheckout,
 
298
                          reconfigure.Reconfigure.to_lightweight_checkout,
 
299
                          checkout.controldir)
 
300
 
 
301
    def test_repo_to_tree(self):
 
302
        repo = self.make_repository('repo')
 
303
        reconfiguration = reconfigure.Reconfigure.to_tree(repo.controldir)
 
304
        reconfiguration.apply()
 
305
        workingtree.WorkingTree.open('repo')
 
306
 
 
307
    def test_shared_repo_to_lightweight_checkout(self):
 
308
        repo = self.make_repository('repo', shared=True)
 
309
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
310
            repo.controldir)
 
311
        self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply)
 
312
        branch = self.make_branch('branch')
 
313
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
314
            repo.controldir, 'branch')
 
315
        reconfiguration.apply()
 
316
        workingtree.WorkingTree.open('repo')
 
317
        repository.Repository.open('repo')
 
318
 
 
319
    def test_unshared_repo_to_lightweight_checkout(self):
 
320
        repo = self.make_repository('repo', shared=False)
 
321
        branch = self.make_branch('branch')
 
322
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
323
            repo.controldir, 'branch')
 
324
        reconfiguration.apply()
 
325
        workingtree.WorkingTree.open('repo')
 
326
        self.assertRaises(errors.NoRepositoryPresent,
 
327
                          repository.Repository.open, 'repo')
 
328
 
 
329
    def test_standalone_to_use_shared(self):
 
330
        self.build_tree(['root/'])
 
331
        tree = self.make_branch_and_tree('root/tree')
 
332
        tree.commit('Hello', rev_id=b'hello-id')
 
333
        repo = self.make_repository('root', shared=True)
 
334
        reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.controldir)
 
335
        reconfiguration.apply()
 
336
        tree = workingtree.WorkingTree.open('root/tree')
 
337
        self.assertTrue(repo.has_same_location(tree.branch.repository))
 
338
        self.assertEqual('Hello', repo.get_revision('hello-id').message)
 
339
 
 
340
    def add_dead_head(self, tree):
 
341
        revno, revision_id = tree.branch.last_revision_info()
 
342
        tree.commit('Dead head', rev_id=b'dead-head-id')
 
343
        tree.branch.set_last_revision_info(revno, revision_id)
 
344
        tree.set_last_revision(revision_id)
 
345
 
 
346
    def test_standalone_to_use_shared_preserves_dead_heads(self):
 
347
        self.build_tree(['root/'])
 
348
        tree = self.make_branch_and_tree('root/tree')
 
349
        self.add_dead_head(tree)
 
350
        tree.commit('Hello', rev_id=b'hello-id')
 
351
        repo = self.make_repository('root', shared=True)
 
352
        reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.controldir)
 
353
        reconfiguration.apply()
 
354
        tree = workingtree.WorkingTree.open('root/tree')
 
355
        message = repo.get_revision('dead-head-id').message
 
356
        self.assertEqual('Dead head', message)
 
357
 
 
358
    def make_repository_tree(self):
 
359
        self.build_tree(['root/'])
 
360
        repo = self.make_repository('root', shared=True)
 
361
        tree = self.make_branch_and_tree('root/tree')
 
362
        reconfigure.Reconfigure.to_use_shared(tree.controldir).apply()
 
363
        return workingtree.WorkingTree.open('root/tree')
 
364
 
 
365
    def test_use_shared_to_use_shared(self):
 
366
        tree = self.make_repository_tree()
 
367
        self.assertRaises(reconfigure.AlreadyUsingShared,
 
368
                          reconfigure.Reconfigure.to_use_shared, tree.controldir)
 
369
 
 
370
    def test_use_shared_to_standalone(self):
 
371
        tree = self.make_repository_tree()
 
372
        tree.commit('Hello', rev_id=b'hello-id')
 
373
        reconfigure.Reconfigure.to_standalone(tree.controldir).apply()
 
374
        tree = workingtree.WorkingTree.open('root/tree')
 
375
        repo = tree.branch.repository
 
376
        self.assertEqual(repo.controldir.root_transport.base,
 
377
                         tree.controldir.root_transport.base)
 
378
        self.assertEqual('Hello', repo.get_revision('hello-id').message)
 
379
 
 
380
    def test_use_shared_to_standalone_preserves_dead_heads(self):
 
381
        tree = self.make_repository_tree()
 
382
        self.add_dead_head(tree)
 
383
        tree.commit('Hello', rev_id=b'hello-id')
 
384
        reconfigure.Reconfigure.to_standalone(tree.controldir).apply()
 
385
        tree = workingtree.WorkingTree.open('root/tree')
 
386
        repo = tree.branch.repository
 
387
        self.assertRaises(errors.NoSuchRevision, repo.get_revision,
 
388
                          'dead-head-id')
 
389
 
 
390
    def test_standalone_to_standalone(self):
 
391
        tree = self.make_branch_and_tree('tree')
 
392
        self.assertRaises(reconfigure.AlreadyStandalone,
 
393
                          reconfigure.Reconfigure.to_standalone, tree.controldir)
 
394
 
 
395
    def make_unsynced_branch_reconfiguration(self):
 
396
        parent = self.make_branch_and_tree('parent')
 
397
        parent.commit('commit 1')
 
398
        child = parent.controldir.sprout('child').open_workingtree()
 
399
        child.commit('commit 2')
 
400
        return reconfigure.Reconfigure.to_lightweight_checkout(child.controldir)
 
401
 
 
402
    def test_unsynced_branch_to_lightweight_checkout_unforced(self):
 
403
        reconfiguration = self.make_unsynced_branch_reconfiguration()
 
404
        self.assertRaises(reconfigure.UnsyncedBranches, reconfiguration.apply)
 
405
 
 
406
    def test_unsynced_branch_to_lightweight_checkout_forced(self):
 
407
        reconfiguration = self.make_unsynced_branch_reconfiguration()
 
408
        reconfiguration.apply(force=True)
 
409
 
 
410
    def make_repository_with_without_trees(self, with_trees):
 
411
        repo = self.make_repository('repo', shared=True)
 
412
        repo.set_make_working_trees(with_trees)
 
413
        return repo
 
414
 
 
415
    def test_make_with_trees(self):
 
416
        repo = self.make_repository_with_without_trees(False)
 
417
        reconfiguration = reconfigure.Reconfigure.set_repository_trees(
 
418
            repo.controldir, True)
 
419
        reconfiguration.apply()
 
420
        self.assertIs(True, repo.make_working_trees())
 
421
 
 
422
    def test_make_without_trees(self):
 
423
        repo = self.make_repository_with_without_trees(True)
 
424
        reconfiguration = reconfigure.Reconfigure.set_repository_trees(
 
425
            repo.controldir, False)
 
426
        reconfiguration.apply()
 
427
        self.assertIs(False, repo.make_working_trees())
 
428
 
 
429
    def test_make_with_trees_already_with_trees(self):
 
430
        repo = self.make_repository_with_without_trees(True)
 
431
        e = self.assertRaises(reconfigure.AlreadyWithTrees,
 
432
           reconfigure.Reconfigure.set_repository_trees, repo.controldir, True)
 
433
        self.assertContainsRe(str(e),
 
434
            r"Shared repository '.*' already creates working trees.")
 
435
 
 
436
    def test_make_without_trees_already_no_trees(self):
 
437
        repo = self.make_repository_with_without_trees(False)
 
438
        e = self.assertRaises(reconfigure.AlreadyWithNoTrees,
 
439
            reconfigure.Reconfigure.set_repository_trees, repo.controldir, False)
 
440
        self.assertContainsRe(str(e),
 
441
            r"Shared repository '.*' already doesn't create working trees.")
 
442
 
 
443
    def test_repository_tree_reconfiguration_not_supported(self):
 
444
        tree = self.make_branch_and_tree('tree')
 
445
        e = self.assertRaises(reconfigure.ReconfigurationNotSupported,
 
446
            reconfigure.Reconfigure.set_repository_trees, tree.controldir, None)
 
447
        self.assertContainsRe(str(e),
 
448
            r"Requested reconfiguration of '.*' is not supported.")
 
449
 
 
450
    def test_lightweight_checkout_to_tree_preserves_reference_locations(self):
 
451
        format = controldir.format_registry.make_controldir('1.9')
 
452
        format.set_branch_format(_mod_bzrbranch.BzrBranchFormat8())
 
453
        tree = self.make_branch_and_tree('tree', format=format)
 
454
        tree.branch.set_reference_info('path', '../location', 'file_id')
 
455
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
 
456
        reconfiguration = reconfigure.Reconfigure.to_tree(checkout.controldir)
 
457
        reconfiguration.apply()
 
458
        checkout_branch = checkout.controldir.open_branch()
 
459
        self.assertEqual(('../location', b'file_id'),
 
460
                         checkout_branch.get_reference_info('path'))