~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_reconfigure.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
286
286
        workingtree.WorkingTree.open('repo')
287
287
        self.assertRaises(errors.NoRepositoryPresent,
288
288
                          repository.Repository.open, 'repo')
 
289
 
 
290
    def test_standalone_to_use_shared(self):
 
291
        self.build_tree(['root/'])
 
292
        tree = self.make_branch_and_tree('root/tree')
 
293
        tree.commit('Hello', rev_id='hello-id')
 
294
        repo = self.make_repository('root', shared=True)
 
295
        reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.bzrdir)
 
296
        reconfiguration.apply()
 
297
        tree = workingtree.WorkingTree.open('root/tree')
 
298
        self.assertTrue(repo.has_same_location(tree.branch.repository))
 
299
        self.assertEqual('Hello', repo.get_revision('hello-id').message)
 
300
 
 
301
    def add_dead_head(self, tree):
 
302
        revno, revision_id = tree.branch.last_revision_info()
 
303
        tree.commit('Dead head', rev_id='dead-head-id')
 
304
        tree.branch.set_last_revision_info(revno, revision_id)
 
305
        tree.set_last_revision(revision_id)
 
306
 
 
307
    def test_standalone_to_use_shared_preserves_dead_heads(self):
 
308
        self.build_tree(['root/'])
 
309
        tree = self.make_branch_and_tree('root/tree')
 
310
        self.add_dead_head(tree)
 
311
        tree.commit('Hello', rev_id='hello-id')
 
312
        repo = self.make_repository('root', shared=True)
 
313
        reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.bzrdir)
 
314
        reconfiguration.apply()
 
315
        tree = workingtree.WorkingTree.open('root/tree')
 
316
        message = repo.get_revision('dead-head-id').message
 
317
        self.assertEqual('Dead head', message)
 
318
 
 
319
    def make_repository_tree(self):
 
320
        self.build_tree(['root/'])
 
321
        repo = self.make_repository('root', shared=True)
 
322
        tree = self.make_branch_and_tree('root/tree')
 
323
        reconfigure.Reconfigure.to_use_shared(tree.bzrdir).apply()
 
324
        return workingtree.WorkingTree.open('root/tree')
 
325
 
 
326
    def test_use_shared_to_use_shared(self):
 
327
        tree = self.make_repository_tree()
 
328
        self.assertRaises(errors.AlreadyUsingShared,
 
329
                          reconfigure.Reconfigure.to_use_shared, tree.bzrdir)
 
330
 
 
331
    def test_use_shared_to_standalone(self):
 
332
        tree = self.make_repository_tree()
 
333
        tree.commit('Hello', rev_id='hello-id')
 
334
        reconfigure.Reconfigure.to_standalone(tree.bzrdir).apply()
 
335
        tree = workingtree.WorkingTree.open('root/tree')
 
336
        repo = tree.branch.repository
 
337
        self.assertEqual(repo.bzrdir.root_transport.base,
 
338
                         tree.bzrdir.root_transport.base)
 
339
        self.assertEqual('Hello', repo.get_revision('hello-id').message)
 
340
 
 
341
    def test_use_shared_to_standalone_preserves_dead_heads(self):
 
342
        tree = self.make_repository_tree()
 
343
        self.add_dead_head(tree)
 
344
        tree.commit('Hello', rev_id='hello-id')
 
345
        reconfigure.Reconfigure.to_standalone(tree.bzrdir).apply()
 
346
        tree = workingtree.WorkingTree.open('root/tree')
 
347
        repo = tree.branch.repository
 
348
        self.assertRaises(errors.NoSuchRevision, repo.get_revision,
 
349
                          'dead-head-id')
 
350
 
 
351
    def test_standalone_to_standalone(self):
 
352
        tree = self.make_branch_and_tree('tree')
 
353
        self.assertRaises(errors.AlreadyStandalone,
 
354
                          reconfigure.Reconfigure.to_standalone, tree.bzrdir)