~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_reconfigure.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
from bzrlib import (
 
18
    bzrdir,
 
19
    errors,
 
20
    tests,
 
21
    workingtree,
 
22
    )
 
23
 
 
24
 
 
25
class TestReconfigure(tests.TestCaseWithTransport):
 
26
 
 
27
    def test_no_type(self):
 
28
        branch = self.make_branch('branch')
 
29
        self.run_bzr_error(['No target configuration specified'],
 
30
                           'reconfigure branch')
 
31
 
 
32
    def test_branch_to_tree(self):
 
33
        branch = self.make_branch('branch')
 
34
        self.run_bzr('reconfigure --tree branch')
 
35
        tree = workingtree.WorkingTree.open('branch')
 
36
 
 
37
    def test_tree_to_branch(self):
 
38
        tree = self.make_branch_and_tree('tree')
 
39
        self.run_bzr('reconfigure --branch tree')
 
40
        self.assertRaises(errors.NoWorkingTree,
 
41
                          workingtree.WorkingTree.open, 'tree')
 
42
 
 
43
    def test_branch_to_specified_checkout(self):
 
44
        branch = self.make_branch('branch')
 
45
        parent = self.make_branch('parent')
 
46
        self.run_bzr('reconfigure branch --checkout --bind-to parent')
 
47
 
 
48
    def test_force(self):
 
49
        tree = self.make_branch_and_tree('tree')
 
50
        self.build_tree(['tree/file'])
 
51
        tree.add('file')
 
52
        self.run_bzr_error(['Working tree ".*" has uncommitted changes'],
 
53
                            'reconfigure --branch tree')
 
54
        self.run_bzr('reconfigure --force --branch tree')
 
55
 
 
56
    def test_lightweight_checkout_to_checkout(self):
 
57
        branch = self.make_branch('branch')
 
58
        checkout = branch.create_checkout('checkout', lightweight=True)
 
59
        self.run_bzr('reconfigure --checkout checkout')
 
60
 
 
61
    def test_no_args(self):
 
62
        branch = self.make_branch('branch')
 
63
        self.run_bzr_error(['No target configuration specified'],
 
64
                           'reconfigure', working_dir='branch')
 
65
 
 
66
    def test_checkout_to_lightweight_checkout(self):
 
67
        branch = self.make_branch('branch')
 
68
        checkout = branch.create_checkout('checkout')
 
69
        self.run_bzr('reconfigure --lightweight-checkout checkout')
 
70
 
 
71
    def test_standalone_to_use_shared(self):
 
72
        self.build_tree(['repo/'])
 
73
        tree = self.make_branch_and_tree('repo/tree')
 
74
        repo = self.make_repository('repo', shared=True)
 
75
        self.run_bzr('reconfigure --use-shared', working_dir='repo/tree')
 
76
        tree = workingtree.WorkingTree.open('repo/tree')
 
77
        self.assertNotEqual(tree.bzrdir.root_transport.base,
 
78
            tree.branch.repository.bzrdir.root_transport.base)
 
79
 
 
80
    def test_use_shared_to_standalone(self):
 
81
        repo = self.make_repository('repo', shared=True)
 
82
        branch = bzrdir.BzrDir.create_branch_convenience('repo/tree')
 
83
        self.assertNotEqual(branch.bzrdir.root_transport.base,
 
84
            branch.repository.bzrdir.root_transport.base)
 
85
        self.run_bzr('reconfigure --standalone', working_dir='repo/tree')
 
86
        tree = workingtree.WorkingTree.open('repo/tree')
 
87
        self.assertEqual(tree.bzrdir.root_transport.base,
 
88
            tree.branch.repository.bzrdir.root_transport.base)