~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_reconfigure.py

  • Committer: Jelmer Vernooij
  • Date: 2011-11-28 15:18:59 UTC
  • mto: This revision was merged to the branch mainline in revision 6317.
  • Revision ID: jelmer@samba.org-20111128151859-dw4nua1xiobilw4r
Fix tests.

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
 
72
71
        checkout = branch.create_checkout('checkout')
73
72
        reconfiguration = reconfigure.Reconfigure.to_branch(checkout.bzrdir)
74
73
        reconfiguration.apply()
75
 
        reconfigured = bzrdir.BzrDir.open('checkout').open_branch()
76
 
        self.assertIs(None, reconfigured.get_bound_location())
 
74
        self.assertIs(None, checkout.branch.get_bound_location())
77
75
 
78
76
    def prepare_lightweight_checkout_to_branch(self):
79
77
        branch = self.make_branch('branch')
148
146
        self.assertRaises(errors.NoBindLocation,
149
147
                          reconfiguration._select_bind_location)
150
148
        branch.set_parent('http://parent')
151
 
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
152
149
        self.assertEqual('http://parent',
153
150
                         reconfiguration._select_bind_location())
154
151
        branch.set_push_location('sftp://push')
155
 
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
156
152
        self.assertEqual('sftp://push',
157
153
                         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)
 
154
        branch.set_bound_location('bzr://foo/old-bound')
 
155
        branch.set_bound_location(None)
165
156
        self.assertEqual('bzr://foo/old-bound',
166
157
                         reconfiguration._select_bind_location())
167
158
        branch.set_bound_location('bzr://foo/cur-bound')
168
 
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
169
159
        self.assertEqual('bzr://foo/cur-bound',
170
160
                         reconfiguration._select_bind_location())
171
161
        reconfiguration.new_bound_location = 'ftp://user-specified'
189
179
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
190
180
        # setting a parent allows it to become a checkout
191
181
        tree.branch.set_parent(parent.base)
192
 
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree.bzrdir)
193
182
        reconfiguration.apply()
194
183
        # supplying a location allows it to become a checkout
195
184
        tree2 = self.make_branch_and_tree('tree2')
208
197
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
209
198
        # setting a parent allows it to become a checkout
210
199
        tree.branch.set_parent(parent.base)
211
 
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
212
 
            tree.bzrdir)
213
200
        reconfiguration.apply()
214
201
        # supplying a location allows it to become a checkout
215
202
        tree2 = self.make_branch_and_tree('tree2')
271
258
    def test_branch_to_lightweight_checkout_failure(self):
272
259
        parent, child, reconfiguration = \
273
260
            self.prepare_branch_to_lightweight_checkout()
274
 
        old_Repository_fetch = vf_repository.VersionedFileRepository.fetch
275
 
        vf_repository.VersionedFileRepository.fetch = None
 
261
        old_Repository_fetch = repository.Repository.fetch
 
262
        repository.Repository.fetch = None
276
263
        try:
277
264
            self.assertRaises(TypeError, reconfiguration.apply)
278
265
        finally:
279
 
            vf_repository.VersionedFileRepository.fetch = old_Repository_fetch
 
266
            repository.Repository.fetch = old_Repository_fetch
280
267
        child = _mod_branch.Branch.open('child')
281
268
        self.assertContainsRe(child.base, 'child/$')
282
269