/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 bzrlib/tests/test_reconfigure.py

  • Committer: Lukáš Lalinský
  • Date: 2007-12-17 17:28:25 UTC
  • mfrom: (3120 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3123.
  • Revision ID: lalinsky@gmail.com-20071217172825-tr3pqm1mhvs3gwnn
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
    branch as _mod_branch,
19
19
    errors,
20
20
    reconfigure,
 
21
    repository,
21
22
    tests,
22
23
    workingtree,
23
24
    )
49
50
 
50
51
    def test_repo_to_branch(self):
51
52
        repo = self.make_repository('repo')
52
 
        self.assertRaises(errors.ReconfigurationNotSupported,
53
 
                          reconfigure.Reconfigure.to_branch, repo.bzrdir)
 
53
        reconfiguration = reconfigure.Reconfigure.to_branch(repo.bzrdir)
 
54
        reconfiguration.apply()
54
55
 
55
56
    def test_checkout_to_branch(self):
56
57
        branch = self.make_branch('branch')
111
112
        branch.set_push_location('sftp://push')
112
113
        self.assertEqual('sftp://push',
113
114
                         reconfiguration._select_bind_location())
114
 
        branch.set_bound_location('bzr:old-bound')
 
115
        branch.set_bound_location('bzr://foo/old-bound')
115
116
        branch.set_bound_location(None)
116
 
        self.assertEqual('bzr:old-bound',
 
117
        self.assertEqual('bzr://foo/old-bound',
 
118
                         reconfiguration._select_bind_location())
 
119
        branch.set_bound_location('bzr://foo/cur-bound')
 
120
        self.assertEqual('bzr://foo/cur-bound',
117
121
                         reconfiguration._select_bind_location())
118
122
        reconfiguration.new_bound_location = 'ftp://user-specified'
119
123
        self.assertEqual('ftp://user-specified',
143
147
                                                              parent.base)
144
148
        reconfiguration.apply()
145
149
 
 
150
    def test_tree_to_lightweight_checkout(self):
 
151
        # A tree with no related branches and no supplied bind location cannot
 
152
        # become a checkout
 
153
        parent = self.make_branch('parent')
 
154
 
 
155
        tree = self.make_branch_and_tree('tree')
 
156
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
157
            tree.bzrdir)
 
158
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
 
159
        # setting a parent allows it to become a checkout
 
160
        tree.branch.set_parent(parent.base)
 
161
        reconfiguration.apply()
 
162
        # supplying a location allows it to become a checkout
 
163
        tree2 = self.make_branch_and_tree('tree2')
 
164
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
165
            tree2.bzrdir, parent.base)
 
166
        reconfiguration.apply()
 
167
 
146
168
    def test_checkout_to_checkout(self):
147
169
        parent = self.make_branch('parent')
148
170
        checkout = parent.create_checkout('checkout')
149
171
        self.assertRaises(errors.AlreadyCheckout,
150
172
                          reconfigure.Reconfigure.to_checkout, checkout.bzrdir)
 
173
 
 
174
    def test_checkout_to_lightweight(self):
 
175
        parent = self.make_branch('parent')
 
176
        checkout = parent.create_checkout('checkout')
 
177
        checkout.commit('test', rev_id='new-commit', local=True)
 
178
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
179
            checkout.bzrdir)
 
180
        reconfiguration.apply()
 
181
        wt = checkout.bzrdir.open_workingtree()
 
182
        self.assertTrue(parent.repository.has_same_location(
 
183
            wt.branch.repository))
 
184
        parent.repository.get_revision('new-commit')
 
185
        self.assertRaises(errors.NoRepositoryPresent,
 
186
                          checkout.bzrdir.open_repository)
 
187
 
 
188
    def test_branch_to_lightweight_checkout(self):
 
189
        parent = self.make_branch('parent')
 
190
        child = parent.bzrdir.sprout('child').open_workingtree()
 
191
        child.commit('test', rev_id='new-commit')
 
192
        child.bzrdir.destroy_workingtree()
 
193
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
194
            child.bzrdir)
 
195
        reconfiguration.apply()
 
196
        wt = child.bzrdir.open_workingtree()
 
197
        self.assertTrue(parent.repository.has_same_location(
 
198
            wt.branch.repository))
 
199
        parent.repository.get_revision('new-commit')
 
200
        self.assertRaises(errors.NoRepositoryPresent,
 
201
                          child.bzrdir.open_repository)
 
202
 
 
203
    def test_lightweight_checkout_to_lightweight_checkout(self):
 
204
        parent = self.make_branch('parent')
 
205
        checkout = parent.create_checkout('checkout', lightweight=True)
 
206
        self.assertRaises(errors.AlreadyLightweightCheckout,
 
207
                          reconfigure.Reconfigure.to_lightweight_checkout,
 
208
                          checkout.bzrdir)
 
209
 
 
210
    def test_repo_to_tree(self):
 
211
        repo = self.make_repository('repo')
 
212
        reconfiguration = reconfigure.Reconfigure.to_tree(repo.bzrdir)
 
213
        reconfiguration.apply()
 
214
        workingtree.WorkingTree.open('repo')
 
215
 
 
216
    def test_shared_repo_to_lightweight_checkout(self):
 
217
        repo = self.make_repository('repo', shared=True)
 
218
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
219
            repo.bzrdir)
 
220
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
 
221
        branch = self.make_branch('branch')
 
222
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
223
            repo.bzrdir, 'branch')
 
224
        reconfiguration.apply()
 
225
        workingtree.WorkingTree.open('repo')
 
226
        repository.Repository.open('repo')
 
227
 
 
228
    def test_unshared_repo_to_lightweight_checkout(self):
 
229
        repo = self.make_repository('repo', shared=False)
 
230
        branch = self.make_branch('branch')
 
231
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
 
232
            repo.bzrdir, 'branch')
 
233
        reconfiguration.apply()
 
234
        workingtree.WorkingTree.open('repo')
 
235
        self.assertRaises(errors.NoRepositoryPresent,
 
236
                          repository.Repository.open, 'repo')