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