~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: mbp at sourcefrog
  • Date: 2005-03-24 00:44:18 UTC
  • Revision ID: mbp@sourcefrog.net-20050324004418-b4a050f656c07f5f
show space usage for various stores in the info command

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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_lightweight_checkout_to_tree(self):
62
 
        branch = self.make_branch('branch')
63
 
        checkout = branch.create_checkout('checkout', lightweight=True)
64
 
        self.run_bzr('reconfigure --tree checkout')
65
 
 
66
 
    def test_no_args(self):
67
 
        branch = self.make_branch('branch')
68
 
        self.run_bzr_error(['No target configuration specified'],
69
 
                           'reconfigure', working_dir='branch')
70
 
 
71
 
    def test_checkout_to_lightweight_checkout(self):
72
 
        branch = self.make_branch('branch')
73
 
        checkout = branch.create_checkout('checkout')
74
 
        self.run_bzr('reconfigure --lightweight-checkout checkout')
75
 
 
76
 
    def test_standalone_to_use_shared(self):
77
 
        self.build_tree(['repo/'])
78
 
        tree = self.make_branch_and_tree('repo/tree')
79
 
        repo = self.make_repository('repo', shared=True)
80
 
        self.run_bzr('reconfigure --use-shared', working_dir='repo/tree')
81
 
        tree = workingtree.WorkingTree.open('repo/tree')
82
 
        self.assertNotEqual(tree.bzrdir.root_transport.base,
83
 
            tree.branch.repository.bzrdir.root_transport.base)
84
 
 
85
 
    def test_use_shared_to_standalone(self):
86
 
        repo = self.make_repository('repo', shared=True)
87
 
        branch = bzrdir.BzrDir.create_branch_convenience('repo/tree')
88
 
        self.assertNotEqual(branch.bzrdir.root_transport.base,
89
 
            branch.repository.bzrdir.root_transport.base)
90
 
        self.run_bzr('reconfigure --standalone', working_dir='repo/tree')
91
 
        tree = workingtree.WorkingTree.open('repo/tree')
92
 
        self.assertEqual(tree.bzrdir.root_transport.base,
93
 
            tree.branch.repository.bzrdir.root_transport.base)
94
 
 
95
 
    def test_make_with_trees(self):
96
 
        repo = self.make_repository('repo', shared=True)
97
 
        repo.set_make_working_trees(False)
98
 
        self.run_bzr('reconfigure --with-trees', working_dir='repo')
99
 
        self.assertIs(True, repo.make_working_trees())
100
 
 
101
 
    def test_make_with_trees_already_trees(self):
102
 
        repo = self.make_repository('repo', shared=True)
103
 
        repo.set_make_working_trees(True)
104
 
        self.run_bzr_error([" already creates working trees"],
105
 
                            'reconfigure --with-trees repo')
106
 
 
107
 
    def test_make_without_trees(self):
108
 
        repo = self.make_repository('repo', shared=True)
109
 
        repo.set_make_working_trees(True)
110
 
        self.run_bzr('reconfigure --with-no-trees', working_dir='repo')
111
 
        self.assertIs(False, repo.make_working_trees())
112
 
 
113
 
    def test_make_without_trees_already_no_trees(self):
114
 
        repo = self.make_repository('repo', shared=True)
115
 
        repo.set_make_working_trees(False)
116
 
        self.run_bzr_error([" already doesn't create working trees"],
117
 
                            'reconfigure --with-no-trees repo')
118
 
 
119
 
    def test_make_with_trees_nonshared_repo(self):
120
 
        branch = self.make_branch('branch')
121
 
        self.run_bzr_error(
122
 
            ["Requested reconfiguration of '.*' is not supported"],
123
 
            'reconfigure --with-trees branch')
124
 
 
125
 
    def test_make_without_trees_leaves_tree_alone(self):
126
 
        repo = self.make_repository('repo', shared=True)
127
 
        branch = bzrdir.BzrDir.create_branch_convenience('repo/branch')
128
 
        tree = workingtree.WorkingTree.open('repo/branch')
129
 
        self.build_tree(['repo/branch/foo'])
130
 
        tree.add('foo')
131
 
        self.run_bzr('reconfigure --with-no-trees --force',
132
 
            working_dir='repo/branch')
133
 
        self.failUnlessExists('repo/branch/foo')
134
 
        tree = workingtree.WorkingTree.open('repo/branch')
135
 
 
136
 
    def test_shared_format_to_standalone(self, format=None):
137
 
        repo = self.make_repository('repo', shared=True, format=format)
138
 
        branch = bzrdir.BzrDir.create_branch_convenience('repo/tree')
139
 
        self.assertNotEqual(branch.bzrdir.root_transport.base,
140
 
            branch.repository.bzrdir.root_transport.base)
141
 
        tree = workingtree.WorkingTree.open('repo/tree')
142
 
        self.build_tree_contents([('repo/tree/file', 'foo\n')]);
143
 
        tree.add(['file'])
144
 
        tree.commit('added file')
145
 
        self.run_bzr('reconfigure --standalone', working_dir='repo/tree')
146
 
        tree = workingtree.WorkingTree.open('repo/tree')
147
 
        self.build_tree_contents([('repo/tree/file', 'bar\n')]);
148
 
        self.check_file_contents('repo/tree/file', 'bar\n')
149
 
        self.run_bzr('revert', working_dir='repo/tree')
150
 
        self.check_file_contents('repo/tree/file', 'foo\n')
151
 
        self.assertEqual(tree.bzrdir.root_transport.base,
152
 
            tree.branch.repository.bzrdir.root_transport.base)
153
 
 
154
 
    def test_shared_knit_to_standalone(self):
155
 
        self.test_shared_format_to_standalone('knit')
156
 
 
157
 
    def test_shared_pack092_to_standalone(self):
158
 
        self.test_shared_format_to_standalone('pack-0.92')
159
 
 
160
 
    def test_shared_rich_root_pack_to_standalone(self):
161
 
        self.test_shared_format_to_standalone('rich-root-pack')
162
 
 
163
 
    def test_lightweight_format_checkout_to_tree(self, format=None):
164
 
        branch = self.make_branch('branch', format=format)
165
 
        checkout = branch.create_checkout('checkout', lightweight=True)
166
 
        tree = workingtree.WorkingTree.open('checkout')
167
 
        self.build_tree_contents([('checkout/file', 'foo\n')]);
168
 
        tree.add(['file'])
169
 
        tree.commit('added file')
170
 
        self.run_bzr('reconfigure --tree', working_dir='checkout')
171
 
        tree = workingtree.WorkingTree.open('checkout')
172
 
        self.build_tree_contents([('checkout/file', 'bar\n')]);
173
 
        self.check_file_contents('checkout/file', 'bar\n')
174
 
        self.run_bzr('revert', working_dir='checkout')
175
 
        self.check_file_contents('checkout/file', 'foo\n')
176
 
 
177
 
    def test_lightweight_knit_checkout_to_tree(self, format=None):
178
 
        self.test_lightweight_format_checkout_to_tree('knit')
179
 
 
180
 
    def test_lightweight_pack092_checkout_to_tree(self, format=None):
181
 
        self.test_lightweight_format_checkout_to_tree('pack-0.92')
182
 
 
183
 
    def test_lightweight_rich_root_pack_checkout_to_tree(self, format=None):
184
 
        self.test_lightweight_format_checkout_to_tree('rich-root-pack')