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. |
1 |
# Copyright (C) 2007, 2008, 2009, 2011, 2012 Canonical Ltd
|
2796.2.1
by Aaron Bentley
Begin work on 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.1
by Aaron Bentley
Begin work on reconfigure command |
16 |
|
17 |
from bzrlib import ( |
|
18 |
branch as _mod_branch, |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
19 |
controldir, |
2796.2.1
by Aaron Bentley
Begin work on reconfigure command |
20 |
errors, |
21 |
reconfigure, |
|
2796.2.25
by Aaron Bentley
Avoid destroying shared repositories |
22 |
repository, |
2796.2.1
by Aaron Bentley
Begin work on reconfigure command |
23 |
tests, |
6341.1.6
by Jelmer Vernooij
Fix test. |
24 |
vf_repository, |
2796.2.1
by Aaron Bentley
Begin work on reconfigure command |
25 |
workingtree, |
26 |
)
|
|
27 |
||
28 |
||
29 |
class TestReconfigure(tests.TestCaseWithTransport): |
|
30 |
||
31 |
def test_tree_to_branch(self): |
|
32 |
tree = self.make_branch_and_tree('tree') |
|
33 |
reconfiguration = reconfigure.Reconfigure.to_branch(tree.bzrdir) |
|
34 |
reconfiguration.apply() |
|
35 |
self.assertRaises(errors.NoWorkingTree, workingtree.WorkingTree.open, |
|
36 |
'tree') |
|
37 |
||
38 |
def test_modified_tree_to_branch(self): |
|
39 |
tree = self.make_branch_and_tree('tree') |
|
40 |
self.build_tree(['tree/file']) |
|
41 |
tree.add('file') |
|
42 |
reconfiguration = reconfigure.Reconfigure.to_branch(tree.bzrdir) |
|
43 |
self.assertRaises(errors.UncommittedChanges, reconfiguration.apply) |
|
44 |
reconfiguration.apply(force=True) |
|
45 |
self.assertRaises(errors.NoWorkingTree, workingtree.WorkingTree.open, |
|
46 |
'tree') |
|
47 |
||
4721.3.2
by Vincent Ladeuil
Simplify mutable_tree.has_changes() and update call sites. |
48 |
def test_tree_with_pending_merge_to_branch(self): |
49 |
tree = self.make_branch_and_tree('tree') |
|
5954.2.4
by Aaron Bentley
Fix broken tests. |
50 |
tree.commit('unchanged') |
4721.3.2
by Vincent Ladeuil
Simplify mutable_tree.has_changes() and update call sites. |
51 |
other_tree = tree.bzrdir.sprout('other').open_workingtree() |
5954.3.2
by Vincent Ladeuil
Nitpicks. |
52 |
other_tree.commit('mergeable commit') |
4721.3.2
by Vincent Ladeuil
Simplify mutable_tree.has_changes() and update call sites. |
53 |
tree.merge_from_branch(other_tree.branch) |
54 |
reconfiguration = reconfigure.Reconfigure.to_branch(tree.bzrdir) |
|
55 |
self.assertRaises(errors.UncommittedChanges, reconfiguration.apply) |
|
56 |
reconfiguration.apply(force=True) |
|
57 |
self.assertRaises(errors.NoWorkingTree, workingtree.WorkingTree.open, |
|
58 |
'tree') |
|
59 |
||
2796.2.1
by Aaron Bentley
Begin work on reconfigure command |
60 |
def test_branch_to_branch(self): |
61 |
branch = self.make_branch('branch') |
|
62 |
self.assertRaises(errors.AlreadyBranch, |
|
63 |
reconfigure.Reconfigure.to_branch, branch.bzrdir) |
|
64 |
||
65 |
def test_repo_to_branch(self): |
|
66 |
repo = self.make_repository('repo') |
|
2796.2.23
by Aaron Bentley
Add support for reconfiguring repositories into branches or trees |
67 |
reconfiguration = reconfigure.Reconfigure.to_branch(repo.bzrdir) |
68 |
reconfiguration.apply() |
|
2796.2.1
by Aaron Bentley
Begin work on reconfigure command |
69 |
|
70 |
def test_checkout_to_branch(self): |
|
71 |
branch = self.make_branch('branch') |
|
72 |
checkout = branch.create_checkout('checkout') |
|
73 |
reconfiguration = reconfigure.Reconfigure.to_branch(checkout.bzrdir) |
|
74 |
reconfiguration.apply() |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
75 |
reconfigured = controldir.ControlDir.open('checkout').open_branch() |
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. |
76 |
self.assertIs(None, reconfigured.get_bound_location()) |
2796.2.2
by Aaron Bentley
Refuse to turn lightweight checkouts into branches |
77 |
|
2796.2.32
by Aaron Bentley
Preserve tags converting from lightweight checkouts |
78 |
def prepare_lightweight_checkout_to_branch(self): |
79 |
branch = self.make_branch('branch') |
|
80 |
checkout = branch.create_checkout('checkout', lightweight=True) |
|
81 |
checkout.commit('first commit', rev_id='rev1') |
|
82 |
reconfiguration = reconfigure.Reconfigure.to_branch(checkout.bzrdir) |
|
83 |
return reconfiguration, checkout |
|
84 |
||
2796.2.2
by Aaron Bentley
Refuse to turn lightweight checkouts into branches |
85 |
def test_lightweight_checkout_to_branch(self): |
2796.2.32
by Aaron Bentley
Preserve tags converting from lightweight checkouts |
86 |
reconfiguration, checkout = \ |
87 |
self.prepare_lightweight_checkout_to_branch() |
|
2796.2.7
by Aaron Bentley
Implement converting a lightweight checkout to a branch |
88 |
reconfiguration.apply() |
89 |
checkout_branch = checkout.bzrdir.open_branch() |
|
90 |
self.assertEqual(checkout_branch.bzrdir.root_transport.base, |
|
91 |
checkout.bzrdir.root_transport.base) |
|
2796.2.8
by Aaron Bentley
Ensure conversion from lightweight fetches revisions and sets revision info |
92 |
self.assertEqual('rev1', checkout_branch.last_revision()) |
93 |
repo = checkout.bzrdir.open_repository() |
|
94 |
repo.get_revision('rev1') |
|
2796.2.3
by Aaron Bentley
Implement conversion to tree and checkout |
95 |
|
2796.2.32
by Aaron Bentley
Preserve tags converting from lightweight checkouts |
96 |
def test_lightweight_checkout_to_branch_tags(self): |
97 |
reconfiguration, checkout = \ |
|
98 |
self.prepare_lightweight_checkout_to_branch() |
|
99 |
checkout.branch.tags.set_tag('foo', 'bar') |
|
100 |
reconfiguration.apply() |
|
101 |
checkout_branch = checkout.bzrdir.open_branch() |
|
102 |
self.assertEqual('bar', checkout_branch.tags.lookup_tag('foo')) |
|
103 |
||
2796.2.33
by Aaron Bentley
Add lightweight-checkout-to-checkout tags test |
104 |
def prepare_lightweight_checkout_to_checkout(self): |
105 |
branch = self.make_branch('branch') |
|
106 |
checkout = branch.create_checkout('checkout', lightweight=True) |
|
107 |
reconfiguration = reconfigure.Reconfigure.to_checkout(checkout.bzrdir) |
|
108 |
return reconfiguration, checkout |
|
109 |
||
2796.2.9
by Aaron Bentley
Ensure conversion from lightweight checkout works |
110 |
def test_lightweight_checkout_to_checkout(self): |
2796.2.33
by Aaron Bentley
Add lightweight-checkout-to-checkout tags test |
111 |
reconfiguration, checkout = \ |
112 |
self.prepare_lightweight_checkout_to_checkout() |
|
2796.2.9
by Aaron Bentley
Ensure conversion from lightweight checkout works |
113 |
reconfiguration.apply() |
114 |
checkout_branch = checkout.bzrdir.open_branch() |
|
115 |
self.assertIsNot(checkout_branch.get_bound_location(), None) |
|
116 |
||
2796.2.33
by Aaron Bentley
Add lightweight-checkout-to-checkout tags test |
117 |
def test_lightweight_checkout_to_checkout_tags(self): |
118 |
reconfiguration, checkout = \ |
|
119 |
self.prepare_lightweight_checkout_to_checkout() |
|
120 |
checkout.branch.tags.set_tag('foo', 'bar') |
|
121 |
reconfiguration.apply() |
|
122 |
checkout_branch = checkout.bzrdir.open_branch() |
|
123 |
self.assertEqual('bar', checkout_branch.tags.lookup_tag('foo')) |
|
124 |
||
2796.2.10
by Aaron Bentley
Ensure that shared repositories are used where possible |
125 |
def test_lightweight_conversion_uses_shared_repo(self): |
126 |
parent = self.make_branch('parent') |
|
127 |
shared_repo = self.make_repository('repo', shared=True) |
|
128 |
checkout = parent.create_checkout('repo/checkout', lightweight=True) |
|
129 |
reconfigure.Reconfigure.to_tree(checkout.bzrdir).apply() |
|
130 |
checkout_repo = checkout.bzrdir.open_branch().repository |
|
131 |
self.assertEqual(shared_repo.bzrdir.root_transport.base, |
|
132 |
checkout_repo.bzrdir.root_transport.base) |
|
133 |
||
2796.2.3
by Aaron Bentley
Implement conversion to tree and checkout |
134 |
def test_branch_to_tree(self): |
135 |
branch = self.make_branch('branch') |
|
136 |
reconfiguration=reconfigure.Reconfigure.to_tree(branch.bzrdir) |
|
137 |
reconfiguration.apply() |
|
138 |
branch.bzrdir.open_workingtree() |
|
139 |
||
140 |
def test_tree_to_tree(self): |
|
141 |
tree = self.make_branch_and_tree('tree') |
|
142 |
self.assertRaises(errors.AlreadyTree, reconfigure.Reconfigure.to_tree, |
|
143 |
tree.bzrdir) |
|
144 |
||
145 |
def test_select_bind_location(self): |
|
146 |
branch = self.make_branch('branch') |
|
147 |
reconfiguration = reconfigure.Reconfigure(branch.bzrdir) |
|
148 |
self.assertRaises(errors.NoBindLocation, |
|
149 |
reconfiguration._select_bind_location) |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
150 |
branch.set_parent('http://parent') |
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. |
151 |
reconfiguration = reconfigure.Reconfigure(branch.bzrdir) |
2796.2.3
by Aaron Bentley
Implement conversion to tree and checkout |
152 |
self.assertEqual('http://parent', |
153 |
reconfiguration._select_bind_location()) |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
154 |
branch.set_push_location('sftp://push') |
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. |
155 |
reconfiguration = reconfigure.Reconfigure(branch.bzrdir) |
2796.2.3
by Aaron Bentley
Implement conversion to tree and checkout |
156 |
self.assertEqual('sftp://push', |
157 |
reconfiguration._select_bind_location()) |
|
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. |
158 |
branch.lock_write() |
159 |
try: |
|
160 |
branch.set_bound_location('bzr://foo/old-bound') |
|
161 |
branch.set_bound_location(None) |
|
162 |
finally: |
|
163 |
branch.unlock() |
|
164 |
reconfiguration = reconfigure.Reconfigure(branch.bzrdir) |
|
2796.2.22
by Aaron Bentley
Tweak from review |
165 |
self.assertEqual('bzr://foo/old-bound', |
2796.2.3
by Aaron Bentley
Implement conversion to tree and checkout |
166 |
reconfiguration._select_bind_location()) |
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
167 |
branch.set_bound_location('bzr://foo/cur-bound') |
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. |
168 |
reconfiguration = reconfigure.Reconfigure(branch.bzrdir) |
2796.2.22
by Aaron Bentley
Tweak from review |
169 |
self.assertEqual('bzr://foo/cur-bound', |
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
170 |
reconfiguration._select_bind_location()) |
2796.2.11
by Aaron Bentley
Cleanups |
171 |
reconfiguration.new_bound_location = 'ftp://user-specified' |
172 |
self.assertEqual('ftp://user-specified', |
|
173 |
reconfiguration._select_bind_location()) |
|
2796.2.3
by Aaron Bentley
Implement conversion to tree and checkout |
174 |
|
2796.2.9
by Aaron Bentley
Ensure conversion from lightweight checkout works |
175 |
def test_select_reference_bind_location(self): |
176 |
branch = self.make_branch('branch') |
|
177 |
checkout = branch.create_checkout('checkout', lightweight=True) |
|
178 |
reconfiguration = reconfigure.Reconfigure(checkout.bzrdir) |
|
179 |
self.assertEqual(branch.base, |
|
180 |
reconfiguration._select_bind_location()) |
|
181 |
||
2796.2.3
by Aaron Bentley
Implement conversion to tree and checkout |
182 |
def test_tree_to_checkout(self): |
183 |
# A tree with no related branches and no supplied bind location cannot
|
|
184 |
# become a checkout
|
|
185 |
parent = self.make_branch('parent') |
|
186 |
||
187 |
tree = self.make_branch_and_tree('tree') |
|
188 |
reconfiguration = reconfigure.Reconfigure.to_checkout(tree.bzrdir) |
|
189 |
self.assertRaises(errors.NoBindLocation, reconfiguration.apply) |
|
190 |
# setting a parent allows it to become a checkout
|
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
191 |
tree.branch.set_parent(parent.base) |
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. |
192 |
reconfiguration = reconfigure.Reconfigure.to_checkout(tree.bzrdir) |
2796.2.3
by Aaron Bentley
Implement conversion to tree and checkout |
193 |
reconfiguration.apply() |
194 |
# supplying a location allows it to become a checkout
|
|
195 |
tree2 = self.make_branch_and_tree('tree2') |
|
196 |
reconfiguration = reconfigure.Reconfigure.to_checkout(tree2.bzrdir, |
|
197 |
parent.base) |
|
2796.2.4
by Aaron Bentley
Fix support for reconfiguring to selected bound location |
198 |
reconfiguration.apply() |
2796.2.3
by Aaron Bentley
Implement conversion to tree and checkout |
199 |
|
2796.2.26
by Aaron Bentley
Support converting standalone tree to lightweight checkout |
200 |
def test_tree_to_lightweight_checkout(self): |
201 |
# A tree with no related branches and no supplied bind location cannot
|
|
202 |
# become a checkout
|
|
203 |
parent = self.make_branch('parent') |
|
204 |
||
205 |
tree = self.make_branch_and_tree('tree') |
|
206 |
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
|
207 |
tree.bzrdir) |
|
208 |
self.assertRaises(errors.NoBindLocation, reconfiguration.apply) |
|
209 |
# setting a parent allows it to become a checkout
|
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
210 |
tree.branch.set_parent(parent.base) |
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. |
211 |
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
212 |
tree.bzrdir) |
|
2796.2.26
by Aaron Bentley
Support converting standalone tree to lightweight checkout |
213 |
reconfiguration.apply() |
214 |
# supplying a location allows it to become a checkout
|
|
215 |
tree2 = self.make_branch_and_tree('tree2') |
|
216 |
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
|
217 |
tree2.bzrdir, parent.base) |
|
218 |
reconfiguration.apply() |
|
219 |
||
2796.2.3
by Aaron Bentley
Implement conversion to tree and checkout |
220 |
def test_checkout_to_checkout(self): |
221 |
parent = self.make_branch('parent') |
|
222 |
checkout = parent.create_checkout('checkout') |
|
223 |
self.assertRaises(errors.AlreadyCheckout, |
|
224 |
reconfigure.Reconfigure.to_checkout, checkout.bzrdir) |
|
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
225 |
|
3338.1.2
by Aaron Bentley
Split out tests even further |
226 |
def make_unsynced_checkout(self): |
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
227 |
parent = self.make_branch('parent') |
228 |
checkout = parent.create_checkout('checkout') |
|
229 |
checkout.commit('test', rev_id='new-commit', local=True) |
|
230 |
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
|
231 |
checkout.bzrdir) |
|
3338.1.2
by Aaron Bentley
Split out tests even further |
232 |
return checkout, parent, reconfiguration |
233 |
||
234 |
def test_unsynced_checkout_to_lightweight(self): |
|
235 |
checkout, parent, reconfiguration = self.make_unsynced_checkout() |
|
3338.1.1
by Aaron Bentley
Raise an error when converting a branch to a lightweight checkout loses data |
236 |
self.assertRaises(errors.UnsyncedBranches, reconfiguration.apply) |
3338.1.2
by Aaron Bentley
Split out tests even further |
237 |
|
238 |
def test_synced_checkout_to_lightweight(self): |
|
239 |
checkout, parent, reconfiguration = self.make_unsynced_checkout() |
|
3338.1.1
by Aaron Bentley
Raise an error when converting a branch to a lightweight checkout loses data |
240 |
parent.pull(checkout.branch) |
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
241 |
reconfiguration.apply() |
242 |
wt = checkout.bzrdir.open_workingtree() |
|
243 |
self.assertTrue(parent.repository.has_same_location( |
|
244 |
wt.branch.repository)) |
|
245 |
parent.repository.get_revision('new-commit') |
|
246 |
self.assertRaises(errors.NoRepositoryPresent, |
|
247 |
checkout.bzrdir.open_repository) |
|
248 |
||
2796.2.31
by Aaron Bentley
Fetch tags to reference branch when converting to checkout |
249 |
def prepare_branch_to_lightweight_checkout(self): |
250 |
parent = self.make_branch('parent') |
|
251 |
child = parent.bzrdir.sprout('child').open_workingtree() |
|
252 |
child.commit('test', rev_id='new-commit') |
|
3338.1.1
by Aaron Bentley
Raise an error when converting a branch to a lightweight checkout loses data |
253 |
parent.pull(child.branch) |
2796.2.31
by Aaron Bentley
Fetch tags to reference branch when converting to checkout |
254 |
child.bzrdir.destroy_workingtree() |
255 |
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
|
256 |
child.bzrdir) |
|
257 |
return parent, child, reconfiguration |
|
258 |
||
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
259 |
def test_branch_to_lightweight_checkout(self): |
2796.2.31
by Aaron Bentley
Fetch tags to reference branch when converting to checkout |
260 |
parent, child, reconfiguration = \ |
261 |
self.prepare_branch_to_lightweight_checkout() |
|
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
262 |
reconfiguration.apply() |
2796.2.31
by Aaron Bentley
Fetch tags to reference branch when converting to checkout |
263 |
self.assertTrue(reconfiguration._destroy_branch) |
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
264 |
wt = child.bzrdir.open_workingtree() |
265 |
self.assertTrue(parent.repository.has_same_location( |
|
266 |
wt.branch.repository)) |
|
267 |
parent.repository.get_revision('new-commit') |
|
268 |
self.assertRaises(errors.NoRepositoryPresent, |
|
269 |
child.bzrdir.open_repository) |
|
270 |
||
2796.2.30
by Aaron Bentley
Reconfigure can safely be interrupted while fetching (#179316) |
271 |
def test_branch_to_lightweight_checkout_failure(self): |
2796.2.31
by Aaron Bentley
Fetch tags to reference branch when converting to checkout |
272 |
parent, child, reconfiguration = \ |
273 |
self.prepare_branch_to_lightweight_checkout() |
|
6341.1.6
by Jelmer Vernooij
Fix test. |
274 |
old_Repository_fetch = vf_repository.VersionedFileRepository.fetch |
275 |
vf_repository.VersionedFileRepository.fetch = None |
|
2796.2.30
by Aaron Bentley
Reconfigure can safely be interrupted while fetching (#179316) |
276 |
try: |
277 |
self.assertRaises(TypeError, reconfiguration.apply) |
|
278 |
finally: |
|
6341.1.6
by Jelmer Vernooij
Fix test. |
279 |
vf_repository.VersionedFileRepository.fetch = old_Repository_fetch |
2796.2.30
by Aaron Bentley
Reconfigure can safely be interrupted while fetching (#179316) |
280 |
child = _mod_branch.Branch.open('child') |
281 |
self.assertContainsRe(child.base, 'child/$') |
|
282 |
||
2796.2.31
by Aaron Bentley
Fetch tags to reference branch when converting to checkout |
283 |
def test_branch_to_lightweight_checkout_fetch_tags(self): |
284 |
parent, child, reconfiguration = \ |
|
285 |
self.prepare_branch_to_lightweight_checkout() |
|
286 |
child.branch.tags.set_tag('foo', 'bar') |
|
287 |
reconfiguration.apply() |
|
288 |
child = _mod_branch.Branch.open('child') |
|
289 |
self.assertEqual('bar', parent.tags.lookup_tag('foo')) |
|
290 |
||
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
291 |
def test_lightweight_checkout_to_lightweight_checkout(self): |
292 |
parent = self.make_branch('parent') |
|
293 |
checkout = parent.create_checkout('checkout', lightweight=True) |
|
294 |
self.assertRaises(errors.AlreadyLightweightCheckout, |
|
295 |
reconfigure.Reconfigure.to_lightweight_checkout, |
|
296 |
checkout.bzrdir) |
|
2796.2.23
by Aaron Bentley
Add support for reconfiguring repositories into branches or trees |
297 |
|
298 |
def test_repo_to_tree(self): |
|
299 |
repo = self.make_repository('repo') |
|
300 |
reconfiguration = reconfigure.Reconfigure.to_tree(repo.bzrdir) |
|
301 |
reconfiguration.apply() |
|
302 |
workingtree.WorkingTree.open('repo') |
|
303 |
||
2796.2.25
by Aaron Bentley
Avoid destroying shared repositories |
304 |
def test_shared_repo_to_lightweight_checkout(self): |
305 |
repo = self.make_repository('repo', shared=True) |
|
2796.2.23
by Aaron Bentley
Add support for reconfiguring repositories into branches or trees |
306 |
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
307 |
repo.bzrdir) |
|
308 |
self.assertRaises(errors.NoBindLocation, reconfiguration.apply) |
|
309 |
branch = self.make_branch('branch') |
|
310 |
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
|
311 |
repo.bzrdir, 'branch') |
|
312 |
reconfiguration.apply() |
|
2796.2.25
by Aaron Bentley
Avoid destroying shared repositories |
313 |
workingtree.WorkingTree.open('repo') |
314 |
repository.Repository.open('repo') |
|
315 |
||
316 |
def test_unshared_repo_to_lightweight_checkout(self): |
|
317 |
repo = self.make_repository('repo', shared=False) |
|
318 |
branch = self.make_branch('branch') |
|
319 |
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout( |
|
320 |
repo.bzrdir, 'branch') |
|
321 |
reconfiguration.apply() |
|
322 |
workingtree.WorkingTree.open('repo') |
|
323 |
self.assertRaises(errors.NoRepositoryPresent, |
|
324 |
repository.Repository.open, 'repo') |
|
3311.2.1
by Aaron Bentley
Initial make-sharing functionality |
325 |
|
3311.2.6
by Aaron Bentley
rename 'sharing' to 'use-shared' |
326 |
def test_standalone_to_use_shared(self): |
3311.2.1
by Aaron Bentley
Initial make-sharing functionality |
327 |
self.build_tree(['root/']) |
328 |
tree = self.make_branch_and_tree('root/tree') |
|
329 |
tree.commit('Hello', rev_id='hello-id') |
|
330 |
repo = self.make_repository('root', shared=True) |
|
3311.2.6
by Aaron Bentley
rename 'sharing' to 'use-shared' |
331 |
reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.bzrdir) |
3311.2.1
by Aaron Bentley
Initial make-sharing functionality |
332 |
reconfiguration.apply() |
333 |
tree = workingtree.WorkingTree.open('root/tree') |
|
334 |
self.assertTrue(repo.has_same_location(tree.branch.repository)) |
|
335 |
self.assertEqual('Hello', repo.get_revision('hello-id').message) |
|
3311.2.2
by Aaron Bentley
Flesh out to_sharing |
336 |
|
3311.2.7
by Aaron Bentley
Get head preservation under test |
337 |
def add_dead_head(self, tree): |
338 |
revno, revision_id = tree.branch.last_revision_info() |
|
339 |
tree.commit('Dead head', rev_id='dead-head-id') |
|
340 |
tree.branch.set_last_revision_info(revno, revision_id) |
|
341 |
tree.set_last_revision(revision_id) |
|
342 |
||
343 |
def test_standalone_to_use_shared_preserves_dead_heads(self): |
|
344 |
self.build_tree(['root/']) |
|
345 |
tree = self.make_branch_and_tree('root/tree') |
|
346 |
self.add_dead_head(tree) |
|
347 |
tree.commit('Hello', rev_id='hello-id') |
|
348 |
repo = self.make_repository('root', shared=True) |
|
349 |
reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.bzrdir) |
|
350 |
reconfiguration.apply() |
|
351 |
tree = workingtree.WorkingTree.open('root/tree') |
|
352 |
message = repo.get_revision('dead-head-id').message |
|
353 |
self.assertEqual('Dead head', message) |
|
354 |
||
3311.2.6
by Aaron Bentley
rename 'sharing' to 'use-shared' |
355 |
def make_repository_tree(self): |
3311.2.4
by Aaron Bentley
Implement conversion to standalone |
356 |
self.build_tree(['root/']) |
357 |
repo = self.make_repository('root', shared=True) |
|
358 |
tree = self.make_branch_and_tree('root/tree') |
|
3311.2.6
by Aaron Bentley
rename 'sharing' to 'use-shared' |
359 |
reconfigure.Reconfigure.to_use_shared(tree.bzrdir).apply() |
3311.2.4
by Aaron Bentley
Implement conversion to standalone |
360 |
return workingtree.WorkingTree.open('root/tree') |
361 |
||
3311.2.6
by Aaron Bentley
rename 'sharing' to 'use-shared' |
362 |
def test_use_shared_to_use_shared(self): |
363 |
tree = self.make_repository_tree() |
|
364 |
self.assertRaises(errors.AlreadyUsingShared, |
|
365 |
reconfigure.Reconfigure.to_use_shared, tree.bzrdir) |
|
3311.2.4
by Aaron Bentley
Implement conversion to standalone |
366 |
|
3311.2.6
by Aaron Bentley
rename 'sharing' to 'use-shared' |
367 |
def test_use_shared_to_standalone(self): |
368 |
tree = self.make_repository_tree() |
|
3311.2.4
by Aaron Bentley
Implement conversion to standalone |
369 |
tree.commit('Hello', rev_id='hello-id') |
370 |
reconfigure.Reconfigure.to_standalone(tree.bzrdir).apply() |
|
371 |
tree = workingtree.WorkingTree.open('root/tree') |
|
372 |
repo = tree.branch.repository |
|
373 |
self.assertEqual(repo.bzrdir.root_transport.base, |
|
374 |
tree.bzrdir.root_transport.base) |
|
375 |
self.assertEqual('Hello', repo.get_revision('hello-id').message) |
|
376 |
||
3311.2.7
by Aaron Bentley
Get head preservation under test |
377 |
def test_use_shared_to_standalone_preserves_dead_heads(self): |
378 |
tree = self.make_repository_tree() |
|
379 |
self.add_dead_head(tree) |
|
380 |
tree.commit('Hello', rev_id='hello-id') |
|
381 |
reconfigure.Reconfigure.to_standalone(tree.bzrdir).apply() |
|
382 |
tree = workingtree.WorkingTree.open('root/tree') |
|
383 |
repo = tree.branch.repository |
|
384 |
self.assertRaises(errors.NoSuchRevision, repo.get_revision, |
|
385 |
'dead-head-id') |
|
386 |
||
3311.2.4
by Aaron Bentley
Implement conversion to standalone |
387 |
def test_standalone_to_standalone(self): |
388 |
tree = self.make_branch_and_tree('tree') |
|
389 |
self.assertRaises(errors.AlreadyStandalone, |
|
390 |
reconfigure.Reconfigure.to_standalone, tree.bzrdir) |
|
3338.1.3
by Aaron Bentley
Merge bzr.dev |
391 |
|
3338.1.2
by Aaron Bentley
Split out tests even further |
392 |
def make_unsynced_branch_reconfiguration(self): |
3338.1.1
by Aaron Bentley
Raise an error when converting a branch to a lightweight checkout loses data |
393 |
parent = self.make_branch_and_tree('parent') |
394 |
parent.commit('commit 1') |
|
395 |
child = parent.bzrdir.sprout('child').open_workingtree() |
|
396 |
child.commit('commit 2') |
|
3338.1.2
by Aaron Bentley
Split out tests even further |
397 |
return reconfigure.Reconfigure.to_lightweight_checkout(child.bzrdir) |
398 |
||
399 |
def test_unsynced_branch_to_lightweight_checkout_unforced(self): |
|
400 |
reconfiguration = self.make_unsynced_branch_reconfiguration() |
|
3338.1.1
by Aaron Bentley
Raise an error when converting a branch to a lightweight checkout loses data |
401 |
self.assertRaises(errors.UnsyncedBranches, reconfiguration.apply) |
3338.1.2
by Aaron Bentley
Split out tests even further |
402 |
|
403 |
def test_unsynced_branch_to_lightweight_checkout_forced(self): |
|
404 |
reconfiguration = self.make_unsynced_branch_reconfiguration() |
|
3338.1.1
by Aaron Bentley
Raise an error when converting a branch to a lightweight checkout loses data |
405 |
reconfiguration.apply(force=True) |
3921.4.4
by Matthew Fuller
Add unit tests for Reconfigure.set_repository_trees(). |
406 |
|
407 |
def make_repository_with_without_trees(self, with_trees): |
|
408 |
repo = self.make_repository('repo', shared=True) |
|
409 |
repo.set_make_working_trees(with_trees) |
|
410 |
return repo |
|
411 |
||
412 |
def test_make_with_trees(self): |
|
413 |
repo = self.make_repository_with_without_trees(False) |
|
414 |
reconfiguration = reconfigure.Reconfigure.set_repository_trees( |
|
415 |
repo.bzrdir, True) |
|
416 |
reconfiguration.apply() |
|
3921.4.5
by Matthew Fuller
Add assertions to the unit tests to make sure the reconfiguration |
417 |
self.assertIs(True, repo.make_working_trees()) |
3921.4.4
by Matthew Fuller
Add unit tests for Reconfigure.set_repository_trees(). |
418 |
|
419 |
def test_make_without_trees(self): |
|
420 |
repo = self.make_repository_with_without_trees(True) |
|
421 |
reconfiguration = reconfigure.Reconfigure.set_repository_trees( |
|
422 |
repo.bzrdir, False) |
|
423 |
reconfiguration.apply() |
|
3921.4.5
by Matthew Fuller
Add assertions to the unit tests to make sure the reconfiguration |
424 |
self.assertIs(False, repo.make_working_trees()) |
3921.4.4
by Matthew Fuller
Add unit tests for Reconfigure.set_repository_trees(). |
425 |
|
426 |
def test_make_with_trees_already_with_trees(self): |
|
427 |
repo = self.make_repository_with_without_trees(True) |
|
3983.3.9
by Marius Kruger
check error message too |
428 |
e = self.assertRaises(errors.AlreadyWithTrees, |
429 |
reconfigure.Reconfigure.set_repository_trees, repo.bzrdir, True) |
|
430 |
self.assertContainsRe(str(e), |
|
431 |
r"Shared repository '.*' already creates working trees.") |
|
3921.4.4
by Matthew Fuller
Add unit tests for Reconfigure.set_repository_trees(). |
432 |
|
433 |
def test_make_without_trees_already_no_trees(self): |
|
434 |
repo = self.make_repository_with_without_trees(False) |
|
3983.3.9
by Marius Kruger
check error message too |
435 |
e = self.assertRaises(errors.AlreadyWithNoTrees, |
3921.4.4
by Matthew Fuller
Add unit tests for Reconfigure.set_repository_trees(). |
436 |
reconfigure.Reconfigure.set_repository_trees, repo.bzrdir, False) |
3983.3.9
by Marius Kruger
check error message too |
437 |
self.assertContainsRe(str(e), |
438 |
r"Shared repository '.*' already doesn't create working trees.") |
|
3983.3.10
by Marius Kruger
add test_repository_tree_reconfiguration_not_supported |
439 |
|
440 |
def test_repository_tree_reconfiguration_not_supported(self): |
|
441 |
tree = self.make_branch_and_tree('tree') |
|
442 |
e = self.assertRaises(errors.ReconfigurationNotSupported, |
|
443 |
reconfigure.Reconfigure.set_repository_trees, tree.bzrdir, None) |
|
444 |
self.assertContainsRe(str(e), |
|
445 |
r"Requested reconfiguration of '.*' is not supported.") |
|
4273.1.18
by Aaron Bentley
Reconfigure preserves reference locations. |
446 |
|
447 |
def test_lightweight_checkout_to_tree_preserves_reference_locations(self): |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
448 |
format = controldir.format_registry.make_bzrdir('1.9') |
4273.1.18
by Aaron Bentley
Reconfigure preserves reference locations. |
449 |
format.set_branch_format(_mod_branch.BzrBranchFormat8()) |
450 |
tree = self.make_branch_and_tree('tree', format=format) |
|
451 |
tree.branch.set_reference_info('file_id', 'path', '../location') |
|
452 |
checkout = tree.branch.create_checkout('checkout', lightweight=True) |
|
453 |
reconfiguration = reconfigure.Reconfigure.to_tree(checkout.bzrdir) |
|
454 |
reconfiguration.apply() |
|
455 |
checkout_branch = checkout.bzrdir.open_branch() |
|
456 |
self.assertEqual(('path', '../location'), |
|
457 |
checkout_branch.get_reference_info('file_id')) |