~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_reconfigure.py

  • Committer: Martin Pool
  • Date: 2011-04-19 07:52:11 UTC
  • mto: This revision was merged to the branch mainline in revision 5833.
  • Revision ID: mbp@sourcefrog.net-20110419075211-3m94qorhr0rg3gzg
Add and test _RulesSearcher.get_single_value

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008, 2009, 2011, 2012 Canonical Ltd
 
1
# Copyright (C) 2007, 2008, 2009 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
21
21
    reconfigure,
22
22
    repository,
23
23
    tests,
24
 
    vf_repository,
25
24
    workingtree,
26
25
    )
27
26
 
47
46
 
48
47
    def test_tree_with_pending_merge_to_branch(self):
49
48
        tree = self.make_branch_and_tree('tree')
50
 
        tree.commit('unchanged')
51
49
        other_tree = tree.bzrdir.sprout('other').open_workingtree()
52
 
        other_tree.commit('mergeable commit')
 
50
        self.build_tree(['other/file'])
 
51
        other_tree.add('file')
 
52
        other_tree.commit('file added')
53
53
        tree.merge_from_branch(other_tree.branch)
54
54
        reconfiguration = reconfigure.Reconfigure.to_branch(tree.bzrdir)
55
55
        self.assertRaises(errors.UncommittedChanges, reconfiguration.apply)
72
72
        checkout = branch.create_checkout('checkout')
73
73
        reconfiguration = reconfigure.Reconfigure.to_branch(checkout.bzrdir)
74
74
        reconfiguration.apply()
75
 
        reconfigured = bzrdir.BzrDir.open('checkout').open_branch()
76
 
        self.assertIs(None, reconfigured.get_bound_location())
 
75
        self.assertIs(None, checkout.branch.get_bound_location())
77
76
 
78
77
    def prepare_lightweight_checkout_to_branch(self):
79
78
        branch = self.make_branch('branch')
148
147
        self.assertRaises(errors.NoBindLocation,
149
148
                          reconfiguration._select_bind_location)
150
149
        branch.set_parent('http://parent')
151
 
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
152
150
        self.assertEqual('http://parent',
153
151
                         reconfiguration._select_bind_location())
154
152
        branch.set_push_location('sftp://push')
155
 
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
156
153
        self.assertEqual('sftp://push',
157
154
                         reconfiguration._select_bind_location())
158
 
        branch.lock_write()
159
 
        try:
160
 
            branch.set_bound_location('bzr://foo/old-bound')
161
 
            branch.set_bound_location(None)
162
 
        finally:
163
 
            branch.unlock()
164
 
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
 
155
        branch.set_bound_location('bzr://foo/old-bound')
 
156
        branch.set_bound_location(None)
165
157
        self.assertEqual('bzr://foo/old-bound',
166
158
                         reconfiguration._select_bind_location())
167
159
        branch.set_bound_location('bzr://foo/cur-bound')
168
 
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
169
160
        self.assertEqual('bzr://foo/cur-bound',
170
161
                         reconfiguration._select_bind_location())
171
162
        reconfiguration.new_bound_location = 'ftp://user-specified'
189
180
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
190
181
        # setting a parent allows it to become a checkout
191
182
        tree.branch.set_parent(parent.base)
192
 
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree.bzrdir)
193
183
        reconfiguration.apply()
194
184
        # supplying a location allows it to become a checkout
195
185
        tree2 = self.make_branch_and_tree('tree2')
208
198
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
209
199
        # setting a parent allows it to become a checkout
210
200
        tree.branch.set_parent(parent.base)
211
 
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
212
 
            tree.bzrdir)
213
201
        reconfiguration.apply()
214
202
        # supplying a location allows it to become a checkout
215
203
        tree2 = self.make_branch_and_tree('tree2')
271
259
    def test_branch_to_lightweight_checkout_failure(self):
272
260
        parent, child, reconfiguration = \
273
261
            self.prepare_branch_to_lightweight_checkout()
274
 
        old_Repository_fetch = vf_repository.VersionedFileRepository.fetch
275
 
        vf_repository.VersionedFileRepository.fetch = None
 
262
        old_Repository_fetch = repository.Repository.fetch
 
263
        repository.Repository.fetch = None
276
264
        try:
277
265
            self.assertRaises(TypeError, reconfiguration.apply)
278
266
        finally:
279
 
            vf_repository.VersionedFileRepository.fetch = old_Repository_fetch
 
267
            repository.Repository.fetch = old_Repository_fetch
280
268
        child = _mod_branch.Branch.open('child')
281
269
        self.assertContainsRe(child.base, 'child/$')
282
270