~bzr-pqm/bzr/bzr.dev

2796.2.5 by Aaron Bentley
Implement reconfigure command
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 (
3311.2.5 by Aaron Bentley
Implement reconfigure --standalone and --sharing
18
    bzrdir,
2796.2.5 by Aaron Bentley
Implement reconfigure command
19
    errors,
20
    tests,
21
    workingtree,
22
    )
23
24
2796.2.17 by Aaron Bentley
Update docs from review
25
class TestReconfigure(tests.TestCaseWithTransport):
2796.2.5 by Aaron Bentley
Implement reconfigure command
26
2796.2.15 by Aaron Bentley
More updates from review
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
2796.2.5 by Aaron Bentley
Implement reconfigure command
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
2796.2.9 by Aaron Bentley
Ensure conversion from lightweight checkout works
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')
2796.2.19 by Aaron Bentley
Support reconfigure --lightweight-checkout
60
2846.1.1 by Rob Weir
add blackbox test for 'bzr reconfigure', which now fails.
61
    def test_no_args(self):
62
        branch = self.make_branch('branch')
2846.1.3 by Rob Weir
add check of error text.
63
        self.run_bzr_error(['No target configuration specified'],
64
                           'reconfigure', working_dir='branch')
2796.2.22 by Aaron Bentley
Tweak from review
65
2796.2.19 by Aaron Bentley
Support reconfigure --lightweight-checkout
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')
3311.2.5 by Aaron Bentley
Implement reconfigure --standalone and --sharing
70
3311.2.6 by Aaron Bentley
rename 'sharing' to 'use-shared'
71
    def test_standalone_to_use_shared(self):
3311.2.5 by Aaron Bentley
Implement reconfigure --standalone and --sharing
72
        self.build_tree(['repo/'])
73
        tree = self.make_branch_and_tree('repo/tree')
74
        repo = self.make_repository('repo', shared=True)
3311.2.6 by Aaron Bentley
rename 'sharing' to 'use-shared'
75
        self.run_bzr('reconfigure --use-shared', working_dir='repo/tree')
3311.2.5 by Aaron Bentley
Implement reconfigure --standalone and --sharing
76
        tree = workingtree.WorkingTree.open('repo/tree')
77
        self.assertNotEqual(tree.bzrdir.root_transport.base,
78
            tree.branch.repository.bzrdir.root_transport.base)
79
3311.2.6 by Aaron Bentley
rename 'sharing' to 'use-shared'
80
    def test_use_shared_to_standalone(self):
3311.2.5 by Aaron Bentley
Implement reconfigure --standalone and --sharing
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)