/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: Martin
  • Date: 2017-06-09 16:31:49 UTC
  • mto: This revision was merged to the branch mainline in revision 6673.
  • Revision ID: gzlist@googlemail.com-20170609163149-liveiasey25480q6
Make InventoryDeltaError use string formatting, and repr for fileids

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
    bzrbranch as _mod_bzrbranch,
 
20
    controldir,
20
21
    errors,
21
22
    reconfigure,
22
23
    repository,
23
24
    tests,
 
25
    vf_repository,
24
26
    workingtree,
25
27
    )
26
28
 
46
48
 
47
49
    def test_tree_with_pending_merge_to_branch(self):
48
50
        tree = self.make_branch_and_tree('tree')
 
51
        tree.commit('unchanged')
49
52
        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')
 
53
        other_tree.commit('mergeable commit')
53
54
        tree.merge_from_branch(other_tree.branch)
54
55
        reconfiguration = reconfigure.Reconfigure.to_branch(tree.bzrdir)
55
56
        self.assertRaises(errors.UncommittedChanges, reconfiguration.apply)
72
73
        checkout = branch.create_checkout('checkout')
73
74
        reconfiguration = reconfigure.Reconfigure.to_branch(checkout.bzrdir)
74
75
        reconfiguration.apply()
75
 
        self.assertIs(None, checkout.branch.get_bound_location())
 
76
        reconfigured = controldir.ControlDir.open('checkout').open_branch()
 
77
        self.assertIs(None, reconfigured.get_bound_location())
76
78
 
77
79
    def prepare_lightweight_checkout_to_branch(self):
78
80
        branch = self.make_branch('branch')
147
149
        self.assertRaises(errors.NoBindLocation,
148
150
                          reconfiguration._select_bind_location)
149
151
        branch.set_parent('http://parent')
 
152
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
150
153
        self.assertEqual('http://parent',
151
154
                         reconfiguration._select_bind_location())
152
155
        branch.set_push_location('sftp://push')
 
156
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
153
157
        self.assertEqual('sftp://push',
154
158
                         reconfiguration._select_bind_location())
155
 
        branch.set_bound_location('bzr://foo/old-bound')
156
 
        branch.set_bound_location(None)
 
159
        branch.lock_write()
 
160
        try:
 
161
            branch.set_bound_location('bzr://foo/old-bound')
 
162
            branch.set_bound_location(None)
 
163
        finally:
 
164
            branch.unlock()
 
165
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
157
166
        self.assertEqual('bzr://foo/old-bound',
158
167
                         reconfiguration._select_bind_location())
159
168
        branch.set_bound_location('bzr://foo/cur-bound')
 
169
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
160
170
        self.assertEqual('bzr://foo/cur-bound',
161
171
                         reconfiguration._select_bind_location())
162
172
        reconfiguration.new_bound_location = 'ftp://user-specified'
180
190
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
181
191
        # setting a parent allows it to become a checkout
182
192
        tree.branch.set_parent(parent.base)
 
193
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree.bzrdir)
183
194
        reconfiguration.apply()
184
195
        # supplying a location allows it to become a checkout
185
196
        tree2 = self.make_branch_and_tree('tree2')
198
209
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
199
210
        # setting a parent allows it to become a checkout
200
211
        tree.branch.set_parent(parent.base)
 
212
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
213
            tree.bzrdir)
201
214
        reconfiguration.apply()
202
215
        # supplying a location allows it to become a checkout
203
216
        tree2 = self.make_branch_and_tree('tree2')
259
272
    def test_branch_to_lightweight_checkout_failure(self):
260
273
        parent, child, reconfiguration = \
261
274
            self.prepare_branch_to_lightweight_checkout()
262
 
        old_Repository_fetch = repository.Repository.fetch
263
 
        repository.Repository.fetch = None
 
275
        old_Repository_fetch = vf_repository.VersionedFileRepository.fetch
 
276
        vf_repository.VersionedFileRepository.fetch = None
264
277
        try:
265
278
            self.assertRaises(TypeError, reconfiguration.apply)
266
279
        finally:
267
 
            repository.Repository.fetch = old_Repository_fetch
 
280
            vf_repository.VersionedFileRepository.fetch = old_Repository_fetch
268
281
        child = _mod_branch.Branch.open('child')
269
282
        self.assertContainsRe(child.base, 'child/$')
270
283
 
433
446
            r"Requested reconfiguration of '.*' is not supported.")
434
447
 
435
448
    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())
 
449
        format = controldir.format_registry.make_bzrdir('1.9')
 
450
        format.set_branch_format(_mod_bzrbranch.BzrBranchFormat8())
438
451
        tree = self.make_branch_and_tree('tree', format=format)
439
452
        tree.branch.set_reference_info('file_id', 'path', '../location')
440
453
        checkout = tree.branch.create_checkout('checkout', lightweight=True)