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