~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_reconfigure.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-01-13 05:14:24 UTC
  • mfrom: (3936.1.3 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090113051424-nrk3zkfe09h46i9y
(mbp) merge 1.11 and advance to 1.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2007 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
from bzrlib import (
18
18
    branch as _mod_branch,
19
 
    bzrdir,
20
19
    errors,
21
20
    reconfigure,
22
21
    repository,
44
43
        self.assertRaises(errors.NoWorkingTree, workingtree.WorkingTree.open,
45
44
                          'tree')
46
45
 
47
 
    def test_tree_with_pending_merge_to_branch(self):
48
 
        tree = self.make_branch_and_tree('tree')
49
 
        tree.commit('unchanged')
50
 
        other_tree = tree.bzrdir.sprout('other').open_workingtree()
51
 
        other_tree.commit('mergeable commit')
52
 
        tree.merge_from_branch(other_tree.branch)
53
 
        reconfiguration = reconfigure.Reconfigure.to_branch(tree.bzrdir)
54
 
        self.assertRaises(errors.UncommittedChanges, reconfiguration.apply)
55
 
        reconfiguration.apply(force=True)
56
 
        self.assertRaises(errors.NoWorkingTree, workingtree.WorkingTree.open,
57
 
                          'tree')
58
 
 
59
46
    def test_branch_to_branch(self):
60
47
        branch = self.make_branch('branch')
61
48
        self.assertRaises(errors.AlreadyBranch,
390
377
    def test_unsynced_branch_to_lightweight_checkout_forced(self):
391
378
        reconfiguration = self.make_unsynced_branch_reconfiguration()
392
379
        reconfiguration.apply(force=True)
393
 
 
394
 
    def make_repository_with_without_trees(self, with_trees):
395
 
        repo = self.make_repository('repo', shared=True)
396
 
        repo.set_make_working_trees(with_trees)
397
 
        return repo
398
 
 
399
 
    def test_make_with_trees(self):
400
 
        repo = self.make_repository_with_without_trees(False)
401
 
        reconfiguration = reconfigure.Reconfigure.set_repository_trees(
402
 
            repo.bzrdir, True)
403
 
        reconfiguration.apply()
404
 
        self.assertIs(True, repo.make_working_trees())
405
 
 
406
 
    def test_make_without_trees(self):
407
 
        repo = self.make_repository_with_without_trees(True)
408
 
        reconfiguration = reconfigure.Reconfigure.set_repository_trees(
409
 
            repo.bzrdir, False)
410
 
        reconfiguration.apply()
411
 
        self.assertIs(False, repo.make_working_trees())
412
 
 
413
 
    def test_make_with_trees_already_with_trees(self):
414
 
        repo = self.make_repository_with_without_trees(True)
415
 
        e = self.assertRaises(errors.AlreadyWithTrees,
416
 
           reconfigure.Reconfigure.set_repository_trees, repo.bzrdir, True)
417
 
        self.assertContainsRe(str(e),
418
 
            r"Shared repository '.*' already creates working trees.")
419
 
 
420
 
    def test_make_without_trees_already_no_trees(self):
421
 
        repo = self.make_repository_with_without_trees(False)
422
 
        e = self.assertRaises(errors.AlreadyWithNoTrees,
423
 
            reconfigure.Reconfigure.set_repository_trees, repo.bzrdir, False)
424
 
        self.assertContainsRe(str(e),
425
 
            r"Shared repository '.*' already doesn't create working trees.")
426
 
 
427
 
    def test_repository_tree_reconfiguration_not_supported(self):
428
 
        tree = self.make_branch_and_tree('tree')
429
 
        e = self.assertRaises(errors.ReconfigurationNotSupported,
430
 
            reconfigure.Reconfigure.set_repository_trees, tree.bzrdir, None)
431
 
        self.assertContainsRe(str(e),
432
 
            r"Requested reconfiguration of '.*' is not supported.")
433
 
 
434
 
    def test_lightweight_checkout_to_tree_preserves_reference_locations(self):
435
 
        format = bzrdir.format_registry.make_bzrdir('1.9')
436
 
        format.set_branch_format(_mod_branch.BzrBranchFormat8())
437
 
        tree = self.make_branch_and_tree('tree', format=format)
438
 
        tree.branch.set_reference_info('file_id', 'path', '../location')
439
 
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
440
 
        reconfiguration = reconfigure.Reconfigure.to_tree(checkout.bzrdir)
441
 
        reconfiguration.apply()
442
 
        checkout_branch = checkout.bzrdir.open_branch()
443
 
        self.assertEqual(('path', '../location'),
444
 
                         checkout_branch.get_reference_info('file_id'))