1
# Copyright (C) 2007 Canonical Ltd
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.
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.
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
25
class TestReconfigure(tests.TestCaseWithTransport):
27
def test_no_type(self):
28
branch = self.make_branch('branch')
29
self.run_bzr_error(['No target configuration specified'],
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')
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')
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')
49
tree = self.make_branch_and_tree('tree')
50
self.build_tree(['tree/file'])
52
self.run_bzr_error(['Working tree ".*" has uncommitted changes'],
53
'reconfigure --branch tree')
54
self.run_bzr('reconfigure --force --branch tree')
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')
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')
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')
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)
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)
90
def test_make_with_trees(self):
91
repo = self.make_repository('repo', shared=True)
92
repo.set_make_working_trees(False)
93
self.run_bzr('reconfigure --with-trees', working_dir='repo')
94
self.assertIs(True, repo.make_working_trees())
96
def test_make_with_trees_already_trees(self):
97
repo = self.make_repository('repo', shared=True)
98
repo.set_make_working_trees(True)
99
self.run_bzr_error([" already creates working trees"],
100
'reconfigure --with-trees repo')
102
def test_make_without_trees(self):
103
repo = self.make_repository('repo', shared=True)
104
repo.set_make_working_trees(True)
105
self.run_bzr('reconfigure --with-no-trees', working_dir='repo')
106
self.assertIs(False, repo.make_working_trees())
108
def test_make_without_trees_already_no_trees(self):
109
repo = self.make_repository('repo', shared=True)
110
repo.set_make_working_trees(False)
111
self.run_bzr_error([" already doesn't create working trees"],
112
'reconfigure --with-no-trees repo')
114
def test_make_with_trees_nonshared_repo(self):
115
branch = self.make_branch('branch')
117
["Requested reconfiguration of '.*' is not supported"],
118
'reconfigure --with-trees branch')
120
def test_make_without_trees_leaves_tree_alone(self):
121
repo = self.make_repository('repo', shared=True)
122
branch = bzrdir.BzrDir.create_branch_convenience('repo/branch')
123
tree = workingtree.WorkingTree.open('repo/branch')
124
self.build_tree(['repo/branch/foo'])
126
self.run_bzr('reconfigure --with-no-trees --force',
127
working_dir='repo/branch')
128
self.failUnlessExists('repo/branch/foo')
129
tree = workingtree.WorkingTree.open('repo/branch')