6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2007-2012, 2016 Canonical Ltd
|
2796.2.5
by Aaron Bentley
Implement reconfigure command |
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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2796.2.5
by Aaron Bentley
Implement reconfigure command |
16 |
|
17 |
from bzrlib import ( |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
18 |
controldir, |
2796.2.5
by Aaron Bentley
Implement reconfigure command |
19 |
errors, |
20 |
tests, |
|
21 |
workingtree, |
|
22 |
)
|
|
6123.8.1
by Martin von Gagern
Expose problems with multiple reconfigure requests. |
23 |
from bzrlib.tests.script import TestCaseWithTransportAndScript |
24 |
||
25 |
||
26 |
class TestReconfigure(TestCaseWithTransportAndScript): |
|
2796.2.5
by Aaron Bentley
Implement reconfigure command |
27 |
|
2796.2.15
by Aaron Bentley
More updates from review |
28 |
def test_no_type(self): |
29 |
branch = self.make_branch('branch') |
|
30 |
self.run_bzr_error(['No target configuration specified'], |
|
31 |
'reconfigure branch') |
|
32 |
||
2796.2.5
by Aaron Bentley
Implement reconfigure command |
33 |
def test_branch_to_tree(self): |
34 |
branch = self.make_branch('branch') |
|
35 |
self.run_bzr('reconfigure --tree branch') |
|
36 |
tree = workingtree.WorkingTree.open('branch') |
|
37 |
||
38 |
def test_tree_to_branch(self): |
|
39 |
tree = self.make_branch_and_tree('tree') |
|
40 |
self.run_bzr('reconfigure --branch tree') |
|
41 |
self.assertRaises(errors.NoWorkingTree, |
|
42 |
workingtree.WorkingTree.open, 'tree') |
|
43 |
||
44 |
def test_branch_to_specified_checkout(self): |
|
45 |
branch = self.make_branch('branch') |
|
46 |
parent = self.make_branch('parent') |
|
47 |
self.run_bzr('reconfigure branch --checkout --bind-to parent') |
|
48 |
||
49 |
def test_force(self): |
|
50 |
tree = self.make_branch_and_tree('tree') |
|
51 |
self.build_tree(['tree/file']) |
|
52 |
tree.add('file') |
|
53 |
self.run_bzr_error(['Working tree ".*" has uncommitted changes'], |
|
54 |
'reconfigure --branch tree') |
|
55 |
self.run_bzr('reconfigure --force --branch tree') |
|
56 |
||
2796.2.9
by Aaron Bentley
Ensure conversion from lightweight checkout works |
57 |
def test_lightweight_checkout_to_checkout(self): |
58 |
branch = self.make_branch('branch') |
|
59 |
checkout = branch.create_checkout('checkout', lightweight=True) |
|
60 |
self.run_bzr('reconfigure --checkout checkout') |
|
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
61 |
|
4297.4.4
by Martin von Gagern
Testcase exposing bug when creating a repository for a lightweight branch. |
62 |
def test_lightweight_checkout_to_tree(self): |
63 |
branch = self.make_branch('branch') |
|
64 |
checkout = branch.create_checkout('checkout', lightweight=True) |
|
65 |
self.run_bzr('reconfigure --tree checkout') |
|
66 |
||
2846.1.1
by Rob Weir
add blackbox test for 'bzr reconfigure', which now fails. |
67 |
def test_no_args(self): |
68 |
branch = self.make_branch('branch') |
|
2846.1.3
by Rob Weir
add check of error text. |
69 |
self.run_bzr_error(['No target configuration specified'], |
70 |
'reconfigure', working_dir='branch') |
|
2796.2.22
by Aaron Bentley
Tweak from review |
71 |
|
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
72 |
def test_checkout_to_lightweight_checkout(self): |
73 |
branch = self.make_branch('branch') |
|
74 |
checkout = branch.create_checkout('checkout') |
|
75 |
self.run_bzr('reconfigure --lightweight-checkout checkout') |
|
3311.2.5
by Aaron Bentley
Implement reconfigure --standalone and --sharing |
76 |
|
3311.2.6
by Aaron Bentley
rename 'sharing' to 'use-shared' |
77 |
def test_standalone_to_use_shared(self): |
3311.2.5
by Aaron Bentley
Implement reconfigure --standalone and --sharing |
78 |
self.build_tree(['repo/']) |
79 |
tree = self.make_branch_and_tree('repo/tree') |
|
80 |
repo = self.make_repository('repo', shared=True) |
|
3311.2.6
by Aaron Bentley
rename 'sharing' to 'use-shared' |
81 |
self.run_bzr('reconfigure --use-shared', working_dir='repo/tree') |
3311.2.5
by Aaron Bentley
Implement reconfigure --standalone and --sharing |
82 |
tree = workingtree.WorkingTree.open('repo/tree') |
83 |
self.assertNotEqual(tree.bzrdir.root_transport.base, |
|
84 |
tree.branch.repository.bzrdir.root_transport.base) |
|
85 |
||
3311.2.6
by Aaron Bentley
rename 'sharing' to 'use-shared' |
86 |
def test_use_shared_to_standalone(self): |
3311.2.5
by Aaron Bentley
Implement reconfigure --standalone and --sharing |
87 |
repo = self.make_repository('repo', shared=True) |
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
88 |
branch = controldir.ControlDir.create_branch_convenience('repo/tree') |
3311.2.5
by Aaron Bentley
Implement reconfigure --standalone and --sharing |
89 |
self.assertNotEqual(branch.bzrdir.root_transport.base, |
90 |
branch.repository.bzrdir.root_transport.base) |
|
91 |
self.run_bzr('reconfigure --standalone', working_dir='repo/tree') |
|
92 |
tree = workingtree.WorkingTree.open('repo/tree') |
|
93 |
self.assertEqual(tree.bzrdir.root_transport.base, |
|
94 |
tree.branch.repository.bzrdir.root_transport.base) |
|
3921.4.6
by Matthew Fuller
Add blackbox tests for reconfigure {--with-trees,--with-no-trees}. |
95 |
|
96 |
def test_make_with_trees(self): |
|
97 |
repo = self.make_repository('repo', shared=True) |
|
98 |
repo.set_make_working_trees(False) |
|
99 |
self.run_bzr('reconfigure --with-trees', working_dir='repo') |
|
100 |
self.assertIs(True, repo.make_working_trees()) |
|
101 |
||
102 |
def test_make_with_trees_already_trees(self): |
|
103 |
repo = self.make_repository('repo', shared=True) |
|
104 |
repo.set_make_working_trees(True) |
|
105 |
self.run_bzr_error([" already creates working trees"], |
|
106 |
'reconfigure --with-trees repo') |
|
107 |
||
108 |
def test_make_without_trees(self): |
|
109 |
repo = self.make_repository('repo', shared=True) |
|
110 |
repo.set_make_working_trees(True) |
|
111 |
self.run_bzr('reconfigure --with-no-trees', working_dir='repo') |
|
112 |
self.assertIs(False, repo.make_working_trees()) |
|
113 |
||
114 |
def test_make_without_trees_already_no_trees(self): |
|
115 |
repo = self.make_repository('repo', shared=True) |
|
116 |
repo.set_make_working_trees(False) |
|
117 |
self.run_bzr_error([" already doesn't create working trees"], |
|
118 |
'reconfigure --with-no-trees repo') |
|
3921.4.7
by Matthew Fuller
Add a blackbox test for the expected failure trying to change --trees |
119 |
|
120 |
def test_make_with_trees_nonshared_repo(self): |
|
121 |
branch = self.make_branch('branch') |
|
122 |
self.run_bzr_error( |
|
123 |
["Requested reconfiguration of '.*' is not supported"], |
|
124 |
'reconfigure --with-trees branch') |
|
3921.4.11
by Matthew Fuller
Add a test that --with-no-trees doesn't touch a branch's existing WT. |
125 |
|
126 |
def test_make_without_trees_leaves_tree_alone(self): |
|
127 |
repo = self.make_repository('repo', shared=True) |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
128 |
branch = controldir.ControlDir.create_branch_convenience('repo/branch') |
3983.3.3
by Marius Kruger
refactor test_make_without_trees_leaves_tree_alone a little |
129 |
tree = workingtree.WorkingTree.open('repo/branch') |
3921.4.11
by Matthew Fuller
Add a test that --with-no-trees doesn't touch a branch's existing WT. |
130 |
self.build_tree(['repo/branch/foo']) |
131 |
tree.add('foo') |
|
3983.3.3
by Marius Kruger
refactor test_make_without_trees_leaves_tree_alone a little |
132 |
self.run_bzr('reconfigure --with-no-trees --force', |
3921.4.11
by Matthew Fuller
Add a test that --with-no-trees doesn't touch a branch's existing WT. |
133 |
working_dir='repo/branch') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
134 |
self.assertPathExists('repo/branch/foo') |
3983.3.3
by Marius Kruger
refactor test_make_without_trees_leaves_tree_alone a little |
135 |
tree = workingtree.WorkingTree.open('repo/branch') |
4297.4.1
by Martin von Gagern
Added blackbox tests to expose LP bug #248932. |
136 |
|
137 |
def test_shared_format_to_standalone(self, format=None): |
|
138 |
repo = self.make_repository('repo', shared=True, format=format) |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
139 |
branch = controldir.ControlDir.create_branch_convenience('repo/tree') |
4297.4.1
by Martin von Gagern
Added blackbox tests to expose LP bug #248932. |
140 |
self.assertNotEqual(branch.bzrdir.root_transport.base, |
141 |
branch.repository.bzrdir.root_transport.base) |
|
142 |
tree = workingtree.WorkingTree.open('repo/tree') |
|
143 |
self.build_tree_contents([('repo/tree/file', 'foo\n')]); |
|
144 |
tree.add(['file']) |
|
145 |
tree.commit('added file') |
|
146 |
self.run_bzr('reconfigure --standalone', working_dir='repo/tree') |
|
147 |
tree = workingtree.WorkingTree.open('repo/tree') |
|
148 |
self.build_tree_contents([('repo/tree/file', 'bar\n')]); |
|
149 |
self.check_file_contents('repo/tree/file', 'bar\n') |
|
150 |
self.run_bzr('revert', working_dir='repo/tree') |
|
151 |
self.check_file_contents('repo/tree/file', 'foo\n') |
|
152 |
self.assertEqual(tree.bzrdir.root_transport.base, |
|
153 |
tree.branch.repository.bzrdir.root_transport.base) |
|
154 |
||
155 |
def test_shared_knit_to_standalone(self): |
|
156 |
self.test_shared_format_to_standalone('knit') |
|
157 |
||
158 |
def test_shared_pack092_to_standalone(self): |
|
159 |
self.test_shared_format_to_standalone('pack-0.92') |
|
160 |
||
161 |
def test_shared_rich_root_pack_to_standalone(self): |
|
162 |
self.test_shared_format_to_standalone('rich-root-pack') |
|
4297.4.4
by Martin von Gagern
Testcase exposing bug when creating a repository for a lightweight branch. |
163 |
|
164 |
def test_lightweight_format_checkout_to_tree(self, format=None): |
|
165 |
branch = self.make_branch('branch', format=format) |
|
166 |
checkout = branch.create_checkout('checkout', lightweight=True) |
|
167 |
tree = workingtree.WorkingTree.open('checkout') |
|
168 |
self.build_tree_contents([('checkout/file', 'foo\n')]); |
|
169 |
tree.add(['file']) |
|
170 |
tree.commit('added file') |
|
171 |
self.run_bzr('reconfigure --tree', working_dir='checkout') |
|
172 |
tree = workingtree.WorkingTree.open('checkout') |
|
173 |
self.build_tree_contents([('checkout/file', 'bar\n')]); |
|
174 |
self.check_file_contents('checkout/file', 'bar\n') |
|
175 |
self.run_bzr('revert', working_dir='checkout') |
|
176 |
self.check_file_contents('checkout/file', 'foo\n') |
|
177 |
||
6123.8.1
by Martin von Gagern
Expose problems with multiple reconfigure requests. |
178 |
def test_lightweight_knit_checkout_to_tree(self): |
4297.4.4
by Martin von Gagern
Testcase exposing bug when creating a repository for a lightweight branch. |
179 |
self.test_lightweight_format_checkout_to_tree('knit') |
180 |
||
6123.8.1
by Martin von Gagern
Expose problems with multiple reconfigure requests. |
181 |
def test_lightweight_pack092_checkout_to_tree(self): |
4297.4.4
by Martin von Gagern
Testcase exposing bug when creating a repository for a lightweight branch. |
182 |
self.test_lightweight_format_checkout_to_tree('pack-0.92') |
183 |
||
6123.8.1
by Martin von Gagern
Expose problems with multiple reconfigure requests. |
184 |
def test_lightweight_rich_root_pack_checkout_to_tree(self): |
4297.4.4
by Martin von Gagern
Testcase exposing bug when creating a repository for a lightweight branch. |
185 |
self.test_lightweight_format_checkout_to_tree('rich-root-pack') |
4509.3.1
by Martin Pool
Initial failing test for 'reconfigure --stacked-on' |
186 |
|
6123.8.1
by Martin von Gagern
Expose problems with multiple reconfigure requests. |
187 |
def test_branch_and_use_shared(self): |
188 |
self.run_script("""\ |
|
189 |
$ bzr init -q branch
|
|
190 |
$ echo foo > branch/foo
|
|
191 |
$ bzr add -q branch/foo
|
|
192 |
$ bzr commit -q -m msg branch
|
|
193 |
$ bzr init-repo -q .
|
|
194 |
$ bzr reconfigure --branch --use-shared branch
|
|
195 |
$ bzr info branch
|
|
196 |
Repository branch (format: ...)
|
|
197 |
Location:
|
|
198 |
shared repository: .
|
|
199 |
repository branch: branch
|
|
200 |
""") |
|
201 |
||
202 |
def test_use_shared_and_branch(self): |
|
203 |
self.run_script("""\ |
|
204 |
$ bzr init -q branch
|
|
205 |
$ echo foo > branch/foo
|
|
206 |
$ bzr add -q branch/foo
|
|
207 |
$ bzr commit -q -m msg branch
|
|
208 |
$ bzr init-repo -q .
|
|
209 |
$ bzr reconfigure --use-shared --branch branch
|
|
210 |
$ bzr info branch
|
|
211 |
Repository branch (format: ...)
|
|
212 |
Location:
|
|
213 |
shared repository: .
|
|
214 |
repository branch: branch
|
|
215 |
""") |
|
216 |
||
4509.3.1
by Martin Pool
Initial failing test for 'reconfigure --stacked-on' |
217 |
|
218 |
class TestReconfigureStacking(tests.TestCaseWithTransport): |
|
219 |
||
4509.3.3
by Martin Pool
Add reconfigure --unstacked command |
220 |
def test_reconfigure_stacking(self): |
4509.3.14
by Martin Pool
More realistic and now failing test_reconfigure_stacking |
221 |
"""Test a fairly realistic scenario for stacking:
|
222 |
||
223 |
* make a branch with some history
|
|
224 |
* branch it
|
|
225 |
* make the second branch stacked on the first
|
|
226 |
* commit in the second
|
|
227 |
* then make the second unstacked, so it has to fill in history from
|
|
228 |
the original fallback lying underneath its original content
|
|
229 |
||
5243.1.2
by Martin
Point launchpad links in comments at production server rather than edge |
230 |
See discussion in <https://bugs.launchpad.net/bzr/+bug/391411>
|
4509.3.14
by Martin Pool
More realistic and now failing test_reconfigure_stacking |
231 |
"""
|
4509.3.29
by Martin Pool
Correction to comments |
232 |
# there are also per_branch tests that exercise remote operation etc
|
4509.3.14
by Martin Pool
More realistic and now failing test_reconfigure_stacking |
233 |
tree_1 = self.make_branch_and_tree('b1', format='2a') |
234 |
self.build_tree(['b1/foo']) |
|
235 |
tree_1.add(['foo']) |
|
236 |
tree_1.commit('add foo') |
|
237 |
branch_1 = tree_1.branch |
|
238 |
# now branch and commit again
|
|
239 |
bzrdir_2 = tree_1.bzrdir.sprout('b2') |
|
240 |
tree_2 = bzrdir_2.open_workingtree() |
|
241 |
branch_2 = tree_2.branch |
|
242 |
# now reconfigure to be stacked
|
|
243 |
out, err = self.run_bzr('reconfigure --stacked-on b1 b2') |
|
6404.6.1
by Vincent Ladeuil
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. |
244 |
self.assertContainsRe(out, '^.*/b2/ is now stacked on ../b1\n$') |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
245 |
self.assertEqual('', err) |
4509.3.31
by Martin Pool
Additional test for stacking from absolute URL |
246 |
# can also give the absolute URL of the branch, and it gets stored
|
247 |
# as a relative path if possible
|
|
248 |
out, err = self.run_bzr('reconfigure --stacked-on %s b2' |
|
6404.6.1
by Vincent Ladeuil
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. |
249 |
% (self.get_url('b1'),)) |
250 |
self.assertContainsRe(out, '^.*/b2/ is now stacked on ../b1\n$') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
251 |
self.assertEqual('', err) |
6404.6.6
by Vincent Ladeuil
Use idioms coherently and add comments to make their purpose clearer. |
252 |
# Refresh the branch as 'reconfigure' modified it
|
253 |
branch_2 = branch_2.bzrdir.open_branch() |
|
4509.3.2
by Martin Pool
Very basic support for 'reconfigure --stacked-on' |
254 |
# It should be given a relative URL to the destination, if possible,
|
255 |
# because that's most likely to work across different transports
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
256 |
self.assertEqual('../b1', branch_2.get_stacked_on_url()) |
4509.3.14
by Martin Pool
More realistic and now failing test_reconfigure_stacking |
257 |
# commit, and it should be stored into b2's repo
|
258 |
self.build_tree_contents([('foo', 'new foo')]) |
|
259 |
tree_2.commit('update foo') |
|
4509.3.3
by Martin Pool
Add reconfigure --unstacked command |
260 |
# Now turn it off again
|
4509.3.14
by Martin Pool
More realistic and now failing test_reconfigure_stacking |
261 |
out, err = self.run_bzr('reconfigure --unstacked b2') |
4509.3.3
by Martin Pool
Add reconfigure --unstacked command |
262 |
self.assertContainsRe(out, |
4509.3.14
by Martin Pool
More realistic and now failing test_reconfigure_stacking |
263 |
'^.*/b2/ is now not stacked\n$') |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
264 |
self.assertEqual('', err) |
6404.6.6
by Vincent Ladeuil
Use idioms coherently and add comments to make their purpose clearer. |
265 |
# Refresh the branch as 'reconfigure' modified it
|
266 |
branch_2 = branch_2.bzrdir.open_branch() |
|
267 |
self.assertRaises(errors.NotStacked, branch_2.get_stacked_on_url) |
|
4509.3.1
by Martin Pool
Initial failing test for 'reconfigure --stacked-on' |
268 |
|
4509.3.2
by Martin Pool
Very basic support for 'reconfigure --stacked-on' |
269 |
# XXX: Needs a test for reconfiguring stacking and shape at the same time;
|
4509.3.29
by Martin Pool
Correction to comments |
270 |
# no branch at location; stacked-on is not a branch; quiet mode.
|
4509.3.1
by Martin Pool
Initial failing test for 'reconfigure --stacked-on' |
271 |
# -- mbp 20090706
|