/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: 2017-06-08 23:30:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170608233031-3qavls2o7a1pqllj
Update imports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2007, 2008, 2009, 2011, 2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from bzrlib import (
 
17
from breezy import (
18
18
    branch as _mod_branch,
19
 
    bzrdir,
 
19
    controldir,
20
20
    errors,
21
21
    reconfigure,
22
22
    repository,
23
23
    tests,
24
24
    workingtree,
25
25
    )
 
26
from breezy.bzr import (
 
27
    branch as _mod_bzrbranch,
 
28
    vf_repository,
 
29
    )
26
30
 
27
31
 
28
32
class TestReconfigure(tests.TestCaseWithTransport):
46
50
 
47
51
    def test_tree_with_pending_merge_to_branch(self):
48
52
        tree = self.make_branch_and_tree('tree')
 
53
        tree.commit('unchanged')
49
54
        other_tree = tree.bzrdir.sprout('other').open_workingtree()
50
 
        self.build_tree(['other/file'])
51
 
        other_tree.add('file')
52
 
        other_tree.commit('file added')
 
55
        other_tree.commit('mergeable commit')
53
56
        tree.merge_from_branch(other_tree.branch)
54
57
        reconfiguration = reconfigure.Reconfigure.to_branch(tree.bzrdir)
55
58
        self.assertRaises(errors.UncommittedChanges, reconfiguration.apply)
72
75
        checkout = branch.create_checkout('checkout')
73
76
        reconfiguration = reconfigure.Reconfigure.to_branch(checkout.bzrdir)
74
77
        reconfiguration.apply()
75
 
        self.assertIs(None, checkout.branch.get_bound_location())
 
78
        reconfigured = controldir.ControlDir.open('checkout').open_branch()
 
79
        self.assertIs(None, reconfigured.get_bound_location())
76
80
 
77
81
    def prepare_lightweight_checkout_to_branch(self):
78
82
        branch = self.make_branch('branch')
147
151
        self.assertRaises(errors.NoBindLocation,
148
152
                          reconfiguration._select_bind_location)
149
153
        branch.set_parent('http://parent')
 
154
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
150
155
        self.assertEqual('http://parent',
151
156
                         reconfiguration._select_bind_location())
152
157
        branch.set_push_location('sftp://push')
 
158
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
153
159
        self.assertEqual('sftp://push',
154
160
                         reconfiguration._select_bind_location())
155
 
        branch.set_bound_location('bzr://foo/old-bound')
156
 
        branch.set_bound_location(None)
 
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.bzrdir)
157
168
        self.assertEqual('bzr://foo/old-bound',
158
169
                         reconfiguration._select_bind_location())
159
170
        branch.set_bound_location('bzr://foo/cur-bound')
 
171
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
160
172
        self.assertEqual('bzr://foo/cur-bound',
161
173
                         reconfiguration._select_bind_location())
162
174
        reconfiguration.new_bound_location = 'ftp://user-specified'
180
192
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
181
193
        # setting a parent allows it to become a checkout
182
194
        tree.branch.set_parent(parent.base)
 
195
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree.bzrdir)
183
196
        reconfiguration.apply()
184
197
        # supplying a location allows it to become a checkout
185
198
        tree2 = self.make_branch_and_tree('tree2')
198
211
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
199
212
        # setting a parent allows it to become a checkout
200
213
        tree.branch.set_parent(parent.base)
 
214
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
215
            tree.bzrdir)
201
216
        reconfiguration.apply()
202
217
        # supplying a location allows it to become a checkout
203
218
        tree2 = self.make_branch_and_tree('tree2')
259
274
    def test_branch_to_lightweight_checkout_failure(self):
260
275
        parent, child, reconfiguration = \
261
276
            self.prepare_branch_to_lightweight_checkout()
262
 
        old_Repository_fetch = repository.Repository.fetch
263
 
        repository.Repository.fetch = None
 
277
        old_Repository_fetch = vf_repository.VersionedFileRepository.fetch
 
278
        vf_repository.VersionedFileRepository.fetch = None
264
279
        try:
265
280
            self.assertRaises(TypeError, reconfiguration.apply)
266
281
        finally:
267
 
            repository.Repository.fetch = old_Repository_fetch
 
282
            vf_repository.VersionedFileRepository.fetch = old_Repository_fetch
268
283
        child = _mod_branch.Branch.open('child')
269
284
        self.assertContainsRe(child.base, 'child/$')
270
285
 
433
448
            r"Requested reconfiguration of '.*' is not supported.")
434
449
 
435
450
    def test_lightweight_checkout_to_tree_preserves_reference_locations(self):
436
 
        format = bzrdir.format_registry.make_bzrdir('1.9')
437
 
        format.set_branch_format(_mod_branch.BzrBranchFormat8())
 
451
        format = controldir.format_registry.make_bzrdir('1.9')
 
452
        format.set_branch_format(_mod_bzrbranch.BzrBranchFormat8())
438
453
        tree = self.make_branch_and_tree('tree', format=format)
439
454
        tree.branch.set_reference_info('file_id', 'path', '../location')
440
455
        checkout = tree.branch.create_checkout('checkout', lightweight=True)