bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2255.7.9
by John Arbash Meinel
Add more tests for WorkingTree.move() and a similar suite |
1 |
# Copyright (C) 2006, 2007 Canonical Ltd
|
|
2255.2.137
by John Arbash Meinel
Move the WorkingTree.move() tests into their own module |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
|
2255.7.9
by John Arbash Meinel
Add more tests for WorkingTree.move() and a similar suite |
17 |
"""Tests for interface conformance of 'WorkingTree.move'"""
|
|
2255.2.137
by John Arbash Meinel
Move the WorkingTree.move() tests into their own module |
18 |
|
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
19 |
import os |
20 |
||
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
21 |
from bzrlib import ( |
22 |
errors, |
|
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
23 |
osutils, |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
24 |
)
|
25 |
||
|
2255.2.137
by John Arbash Meinel
Move the WorkingTree.move() tests into their own module |
26 |
from bzrlib.workingtree_4 import WorkingTreeFormat4 |
27 |
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree |
|
28 |
||
29 |
||
30 |
class TestMove(TestCaseWithWorkingTree): |
|
31 |
||
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
32 |
def get_tree_layout(self, tree): |
33 |
"""Get the (path, file_id) pairs for the current tree.""" |
|
34 |
tree.lock_read() |
|
35 |
try: |
|
36 |
return [(path, ie.file_id) for path, ie |
|
37 |
in tree.iter_entries_by_dir()] |
|
38 |
finally: |
|
39 |
tree.unlock() |
|
40 |
||
41 |
def assertTreeLayout(self, expected, tree): |
|
42 |
"""Check that the tree has the correct layout.""" |
|
43 |
actual = self.get_tree_layout(tree) |
|
44 |
self.assertEqual(expected, actual) |
|
45 |
||
|
2255.2.137
by John Arbash Meinel
Move the WorkingTree.move() tests into their own module |
46 |
def test_move_correct_call_named(self): |
47 |
"""tree.move has the deprecated parameter 'to_name'. |
|
48 |
It has been replaced by 'to_dir' for consistency.
|
|
49 |
Test the new API using named parameter
|
|
50 |
"""
|
|
51 |
self.build_tree(['a1', 'sub1/']) |
|
52 |
tree = self.make_branch_and_tree('.') |
|
53 |
tree.add(['a1', 'sub1']) |
|
54 |
tree.commit('initial commit') |
|
55 |
tree.move(['a1'], to_dir='sub1', after=False) |
|
56 |
||
57 |
def test_move_correct_call_unnamed(self): |
|
58 |
"""tree.move has the deprecated parameter 'to_name'. |
|
59 |
It has been replaced by 'to_dir' for consistency.
|
|
60 |
Test the new API using unnamed parameter
|
|
61 |
"""
|
|
62 |
self.build_tree(['a1', 'sub1/']) |
|
63 |
tree = self.make_branch_and_tree('.') |
|
64 |
tree.add(['a1', 'sub1']) |
|
65 |
tree.commit('initial commit') |
|
66 |
tree.move(['a1'], 'sub1', after=False) |
|
67 |
||
68 |
def test_move_deprecated_wrong_call(self): |
|
69 |
"""tree.move has the deprecated parameter 'to_name'. |
|
70 |
It has been replaced by 'to_dir' for consistency.
|
|
71 |
Test the new API using wrong parameter
|
|
72 |
"""
|
|
73 |
self.build_tree(['a1', 'sub1/']) |
|
74 |
tree = self.make_branch_and_tree('.') |
|
75 |
tree.add(['a1', 'sub1']) |
|
76 |
tree.commit('initial commit') |
|
77 |
self.assertRaises(TypeError, tree.move, ['a1'], |
|
78 |
to_this_parameter_does_not_exist='sub1', |
|
79 |
after=False) |
|
80 |
||
81 |
def test_move_deprecated_call(self): |
|
82 |
"""tree.move has the deprecated parameter 'to_name'. |
|
83 |
It has been replaced by 'to_dir' for consistency.
|
|
84 |
Test the new API using deprecated parameter
|
|
85 |
"""
|
|
86 |
self.build_tree(['a1', 'sub1/']) |
|
87 |
tree = self.make_branch_and_tree('.') |
|
88 |
tree.add(['a1', 'sub1']) |
|
89 |
tree.commit('initial commit') |
|
90 |
||
91 |
try: |
|
92 |
self.callDeprecated(['The parameter to_name was deprecated' |
|
93 |
' in version 0.13. Use to_dir instead'], |
|
94 |
tree.move, ['a1'], to_name='sub1', |
|
95 |
after=False) |
|
96 |
except TypeError: |
|
97 |
# WorkingTreeFormat4 doesn't have to maintain api compatibility
|
|
98 |
# since it was deprecated before the class was introduced.
|
|
99 |
if not isinstance(self.workingtree_format, WorkingTreeFormat4): |
|
100 |
raise
|
|
101 |
||
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
102 |
def test_move_target_not_dir(self): |
103 |
tree = self.make_branch_and_tree('.') |
|
104 |
self.build_tree(['a']) |
|
105 |
tree.add(['a']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
106 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
107 |
|
108 |
self.assertRaises(errors.BzrMoveFailedError, |
|
109 |
tree.move, ['a'], 'not-a-dir') |
|
110 |
||
111 |
def test_move_non_existent(self): |
|
112 |
tree = self.make_branch_and_tree('.') |
|
113 |
self.build_tree(['a/']) |
|
114 |
tree.add(['a']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
115 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
116 |
self.assertRaises(errors.BzrMoveFailedError, |
117 |
tree.move, ['not-a-file'], 'a') |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
118 |
self.assertRaises(errors.BzrMoveFailedError, |
119 |
tree.move, ['not-a-file'], '') |
|
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
120 |
|
121 |
def test_move_target_not_versioned(self): |
|
122 |
tree = self.make_branch_and_tree('.') |
|
123 |
self.build_tree(['a/', 'b']) |
|
124 |
tree.add(['b']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
125 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
126 |
self.assertRaises(errors.BzrMoveFailedError, |
127 |
tree.move, ['b'], 'a') |
|
128 |
||
129 |
# TODO: jam 20070225 What about a test when the target is now a directory,
|
|
130 |
# but in the past it was a file. Theoretically WorkingTree should
|
|
131 |
# notice the kind change.
|
|
132 |
||
133 |
def test_move_unversioned(self): |
|
134 |
tree = self.make_branch_and_tree('.') |
|
135 |
self.build_tree(['a/', 'b']) |
|
136 |
tree.add(['a']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
137 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
138 |
self.assertRaises(errors.BzrMoveFailedError, |
139 |
tree.move, ['b'], 'a') |
|
140 |
||
141 |
def test_move_multi_unversioned(self): |
|
142 |
tree = self.make_branch_and_tree('.') |
|
143 |
self.build_tree(['a/', 'b', 'c', 'd']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
144 |
tree.add(['a', 'c', 'd'], ['a-id', 'c-id', 'd-id']) |
145 |
tree.commit('initial', rev_id='rev-1') |
|
146 |
root_id = tree.get_root_id() |
|
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
147 |
self.assertRaises(errors.BzrMoveFailedError, |
148 |
tree.move, ['c', 'b', 'd'], 'a') |
|
149 |
self.assertRaises(errors.BzrMoveFailedError, |
|
150 |
tree.move, ['b', 'c', 'd'], 'a') |
|
151 |
self.assertRaises(errors.BzrMoveFailedError, |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
152 |
tree.move, ['d', 'c', 'b'], 'a') |
153 |
if osutils.lexists('a/c'): |
|
154 |
# If 'c' was actually moved, then 'd' should have also been moved
|
|
155 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), |
|
156 |
('a/c', 'c-id'), ('a/d', 'd-id')], tree) |
|
157 |
else: |
|
158 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'), |
|
159 |
('d', 'd-id')], tree) |
|
160 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'), |
|
161 |
('d', 'd-id')], tree.basis_tree()) |
|
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
162 |
|
163 |
def test_move_subdir(self): |
|
164 |
tree = self.make_branch_and_tree('.') |
|
165 |
self.build_tree(['a', 'b/', 'b/c']) |
|
166 |
tree.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
167 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
168 |
root_id = tree.get_root_id() |
169 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'), |
|
170 |
('b/c', 'c-id')], tree) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
171 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'), |
172 |
('b/c', 'c-id')], tree.basis_tree()) |
|
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
173 |
a_contents = tree.get_file_text('a-id') |
174 |
tree.move(['a'], 'b') |
|
175 |
self.assertTreeLayout([('', root_id), ('b', 'b-id'), ('b/a', 'a-id'), |
|
176 |
('b/c', 'c-id')], tree) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
177 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'), |
178 |
('b/c', 'c-id')], tree.basis_tree()) |
|
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
179 |
self.failIfExists('a') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
180 |
self.assertFileEqual(a_contents, 'b/a') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
181 |
|
182 |
def test_move_parent_dir(self): |
|
183 |
tree = self.make_branch_and_tree('.') |
|
184 |
self.build_tree(['a', 'b/', 'b/c']) |
|
185 |
tree.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
186 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
187 |
root_id = tree.get_root_id() |
188 |
c_contents = tree.get_file_text('c-id') |
|
189 |
tree.move(['b/c'], '') |
|
190 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'), |
|
191 |
('c', 'c-id')], tree) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
192 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'), |
193 |
('b/c', 'c-id')], tree.basis_tree()) |
|
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
194 |
self.failIfExists('b/c') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
195 |
self.assertFileEqual(c_contents, 'c') |
196 |
||
197 |
def test_move_fail_consistent(self): |
|
198 |
tree = self.make_branch_and_tree('.') |
|
199 |
self.build_tree(['a', 'b/', 'b/a', 'c']) |
|
200 |
tree.add(['a', 'b', 'c'], ['a-id', 'b-id', 'c-id']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
201 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
202 |
root_id = tree.get_root_id() |
203 |
# Target already exists
|
|
204 |
self.assertRaises(errors.RenameFailedFilesExist, |
|
205 |
tree.move, ['c', 'a'], 'b') |
|
206 |
# 'c' may or may not have been moved, but either way the tree should
|
|
207 |
# maintain a consistent state.
|
|
208 |
if osutils.lexists('c'): |
|
209 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'), |
|
210 |
('c', 'c-id')], tree) |
|
211 |
else: |
|
212 |
self.failUnlessExists('b/c') |
|
213 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'), |
|
214 |
('b/c', 'c-id')], tree) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
215 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'), |
216 |
('c', 'c-id')], tree.basis_tree()) |
|
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
217 |
|
218 |
def test_move_onto_self(self): |
|
219 |
tree = self.make_branch_and_tree('.') |
|
220 |
self.build_tree(['b/', 'b/a']) |
|
221 |
tree.add(['b', 'b/a'], ['b-id', 'a-id']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
222 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
223 |
|
224 |
self.assertRaises(errors.BzrMoveFailedError, |
|
225 |
tree.move, ['b/a'], 'b') |
|
226 |
||
227 |
def test_move_onto_self_root(self): |
|
228 |
tree = self.make_branch_and_tree('.') |
|
229 |
self.build_tree(['a']) |
|
230 |
tree.add(['a'], ['a-id']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
231 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
232 |
|
233 |
self.assertRaises(errors.BzrMoveFailedError, |
|
234 |
tree.move, ['a'], 'a') |
|
235 |
||
236 |
def test_move_after(self): |
|
237 |
tree = self.make_branch_and_tree('.') |
|
238 |
self.build_tree(['a', 'b/']) |
|
239 |
tree.add(['a', 'b'], ['a-id', 'b-id']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
240 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
241 |
root_id = tree.get_root_id() |
242 |
os.rename('a', 'b/a') |
|
243 |
||
244 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')], |
|
245 |
tree) |
|
246 |
# We don't need after=True as long as source is missing and target
|
|
247 |
# exists.
|
|
248 |
tree.move(['a'], 'b') |
|
249 |
self.assertTreeLayout([('', root_id), ('b', 'b-id'), ('b/a', 'a-id')], |
|
250 |
tree) |
|
|
2255.2.141
by John Arbash Meinel
Some small changes to move tests. |
251 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')], |
252 |
tree.basis_tree()) |
|
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
253 |
|
254 |
def test_move_after_with_after(self): |
|
255 |
tree = self.make_branch_and_tree('.') |
|
256 |
self.build_tree(['a', 'b/']) |
|
257 |
tree.add(['a', 'b'], ['a-id', 'b-id']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
258 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
259 |
root_id = tree.get_root_id() |
260 |
os.rename('a', 'b/a') |
|
261 |
||
262 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')], |
|
263 |
tree) |
|
264 |
# Passing after=True should work as well
|
|
265 |
tree.move(['a'], 'b', after=True) |
|
266 |
self.assertTreeLayout([('', root_id), ('b', 'b-id'), ('b/a', 'a-id')], |
|
267 |
tree) |
|
|
2255.2.141
by John Arbash Meinel
Some small changes to move tests. |
268 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')], |
269 |
tree.basis_tree()) |
|
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
270 |
|
271 |
def test_move_after_no_target(self): |
|
272 |
tree = self.make_branch_and_tree('.') |
|
273 |
self.build_tree(['a', 'b/']) |
|
274 |
tree.add(['a', 'b'], ['a-id', 'b-id']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
275 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
276 |
root_id = tree.get_root_id() |
277 |
||
278 |
# Passing after when the file hasn't been move raises an exception
|
|
279 |
self.assertRaises(errors.BzrMoveFailedError, |
|
280 |
tree.move, ['a'], 'b', after=True) |
|
|
2255.2.141
by John Arbash Meinel
Some small changes to move tests. |
281 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')], |
282 |
tree.basis_tree()) |
|
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
283 |
|
284 |
def test_move_after_source_and_dest(self): |
|
285 |
tree = self.make_branch_and_tree('.') |
|
286 |
self.build_tree(['a', 'b/', 'b/a']) |
|
287 |
tree.add(['a', 'b'], ['a-id', 'b-id']) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
288 |
tree.commit('initial', rev_id='rev-1') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
289 |
root_id = tree.get_root_id() |
290 |
||
291 |
# TODO: jam 20070225 I would usually use 'rb', but assertFileEqual
|
|
292 |
# uses 'r'.
|
|
293 |
a_file = open('a', 'r') |
|
294 |
try: |
|
295 |
a_text = a_file.read() |
|
296 |
finally: |
|
297 |
a_file.close() |
|
298 |
ba_file = open('b/a', 'r') |
|
299 |
try: |
|
300 |
ba_text = ba_file.read() |
|
301 |
finally: |
|
302 |
ba_file.close() |
|
303 |
||
304 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')], |
|
305 |
tree) |
|
306 |
self.assertRaises(errors.RenameFailedFilesExist, |
|
307 |
tree.move, ['a'], 'b', after=False) |
|
308 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')], |
|
309 |
tree) |
|
310 |
self.assertFileEqual(a_text, 'a') |
|
311 |
self.assertFileEqual(ba_text, 'b/a') |
|
312 |
# But you can pass after=True
|
|
313 |
tree.move(['a'], 'b', after=True) |
|
314 |
self.assertTreeLayout([('', root_id), ('b', 'b-id'), ('b/a', 'a-id')], |
|
315 |
tree) |
|
|
2255.2.141
by John Arbash Meinel
Some small changes to move tests. |
316 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')], |
317 |
tree.basis_tree()) |
|
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
318 |
# But it shouldn't actually move anything
|
319 |
self.assertFileEqual(a_text, 'a') |
|
320 |
self.assertFileEqual(ba_text, 'b/a') |
|
|
2255.2.146
by John Arbash Meinel
Implement move_directory by factoring out move_one |
321 |
|
322 |
def test_move_directory(self): |
|
323 |
tree = self.make_branch_and_tree('.') |
|
324 |
self.build_tree(['a/', 'a/b', 'a/c/', 'a/c/d', 'e/']) |
|
325 |
tree.add(['a', 'a/b', 'a/c', 'a/c/d', 'e'], |
|
326 |
['a-id', 'b-id', 'c-id', 'd-id', 'e-id']) |
|
327 |
tree.commit('initial', rev_id='rev-1') |
|
328 |
root_id = tree.get_root_id() |
|
329 |
||
330 |
tree.move(['a'], 'e') |
|
331 |
self.assertTreeLayout([('', root_id), ('e', 'e-id'), ('e/a', 'a-id'), |
|
332 |
('e/a/b', 'b-id'), ('e/a/c', 'c-id'), |
|
333 |
('e/a/c/d', 'd-id')], tree) |
|
|
2255.7.9
by John Arbash Meinel
Add more tests for WorkingTree.move() and a similar suite |
334 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('e', 'e-id'), |
335 |
('a/b', 'b-id'), ('a/c', 'c-id'), |
|
336 |
('a/c/d', 'd-id')], tree.basis_tree()) |
|
337 |
||
338 |
def test_move_moved(self): |
|
339 |
"""Moving a moved entry works as expected.""" |
|
340 |
tree = self.make_branch_and_tree('.') |
|
341 |
self.build_tree(['a/', 'a/b', 'c/']) |
|
342 |
tree.add(['a', 'a/b', 'c'], ['a-id', 'b-id', 'c-id']) |
|
343 |
tree.commit('initial', rev_id='rev-1') |
|
344 |
root_id = tree.get_root_id() |
|
345 |
||
346 |
tree.move(['a/b'], 'c') |
|
347 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'), |
|
348 |
('c/b', 'b-id')], tree) |
|
349 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'), |
|
350 |
('a/b', 'b-id')], tree.basis_tree()) |
|
351 |
||
352 |
tree.move(['c/b'], '') |
|
353 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'), |
|
354 |
('c', 'c-id')], tree) |
|
355 |
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'), |
|
356 |
('a/b', 'b-id')], tree.basis_tree()) |