/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: John Arbash Meinel
  • Date: 2008-06-05 16:27:16 UTC
  • mfrom: (3475 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3476.
  • Revision ID: john@arbash-meinel.com-20080605162716-a3hn238tnctbfd8j
merge bzr.dev, resolve NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
197
197
        self.assertRaises(errors.AlreadyCheckout,
198
198
                          reconfigure.Reconfigure.to_checkout, checkout.bzrdir)
199
199
 
200
 
    def test_checkout_to_lightweight(self):
 
200
    def make_unsynced_checkout(self):
201
201
        parent = self.make_branch('parent')
202
202
        checkout = parent.create_checkout('checkout')
203
203
        checkout.commit('test', rev_id='new-commit', local=True)
204
204
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
205
205
            checkout.bzrdir)
 
206
        return checkout, parent, reconfiguration
 
207
 
 
208
    def test_unsynced_checkout_to_lightweight(self):
 
209
        checkout, parent, reconfiguration = self.make_unsynced_checkout()
 
210
        self.assertRaises(errors.UnsyncedBranches, reconfiguration.apply)
 
211
 
 
212
    def test_synced_checkout_to_lightweight(self):
 
213
        checkout, parent, reconfiguration = self.make_unsynced_checkout()
 
214
        parent.pull(checkout.branch)
206
215
        reconfiguration.apply()
207
216
        wt = checkout.bzrdir.open_workingtree()
208
217
        self.assertTrue(parent.repository.has_same_location(
215
224
        parent = self.make_branch('parent')
216
225
        child = parent.bzrdir.sprout('child').open_workingtree()
217
226
        child.commit('test', rev_id='new-commit')
 
227
        parent.pull(child.branch)
218
228
        child.bzrdir.destroy_workingtree()
219
229
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
220
230
            child.bzrdir)
286
296
        workingtree.WorkingTree.open('repo')
287
297
        self.assertRaises(errors.NoRepositoryPresent,
288
298
                          repository.Repository.open, 'repo')
 
299
 
 
300
    def test_standalone_to_use_shared(self):
 
301
        self.build_tree(['root/'])
 
302
        tree = self.make_branch_and_tree('root/tree')
 
303
        tree.commit('Hello', rev_id='hello-id')
 
304
        repo = self.make_repository('root', shared=True)
 
305
        reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.bzrdir)
 
306
        reconfiguration.apply()
 
307
        tree = workingtree.WorkingTree.open('root/tree')
 
308
        self.assertTrue(repo.has_same_location(tree.branch.repository))
 
309
        self.assertEqual('Hello', repo.get_revision('hello-id').message)
 
310
 
 
311
    def add_dead_head(self, tree):
 
312
        revno, revision_id = tree.branch.last_revision_info()
 
313
        tree.commit('Dead head', rev_id='dead-head-id')
 
314
        tree.branch.set_last_revision_info(revno, revision_id)
 
315
        tree.set_last_revision(revision_id)
 
316
 
 
317
    def test_standalone_to_use_shared_preserves_dead_heads(self):
 
318
        self.build_tree(['root/'])
 
319
        tree = self.make_branch_and_tree('root/tree')
 
320
        self.add_dead_head(tree)
 
321
        tree.commit('Hello', rev_id='hello-id')
 
322
        repo = self.make_repository('root', shared=True)
 
323
        reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.bzrdir)
 
324
        reconfiguration.apply()
 
325
        tree = workingtree.WorkingTree.open('root/tree')
 
326
        message = repo.get_revision('dead-head-id').message
 
327
        self.assertEqual('Dead head', message)
 
328
 
 
329
    def make_repository_tree(self):
 
330
        self.build_tree(['root/'])
 
331
        repo = self.make_repository('root', shared=True)
 
332
        tree = self.make_branch_and_tree('root/tree')
 
333
        reconfigure.Reconfigure.to_use_shared(tree.bzrdir).apply()
 
334
        return workingtree.WorkingTree.open('root/tree')
 
335
 
 
336
    def test_use_shared_to_use_shared(self):
 
337
        tree = self.make_repository_tree()
 
338
        self.assertRaises(errors.AlreadyUsingShared,
 
339
                          reconfigure.Reconfigure.to_use_shared, tree.bzrdir)
 
340
 
 
341
    def test_use_shared_to_standalone(self):
 
342
        tree = self.make_repository_tree()
 
343
        tree.commit('Hello', rev_id='hello-id')
 
344
        reconfigure.Reconfigure.to_standalone(tree.bzrdir).apply()
 
345
        tree = workingtree.WorkingTree.open('root/tree')
 
346
        repo = tree.branch.repository
 
347
        self.assertEqual(repo.bzrdir.root_transport.base,
 
348
                         tree.bzrdir.root_transport.base)
 
349
        self.assertEqual('Hello', repo.get_revision('hello-id').message)
 
350
 
 
351
    def test_use_shared_to_standalone_preserves_dead_heads(self):
 
352
        tree = self.make_repository_tree()
 
353
        self.add_dead_head(tree)
 
354
        tree.commit('Hello', rev_id='hello-id')
 
355
        reconfigure.Reconfigure.to_standalone(tree.bzrdir).apply()
 
356
        tree = workingtree.WorkingTree.open('root/tree')
 
357
        repo = tree.branch.repository
 
358
        self.assertRaises(errors.NoSuchRevision, repo.get_revision,
 
359
                          'dead-head-id')
 
360
 
 
361
    def test_standalone_to_standalone(self):
 
362
        tree = self.make_branch_and_tree('tree')
 
363
        self.assertRaises(errors.AlreadyStandalone,
 
364
                          reconfigure.Reconfigure.to_standalone, tree.bzrdir)
 
365
 
 
366
    def make_unsynced_branch_reconfiguration(self):
 
367
        parent = self.make_branch_and_tree('parent')
 
368
        parent.commit('commit 1')
 
369
        child = parent.bzrdir.sprout('child').open_workingtree()
 
370
        child.commit('commit 2')
 
371
        return reconfigure.Reconfigure.to_lightweight_checkout(child.bzrdir)
 
372
 
 
373
    def test_unsynced_branch_to_lightweight_checkout_unforced(self):
 
374
        reconfiguration = self.make_unsynced_branch_reconfiguration()
 
375
        self.assertRaises(errors.UnsyncedBranches, reconfiguration.apply)
 
376
 
 
377
    def test_unsynced_branch_to_lightweight_checkout_forced(self):
 
378
        reconfiguration = self.make_unsynced_branch_reconfiguration()
 
379
        reconfiguration.apply(force=True)