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