~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_reconfigure.py

  • Committer: Aaron Bentley
  • Date: 2008-04-24 04:58:42 UTC
  • mfrom: (3377 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3380.
  • Revision ID: aaron@aaronbentley.com-20080424045842-0cajl9v6s4u52kaw
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
304
304
        self.assertRaises(errors.NoRepositoryPresent,
305
305
                          repository.Repository.open, 'repo')
306
306
 
 
307
    def test_standalone_to_use_shared(self):
 
308
        self.build_tree(['root/'])
 
309
        tree = self.make_branch_and_tree('root/tree')
 
310
        tree.commit('Hello', rev_id='hello-id')
 
311
        repo = self.make_repository('root', shared=True)
 
312
        reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.bzrdir)
 
313
        reconfiguration.apply()
 
314
        tree = workingtree.WorkingTree.open('root/tree')
 
315
        self.assertTrue(repo.has_same_location(tree.branch.repository))
 
316
        self.assertEqual('Hello', repo.get_revision('hello-id').message)
 
317
 
 
318
    def add_dead_head(self, tree):
 
319
        revno, revision_id = tree.branch.last_revision_info()
 
320
        tree.commit('Dead head', rev_id='dead-head-id')
 
321
        tree.branch.set_last_revision_info(revno, revision_id)
 
322
        tree.set_last_revision(revision_id)
 
323
 
 
324
    def test_standalone_to_use_shared_preserves_dead_heads(self):
 
325
        self.build_tree(['root/'])
 
326
        tree = self.make_branch_and_tree('root/tree')
 
327
        self.add_dead_head(tree)
 
328
        tree.commit('Hello', rev_id='hello-id')
 
329
        repo = self.make_repository('root', shared=True)
 
330
        reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.bzrdir)
 
331
        reconfiguration.apply()
 
332
        tree = workingtree.WorkingTree.open('root/tree')
 
333
        message = repo.get_revision('dead-head-id').message
 
334
        self.assertEqual('Dead head', message)
 
335
 
 
336
    def make_repository_tree(self):
 
337
        self.build_tree(['root/'])
 
338
        repo = self.make_repository('root', shared=True)
 
339
        tree = self.make_branch_and_tree('root/tree')
 
340
        reconfigure.Reconfigure.to_use_shared(tree.bzrdir).apply()
 
341
        return workingtree.WorkingTree.open('root/tree')
 
342
 
 
343
    def test_use_shared_to_use_shared(self):
 
344
        tree = self.make_repository_tree()
 
345
        self.assertRaises(errors.AlreadyUsingShared,
 
346
                          reconfigure.Reconfigure.to_use_shared, tree.bzrdir)
 
347
 
 
348
    def test_use_shared_to_standalone(self):
 
349
        tree = self.make_repository_tree()
 
350
        tree.commit('Hello', rev_id='hello-id')
 
351
        reconfigure.Reconfigure.to_standalone(tree.bzrdir).apply()
 
352
        tree = workingtree.WorkingTree.open('root/tree')
 
353
        repo = tree.branch.repository
 
354
        self.assertEqual(repo.bzrdir.root_transport.base,
 
355
                         tree.bzrdir.root_transport.base)
 
356
        self.assertEqual('Hello', repo.get_revision('hello-id').message)
 
357
 
 
358
    def test_use_shared_to_standalone_preserves_dead_heads(self):
 
359
        tree = self.make_repository_tree()
 
360
        self.add_dead_head(tree)
 
361
        tree.commit('Hello', rev_id='hello-id')
 
362
        reconfigure.Reconfigure.to_standalone(tree.bzrdir).apply()
 
363
        tree = workingtree.WorkingTree.open('root/tree')
 
364
        repo = tree.branch.repository
 
365
        self.assertRaises(errors.NoSuchRevision, repo.get_revision,
 
366
                          'dead-head-id')
 
367
 
 
368
    def test_standalone_to_standalone(self):
 
369
        tree = self.make_branch_and_tree('tree')
 
370
        self.assertRaises(errors.AlreadyStandalone,
 
371
                          reconfigure.Reconfigure.to_standalone, tree.bzrdir)
 
372
 
307
373
    def make_unsynced_branch_reconfiguration(self):
308
374
        parent = self.make_branch_and_tree('parent')
309
375
        parent.commit('commit 1')