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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
2255.2.137
by John Arbash Meinel
Move the WorkingTree.move() tests into their own module |
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 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
21 |
from breezy import ( |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
22 |
errors, |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
23 |
osutils, |
|
5609.8.2
by Martin
Add per_workingtree test for every error case bar one that has unicode problems |
24 |
tests, |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
25 |
)
|
26 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
27 |
from breezy.tests.matchers import HasLayout |
28 |
from breezy.tests.per_workingtree import TestCaseWithWorkingTree |
|
29 |
from breezy.tests import ( |
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
30 |
features, |
31 |
)
|
|
|
2255.2.137
by John Arbash Meinel
Move the WorkingTree.move() tests into their own module |
32 |
|
33 |
||
34 |
class TestMove(TestCaseWithWorkingTree): |
|
35 |
||
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
36 |
def assertTreeLayout(self, expected, tree): |
37 |
"""Check that the tree has the correct layout.""" |
|
|
6072.2.2
by Jelmer Vernooij
Use HasLayout matcher. |
38 |
self.assertThat(tree, HasLayout(expected)) |
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
39 |
|
|
3923.2.1
by Charles Duffy
Fix bug #314251 (dirstate crash on rename via delete+add) |
40 |
def test_move_via_rm_and_add(self): |
41 |
"""Move by remove and add-with-id""" |
|
42 |
self.build_tree(['a1', 'b1']) |
|
43 |
tree = self.make_branch_and_tree('.') |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
44 |
if tree.supports_setting_file_ids(): |
45 |
tree.add(['a1'], ids=['a1-id']) |
|
46 |
else: |
|
47 |
tree.add(['a1']) |
|
|
3923.2.1
by Charles Duffy
Fix bug #314251 (dirstate crash on rename via delete+add) |
48 |
tree.commit('initial commit') |
49 |
tree.remove('a1', force=True, keep_files=False) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
50 |
if tree.supports_setting_file_ids(): |
51 |
tree.add(['b1'], ids=['a1-id']) |
|
52 |
else: |
|
53 |
tree.add(['b1']) |
|
|
3923.2.1
by Charles Duffy
Fix bug #314251 (dirstate crash on rename via delete+add) |
54 |
tree._validate() |
55 |
||
|
2255.2.137
by John Arbash Meinel
Move the WorkingTree.move() tests into their own module |
56 |
def test_move_correct_call_named(self): |
57 |
"""tree.move has the deprecated parameter 'to_name'. |
|
58 |
It has been replaced by 'to_dir' for consistency.
|
|
59 |
Test the new API using named parameter
|
|
60 |
"""
|
|
61 |
self.build_tree(['a1', 'sub1/']) |
|
62 |
tree = self.make_branch_and_tree('.') |
|
63 |
tree.add(['a1', 'sub1']) |
|
64 |
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. |
65 |
self.assertEqual([('a1', 'sub1/a1')], |
66 |
tree.move(['a1'], to_dir='sub1', after=False)) |
|
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
67 |
tree._validate() |
|
2255.2.137
by John Arbash Meinel
Move the WorkingTree.move() tests into their own module |
68 |
|
69 |
def test_move_correct_call_unnamed(self): |
|
70 |
"""tree.move has the deprecated parameter 'to_name'. |
|
71 |
It has been replaced by 'to_dir' for consistency.
|
|
72 |
Test the new API using unnamed parameter
|
|
73 |
"""
|
|
74 |
self.build_tree(['a1', 'sub1/']) |
|
75 |
tree = self.make_branch_and_tree('.') |
|
76 |
tree.add(['a1', 'sub1']) |
|
77 |
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. |
78 |
self.assertEqual([('a1', 'sub1/a1')], |
79 |
tree.move(['a1'], 'sub1', after=False)) |
|
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
80 |
tree._validate() |
|
2255.2.137
by John Arbash Meinel
Move the WorkingTree.move() tests into their own module |
81 |
|
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
82 |
def test_move_target_not_dir(self): |
83 |
tree = self.make_branch_and_tree('.') |
|
84 |
self.build_tree(['a']) |
|
85 |
tree.add(['a']) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
86 |
tree.commit('initial') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
87 |
|
88 |
self.assertRaises(errors.BzrMoveFailedError, |
|
89 |
tree.move, ['a'], 'not-a-dir') |
|
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
90 |
tree._validate() |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
91 |
|
92 |
def test_move_non_existent(self): |
|
93 |
tree = self.make_branch_and_tree('.') |
|
94 |
self.build_tree(['a/']) |
|
95 |
tree.add(['a']) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
96 |
tree.commit('initial') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
97 |
self.assertRaises(errors.BzrMoveFailedError, |
98 |
tree.move, ['not-a-file'], 'a') |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
99 |
self.assertRaises(errors.BzrMoveFailedError, |
100 |
tree.move, ['not-a-file'], '') |
|
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
101 |
tree._validate() |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
102 |
|
103 |
def test_move_target_not_versioned(self): |
|
104 |
tree = self.make_branch_and_tree('.') |
|
105 |
self.build_tree(['a/', 'b']) |
|
106 |
tree.add(['b']) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
107 |
tree.commit('initial') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
108 |
self.assertRaises(errors.BzrMoveFailedError, |
109 |
tree.move, ['b'], 'a') |
|
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
110 |
tree._validate() |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
111 |
|
112 |
def test_move_unversioned(self): |
|
113 |
tree = self.make_branch_and_tree('.') |
|
114 |
self.build_tree(['a/', 'b']) |
|
115 |
tree.add(['a']) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
116 |
tree.commit('initial') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
117 |
self.assertRaises(errors.BzrMoveFailedError, |
118 |
tree.move, ['b'], 'a') |
|
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
119 |
tree._validate() |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
120 |
|
121 |
def test_move_multi_unversioned(self): |
|
122 |
tree = self.make_branch_and_tree('.') |
|
123 |
self.build_tree(['a/', 'b', 'c', 'd']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
124 |
tree.add(['a', 'c', 'd']) |
125 |
a_id = tree.path2id('a') |
|
126 |
c_id = tree.path2id('c') |
|
127 |
d_id = tree.path2id('d') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
128 |
tree.commit('initial') |
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
129 |
root_id = tree.get_root_id() |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
130 |
self.assertRaises(errors.BzrMoveFailedError, |
131 |
tree.move, ['c', 'b', 'd'], 'a') |
|
132 |
self.assertRaises(errors.BzrMoveFailedError, |
|
133 |
tree.move, ['b', 'c', 'd'], 'a') |
|
134 |
self.assertRaises(errors.BzrMoveFailedError, |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
135 |
tree.move, ['d', 'c', 'b'], 'a') |
136 |
if osutils.lexists('a/c'): |
|
137 |
# If 'c' was actually moved, then 'd' should have also been moved
|
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
138 |
self.assertTreeLayout([('', root_id), ('a/', a_id), |
139 |
('a/c', c_id), ('a/d', d_id)], tree) |
|
|
2255.2.140
by John Arbash Meinel
Update tests to ensure basis tree is not modified |
140 |
else: |
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
141 |
self.assertTreeLayout([('', root_id), ('a/', a_id), ('c', c_id), |
142 |
('d', d_id)], tree) |
|
143 |
self.assertTreeLayout([('', root_id), ('a/', a_id), ('c', c_id), |
|
144 |
('d', d_id)], tree.basis_tree()) |
|
|
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 |
|
|
2456.2.1
by John Arbash Meinel
(broken) Add a (failing) test that _iter_changes works correctly |
147 |
def test_move_over_deleted(self): |
148 |
tree = self.make_branch_and_tree('.') |
|
149 |
self.build_tree(['a/', 'a/b', 'b']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
150 |
tree.add(['a', 'a/b', 'b']) |
151 |
a_id = tree.path2id('a') |
|
152 |
ab_id = tree.path2id('a/b') |
|
153 |
b_id = tree.path2id('b') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
154 |
tree.commit('initial') |
|
2456.2.1
by John Arbash Meinel
(broken) Add a (failing) test that _iter_changes works correctly |
155 |
|
156 |
root_id = tree.get_root_id() |
|
157 |
tree.remove(['a/b'], keep_files=False) |
|
158 |
self.assertEqual([('b', 'a/b')], tree.move(['b'], 'a')) |
|
159 |
self.assertTreeLayout([('', root_id), |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
160 |
('a/', a_id), |
161 |
('a/b', b_id), |
|
|
2456.2.1
by John Arbash Meinel
(broken) Add a (failing) test that _iter_changes works correctly |
162 |
], tree) |
163 |
tree._validate() |
|
164 |
||
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
165 |
def test_move_subdir(self): |
166 |
tree = self.make_branch_and_tree('.') |
|
167 |
self.build_tree(['a', 'b/', 'b/c']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
168 |
tree.add(['a', 'b', 'b/c']) |
169 |
a_id = tree.path2id('a') |
|
170 |
b_id = tree.path2id('b') |
|
171 |
c_id = tree.path2id('b/c') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
172 |
tree.commit('initial') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
173 |
root_id = tree.get_root_id() |
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
174 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id), |
175 |
('b/c', c_id)], tree) |
|
176 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id), |
|
177 |
('b/c', c_id)], tree.basis_tree()) |
|
178 |
a_contents = tree.get_file_text('a', 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. |
179 |
self.assertEqual([('a', 'b/a')], |
180 |
tree.move(['a'], 'b')) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
181 |
self.assertTreeLayout([('', root_id), ('b/', b_id), ('b/a', a_id), |
182 |
('b/c', c_id)], tree) |
|
183 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id), |
|
184 |
('b/c', c_id)], tree.basis_tree()) |
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
185 |
self.assertPathDoesNotExist('a') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
186 |
self.assertFileEqual(a_contents, 'b/a') |
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
187 |
tree._validate() |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
188 |
|
189 |
def test_move_parent_dir(self): |
|
190 |
tree = self.make_branch_and_tree('.') |
|
191 |
self.build_tree(['a', 'b/', 'b/c']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
192 |
tree.add(['a', 'b', 'b/c']) |
193 |
a_id = tree.path2id('a') |
|
194 |
b_id = tree.path2id('b') |
|
195 |
c_id = tree.path2id('b/c') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
196 |
tree.commit('initial') |
|
2255.2.138
by John Arbash Meinel
implement several new WorkingTree.move() tests |
197 |
root_id = tree.get_root_id() |
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
198 |
c_contents = tree.get_file_text('b/c', 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. |
199 |
self.assertEqual([('b/c', 'c')], |
200 |
tree.move(['b/c'], '')) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
201 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id), |
202 |
('c', c_id)], tree) |
|
203 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id), |
|
204 |
('b/c', c_id)], tree.basis_tree()) |
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
205 |
self.assertPathDoesNotExist('b/c') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
206 |
self.assertFileEqual(c_contents, 'c') |
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
207 |
tree._validate() |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
208 |
|
209 |
def test_move_fail_consistent(self): |
|
210 |
tree = self.make_branch_and_tree('.') |
|
211 |
self.build_tree(['a', 'b/', 'b/a', 'c']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
212 |
tree.add(['a', 'b', 'c']) |
213 |
a_id = tree.path2id('a') |
|
214 |
b_id = tree.path2id('b') |
|
215 |
c_id = tree.path2id('c') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
216 |
tree.commit('initial') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
217 |
root_id = tree.get_root_id() |
218 |
# Target already exists
|
|
219 |
self.assertRaises(errors.RenameFailedFilesExist, |
|
220 |
tree.move, ['c', 'a'], 'b') |
|
221 |
# 'c' may or may not have been moved, but either way the tree should
|
|
222 |
# maintain a consistent state.
|
|
223 |
if osutils.lexists('c'): |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
224 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id), |
225 |
('c', c_id)], tree) |
|
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
226 |
else: |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
227 |
self.assertPathExists('b/c') |
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
228 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id), |
229 |
('b/c', c_id)], tree) |
|
230 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id), |
|
231 |
('c', c_id)], tree.basis_tree()) |
|
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
232 |
tree._validate() |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
233 |
|
234 |
def test_move_onto_self(self): |
|
235 |
tree = self.make_branch_and_tree('.') |
|
236 |
self.build_tree(['b/', 'b/a']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
237 |
tree.add(['b', 'b/a']) |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
238 |
tree.commit('initial') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
239 |
|
240 |
self.assertRaises(errors.BzrMoveFailedError, |
|
241 |
tree.move, ['b/a'], 'b') |
|
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
242 |
tree._validate() |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
243 |
|
244 |
def test_move_onto_self_root(self): |
|
245 |
tree = self.make_branch_and_tree('.') |
|
246 |
self.build_tree(['a']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
247 |
tree.add(['a']) |
248 |
a_id = tree.path2id('a') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
249 |
tree.commit('initial') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
250 |
|
251 |
self.assertRaises(errors.BzrMoveFailedError, |
|
252 |
tree.move, ['a'], 'a') |
|
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
253 |
tree._validate() |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
254 |
|
255 |
def test_move_after(self): |
|
256 |
tree = self.make_branch_and_tree('.') |
|
257 |
self.build_tree(['a', 'b/']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
258 |
tree.add(['a', 'b']) |
259 |
a_id = tree.path2id('a') |
|
260 |
b_id = tree.path2id('b') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
261 |
tree.commit('initial') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
262 |
root_id = tree.get_root_id() |
263 |
os.rename('a', 'b/a') |
|
264 |
||
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
265 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id)], |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
266 |
tree) |
267 |
# We don't need after=True as long as source is missing and target
|
|
268 |
# 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. |
269 |
self.assertEqual([('a', 'b/a')], |
270 |
tree.move(['a'], 'b')) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
271 |
self.assertTreeLayout([('', root_id), ('b/', b_id), ('b/a', a_id)], |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
272 |
tree) |
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
273 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id)], |
|
2255.2.141
by John Arbash Meinel
Some small changes to move tests. |
274 |
tree.basis_tree()) |
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
275 |
tree._validate() |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
276 |
|
277 |
def test_move_after_with_after(self): |
|
278 |
tree = self.make_branch_and_tree('.') |
|
279 |
self.build_tree(['a', 'b/']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
280 |
tree.add(['a', 'b']) |
281 |
a_id = tree.path2id('a') |
|
282 |
b_id = tree.path2id('b') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
283 |
tree.commit('initial') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
284 |
root_id = tree.get_root_id() |
285 |
os.rename('a', 'b/a') |
|
286 |
||
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
287 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id)], |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
288 |
tree) |
289 |
# 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. |
290 |
self.assertEqual([('a', 'b/a')], |
291 |
tree.move(['a'], 'b', after=True)) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
292 |
self.assertTreeLayout([('', root_id), ('b/', b_id), ('b/a', a_id)], |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
293 |
tree) |
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
294 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id)], |
|
2255.2.141
by John Arbash Meinel
Some small changes to move tests. |
295 |
tree.basis_tree()) |
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
296 |
tree._validate() |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
297 |
|
298 |
def test_move_after_no_target(self): |
|
299 |
tree = self.make_branch_and_tree('.') |
|
300 |
self.build_tree(['a', 'b/']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
301 |
tree.add(['a', 'b']) |
302 |
a_id = tree.path2id('a') |
|
303 |
b_id = tree.path2id('b') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
304 |
tree.commit('initial') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
305 |
root_id = tree.get_root_id() |
306 |
||
307 |
# Passing after when the file hasn't been move raises an exception
|
|
308 |
self.assertRaises(errors.BzrMoveFailedError, |
|
309 |
tree.move, ['a'], 'b', after=True) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
310 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id)], |
|
2255.2.141
by John Arbash Meinel
Some small changes to move tests. |
311 |
tree.basis_tree()) |
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
312 |
tree._validate() |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
313 |
|
314 |
def test_move_after_source_and_dest(self): |
|
315 |
tree = self.make_branch_and_tree('.') |
|
316 |
self.build_tree(['a', 'b/', 'b/a']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
317 |
tree.add(['a', 'b']) |
318 |
a_id = tree.path2id('a') |
|
319 |
b_id = tree.path2id('b') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
320 |
tree.commit('initial') |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
321 |
root_id = tree.get_root_id() |
322 |
||
323 |
# TODO: jam 20070225 I would usually use 'rb', but assertFileEqual
|
|
324 |
# uses 'r'.
|
|
325 |
a_file = open('a', 'r') |
|
326 |
try: |
|
327 |
a_text = a_file.read() |
|
328 |
finally: |
|
329 |
a_file.close() |
|
330 |
ba_file = open('b/a', 'r') |
|
331 |
try: |
|
332 |
ba_text = ba_file.read() |
|
333 |
finally: |
|
334 |
ba_file.close() |
|
335 |
||
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
336 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id)], |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
337 |
tree) |
338 |
self.assertRaises(errors.RenameFailedFilesExist, |
|
339 |
tree.move, ['a'], 'b', after=False) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
340 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id)], |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
341 |
tree) |
342 |
self.assertFileEqual(a_text, 'a') |
|
343 |
self.assertFileEqual(ba_text, 'b/a') |
|
344 |
# 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. |
345 |
self.assertEqual([('a', 'b/a')], |
346 |
tree.move(['a'], 'b', after=True)) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
347 |
self.assertTreeLayout([('', root_id), ('b/', b_id), ('b/a', a_id)], |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
348 |
tree) |
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
349 |
self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id)], |
|
2255.2.141
by John Arbash Meinel
Some small changes to move tests. |
350 |
tree.basis_tree()) |
|
2255.2.139
by John Arbash Meinel
test cases for moving after a file has already been moved. |
351 |
# But it shouldn't actually move anything
|
352 |
self.assertFileEqual(a_text, 'a') |
|
353 |
self.assertFileEqual(ba_text, 'b/a') |
|
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
354 |
tree._validate() |
|
2255.2.146
by John Arbash Meinel
Implement move_directory by factoring out move_one |
355 |
|
356 |
def test_move_directory(self): |
|
357 |
tree = self.make_branch_and_tree('.') |
|
358 |
self.build_tree(['a/', 'a/b', 'a/c/', 'a/c/d', 'e/']) |
|
359 |
tree.add(['a', 'a/b', 'a/c', 'a/c/d', 'e'], |
|
360 |
['a-id', 'b-id', 'c-id', 'd-id', 'e-id']) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
361 |
tree.commit('initial') |
|
2255.2.146
by John Arbash Meinel
Implement move_directory by factoring out move_one |
362 |
root_id = tree.get_root_id() |
363 |
||
|
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. |
364 |
self.assertEqual([('a', 'e/a')], |
365 |
tree.move(['a'], 'e')) |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
366 |
self.assertTreeLayout([('', root_id), ('e/', 'e-id'), ('e/a/', 'a-id'), |
367 |
('e/a/b', 'b-id'), ('e/a/c/', 'c-id'), |
|
|
2255.2.146
by John Arbash Meinel
Implement move_directory by factoring out move_one |
368 |
('e/a/c/d', 'd-id')], tree) |
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
369 |
self.assertTreeLayout([('', root_id), ('a/', 'a-id'), ('e/', 'e-id'), |
370 |
('a/b', 'b-id'), ('a/c/', 'c-id'), |
|
|
2255.7.9
by John Arbash Meinel
Add more tests for WorkingTree.move() and a similar suite |
371 |
('a/c/d', 'd-id')], tree.basis_tree()) |
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
372 |
tree._validate() |
|
2255.7.9
by John Arbash Meinel
Add more tests for WorkingTree.move() and a similar suite |
373 |
|
|
2438.1.3
by John Arbash Meinel
Add 2 new WT.move() tests, one of which exposes bug #105479 |
374 |
def test_move_directory_into_parent(self): |
|
6039.1.3
by Jelmer Vernooij
Cope with versioned directories in test_move_directory_into_parent. |
375 |
if not self.workingtree_format.supports_versioned_directories: |
376 |
raise tests.TestNotApplicable( |
|
377 |
"test requires versioned directories") |
|
|
2438.1.3
by John Arbash Meinel
Add 2 new WT.move() tests, one of which exposes bug #105479 |
378 |
tree = self.make_branch_and_tree('.') |
379 |
self.build_tree(['c/', 'c/b/', 'c/b/d/']) |
|
380 |
tree.add(['c', 'c/b', 'c/b/d'], |
|
381 |
['c-id', 'b-id', 'd-id']) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
382 |
tree.commit('initial') |
|
2438.1.3
by John Arbash Meinel
Add 2 new WT.move() tests, one of which exposes bug #105479 |
383 |
root_id = tree.get_root_id() |
384 |
||
385 |
self.assertEqual([('c/b', 'b')], |
|
386 |
tree.move(['c/b'], '')) |
|
387 |
self.assertTreeLayout([('', root_id), |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
388 |
('b/', 'b-id'), |
389 |
('c/', 'c-id'), |
|
390 |
('b/d/', 'd-id'), |
|
|
2438.1.3
by John Arbash Meinel
Add 2 new WT.move() tests, one of which exposes bug #105479 |
391 |
], tree) |
392 |
tree._validate() |
|
393 |
||
|
2438.1.13
by John Arbash Meinel
Add a test for moving a directory where a child has been moved into a subdir. |
394 |
def test_move_directory_with_children_in_subdir(self): |
395 |
tree = self.make_branch_and_tree('.') |
|
396 |
self.build_tree(['a/', 'a/b', 'a/c/', 'd/']) |
|
397 |
tree.add(['a', 'a/b', 'a/c', 'd'], |
|
398 |
['a-id', 'b-id', 'c-id', 'd-id']) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
399 |
tree.commit('initial') |
|
2438.1.13
by John Arbash Meinel
Add a test for moving a directory where a child has been moved into a subdir. |
400 |
root_id = tree.get_root_id() |
401 |
||
402 |
tree.rename_one('a/b', 'a/c/b') |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
403 |
self.assertTreeLayout([('', root_id), |
404 |
('a/', 'a-id'), |
|
405 |
('d/', 'd-id'), |
|
406 |
('a/c/', 'c-id'), |
|
407 |
('a/c/b', 'b-id'), |
|
408 |
], tree) |
|
|
2438.1.13
by John Arbash Meinel
Add a test for moving a directory where a child has been moved into a subdir. |
409 |
self.assertEqual([('a', 'd/a')], |
410 |
tree.move(['a'], 'd')) |
|
411 |
self.assertTreeLayout([('', root_id), |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
412 |
('d/', 'd-id'), |
413 |
('d/a/', 'a-id'), |
|
414 |
('d/a/c/', 'c-id'), |
|
|
2438.1.13
by John Arbash Meinel
Add a test for moving a directory where a child has been moved into a subdir. |
415 |
('d/a/c/b', 'b-id'), |
416 |
], tree) |
|
417 |
tree._validate() |
|
418 |
||
|
2438.1.7
by John Arbash Meinel
While in this area, add a test for renaming a directory with removed children. |
419 |
def test_move_directory_with_deleted_children(self): |
420 |
tree = self.make_branch_and_tree('.') |
|
421 |
self.build_tree(['a/', 'a/b', 'a/c', 'a/d', 'b/']) |
|
422 |
tree.add(['a', 'b', 'a/b', 'a/c', 'a/d'], |
|
423 |
['a-id', 'b-id', 'ab-id', 'ac-id', 'ad-id']) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
424 |
tree.commit('initial') |
|
2438.1.7
by John Arbash Meinel
While in this area, add a test for renaming a directory with removed children. |
425 |
root_id = tree.get_root_id() |
426 |
||
427 |
tree.remove(['a/b', 'a/d']) |
|
428 |
||
429 |
self.assertEqual([('a', 'b/a')], |
|
430 |
tree.move(['a'], 'b')) |
|
431 |
self.assertTreeLayout([('', root_id), |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
432 |
('b/', 'b-id'), |
433 |
('b/a/', 'a-id'), |
|
|
2438.1.7
by John Arbash Meinel
While in this area, add a test for renaming a directory with removed children. |
434 |
('b/a/c', 'ac-id'), |
435 |
], tree) |
|
436 |
tree._validate() |
|
437 |
||
|
2438.1.6
by John Arbash Meinel
Simplify the test since all we require is renaming a newly added entry's parent dir. |
438 |
def test_move_directory_with_new_children(self): |
|
2438.1.3
by John Arbash Meinel
Add 2 new WT.move() tests, one of which exposes bug #105479 |
439 |
tree = self.make_branch_and_tree('.') |
|
2438.1.6
by John Arbash Meinel
Simplify the test since all we require is renaming a newly added entry's parent dir. |
440 |
self.build_tree(['a/', 'a/c', 'b/']) |
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
441 |
tree.add(['a', 'b', 'a/c']) |
442 |
a_id = tree.path2id('a') |
|
443 |
b_id = tree.path2id('b') |
|
444 |
ac_id = tree.path2id('a/c') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
445 |
tree.commit('initial') |
|
2438.1.3
by John Arbash Meinel
Add 2 new WT.move() tests, one of which exposes bug #105479 |
446 |
root_id = tree.get_root_id() |
447 |
||
|
2438.1.6
by John Arbash Meinel
Simplify the test since all we require is renaming a newly added entry's parent dir. |
448 |
self.build_tree(['a/b', 'a/d']) |
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
449 |
tree.add(['a/b', 'a/d']) |
450 |
ab_id = tree.path2id('a/b') |
|
451 |
ad_id = tree.path2id('a/d') |
|
|
2438.1.3
by John Arbash Meinel
Add 2 new WT.move() tests, one of which exposes bug #105479 |
452 |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
453 |
self.assertEqual([('a', 'b/a')], tree.move(['a'], 'b')) |
|
2438.1.3
by John Arbash Meinel
Add 2 new WT.move() tests, one of which exposes bug #105479 |
454 |
self.assertTreeLayout([('', root_id), |
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
455 |
('b/', b_id), |
456 |
('b/a/', a_id), |
|
457 |
('b/a/b', ab_id), |
|
458 |
('b/a/c', ac_id), |
|
459 |
('b/a/d', ad_id), |
|
|
2438.1.3
by John Arbash Meinel
Add 2 new WT.move() tests, one of which exposes bug #105479 |
460 |
], tree) |
461 |
tree._validate() |
|
462 |
||
|
2438.1.9
by John Arbash Meinel
Add another (failing) test when we move an entry which has a renamed child. |
463 |
def test_move_directory_with_moved_children(self): |
464 |
tree = self.make_branch_and_tree('.') |
|
465 |
self.build_tree(['a/', 'a/b', 'a/c', 'd', 'e/']) |
|
466 |
tree.add(['a', 'a/b', 'a/c', 'd', 'e'], |
|
467 |
['a-id', 'b-id', 'c-id', 'd-id', 'e-id']) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
468 |
tree.commit('initial') |
|
2438.1.9
by John Arbash Meinel
Add another (failing) test when we move an entry which has a renamed child. |
469 |
root_id = tree.get_root_id() |
470 |
||
471 |
self.assertEqual([('a/b', 'b')], |
|
472 |
tree.move(['a/b'], '')) |
|
473 |
self.assertTreeLayout([('', root_id), |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
474 |
('a/', 'a-id'), |
|
2438.1.9
by John Arbash Meinel
Add another (failing) test when we move an entry which has a renamed child. |
475 |
('b', 'b-id'), |
476 |
('d', 'd-id'), |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
477 |
('e/', 'e-id'), |
|
2438.1.9
by John Arbash Meinel
Add another (failing) test when we move an entry which has a renamed child. |
478 |
('a/c', 'c-id'), |
479 |
], tree) |
|
480 |
self.assertEqual([('d', 'a/d')], |
|
481 |
tree.move(['d'], 'a')) |
|
482 |
self.assertTreeLayout([('', root_id), |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
483 |
('a/', 'a-id'), |
|
2438.1.9
by John Arbash Meinel
Add another (failing) test when we move an entry which has a renamed child. |
484 |
('b', 'b-id'), |
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
485 |
('e/', 'e-id'), |
|
2438.1.9
by John Arbash Meinel
Add another (failing) test when we move an entry which has a renamed child. |
486 |
('a/c', 'c-id'), |
487 |
('a/d', 'd-id'), |
|
488 |
], tree) |
|
489 |
self.assertEqual([('a', 'e/a')], |
|
490 |
tree.move(['a'], 'e')) |
|
491 |
self.assertTreeLayout([('', root_id), |
|
492 |
('b', 'b-id'), |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
493 |
('e/', 'e-id'), |
494 |
('e/a/', 'a-id'), |
|
|
2438.1.9
by John Arbash Meinel
Add another (failing) test when we move an entry which has a renamed child. |
495 |
('e/a/c', 'c-id'), |
496 |
('e/a/d', 'd-id'), |
|
497 |
], tree) |
|
498 |
tree._validate() |
|
499 |
||
|
2438.1.11
by John Arbash Meinel
Add a test for moving a directory with a renamed child. |
500 |
def test_move_directory_with_renamed_child(self): |
501 |
tree = self.make_branch_and_tree('.') |
|
502 |
self.build_tree(['a/', 'a/b', 'a/c', 'd/']) |
|
503 |
tree.add(['a', 'a/b', 'a/c', 'd'], |
|
504 |
['a-id', 'b-id', 'c-id', 'd-id']) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
505 |
tree.commit('initial') |
|
2438.1.11
by John Arbash Meinel
Add a test for moving a directory with a renamed child. |
506 |
root_id = tree.get_root_id() |
507 |
||
508 |
tree.rename_one('a/b', 'a/d') |
|
509 |
self.assertTreeLayout([('', root_id), |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
510 |
('a/', 'a-id'), |
511 |
('d/', 'd-id'), |
|
|
2438.1.11
by John Arbash Meinel
Add a test for moving a directory with a renamed child. |
512 |
('a/c', 'c-id'), |
513 |
('a/d', 'b-id'), |
|
514 |
], tree) |
|
515 |
self.assertEqual([('a', 'd/a')], |
|
516 |
tree.move(['a'], 'd')) |
|
517 |
self.assertTreeLayout([('', root_id), |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
518 |
('d/', 'd-id'), |
519 |
('d/a/', 'a-id'), |
|
|
2438.1.11
by John Arbash Meinel
Add a test for moving a directory with a renamed child. |
520 |
('d/a/c', 'c-id'), |
521 |
('d/a/d', 'b-id'), |
|
522 |
], tree) |
|
523 |
tree._validate() |
|
524 |
||
|
2438.1.12
by John Arbash Meinel
Add a test with children that have been swapped |
525 |
def test_move_directory_with_swapped_children(self): |
526 |
tree = self.make_branch_and_tree('.') |
|
527 |
self.build_tree(['a/', 'a/b', 'a/c', 'a/d', 'e/']) |
|
528 |
tree.add(['a', 'a/b', 'a/c', 'a/d', 'e'], |
|
529 |
['a-id', 'b-id', 'c-id', 'd-id', 'e-id']) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
530 |
tree.commit('initial') |
|
2438.1.12
by John Arbash Meinel
Add a test with children that have been swapped |
531 |
root_id = tree.get_root_id() |
532 |
||
533 |
tree.rename_one('a/b', 'a/bb') |
|
534 |
tree.rename_one('a/d', 'a/b') |
|
535 |
tree.rename_one('a/bb', 'a/d') |
|
536 |
self.assertTreeLayout([('', root_id), |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
537 |
('a/', 'a-id'), |
538 |
('e/', 'e-id'), |
|
|
2438.1.12
by John Arbash Meinel
Add a test with children that have been swapped |
539 |
('a/b', 'd-id'), |
540 |
('a/c', 'c-id'), |
|
541 |
('a/d', 'b-id'), |
|
542 |
], tree) |
|
543 |
self.assertEqual([('a', 'e/a')], |
|
544 |
tree.move(['a'], 'e')) |
|
545 |
self.assertTreeLayout([('', root_id), |
|
|
6110.6.2
by Jelmer Vernooij
In HasLayout, take into consideration Tree.has_versioned_directories. |
546 |
('e/', 'e-id'), |
547 |
('e/a/', 'a-id'), |
|
|
2438.1.12
by John Arbash Meinel
Add a test with children that have been swapped |
548 |
('e/a/b', 'd-id'), |
549 |
('e/a/c', 'c-id'), |
|
550 |
('e/a/d', 'b-id'), |
|
551 |
], tree) |
|
552 |
tree._validate() |
|
553 |
||
|
2255.7.9
by John Arbash Meinel
Add more tests for WorkingTree.move() and a similar suite |
554 |
def test_move_moved(self): |
555 |
"""Moving a moved entry works as expected.""" |
|
556 |
tree = self.make_branch_and_tree('.') |
|
557 |
self.build_tree(['a/', 'a/b', 'c/']) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
558 |
tree.add(['a', 'a/b', 'c']) |
559 |
a_id = tree.path2id('a') |
|
560 |
b_id = tree.path2id('a/b') |
|
561 |
c_id = tree.path2id('c') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
562 |
tree.commit('initial') |
|
2255.7.9
by John Arbash Meinel
Add more tests for WorkingTree.move() and a similar suite |
563 |
root_id = tree.get_root_id() |
564 |
||
|
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. |
565 |
self.assertEqual([('a/b', 'c/b')], |
566 |
tree.move(['a/b'], 'c')) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
567 |
self.assertTreeLayout([('', root_id), ('a/', a_id), ('c/', c_id), |
568 |
('c/b', b_id)], tree) |
|
569 |
self.assertTreeLayout([('', root_id), ('a/', a_id), ('c/', c_id), |
|
570 |
('a/b', b_id)], tree.basis_tree()) |
|
|
2255.7.9
by John Arbash Meinel
Add more tests for WorkingTree.move() and a similar suite |
571 |
|
|
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. |
572 |
self.assertEqual([('c/b', 'b')], |
573 |
tree.move(['c/b'], '')) |
|
|
6846.2.1
by Jelmer Vernooij
Skip a few tests that don't apply to brz-git. |
574 |
self.assertTreeLayout([('', root_id), ('a/', a_id), ('b', b_id), |
575 |
('c/', c_id)], tree) |
|
576 |
self.assertTreeLayout([('', root_id), ('a/', a_id), ('c/', c_id), |
|
577 |
('a/b', b_id)], tree.basis_tree()) |
|
|
2371.2.1
by John Arbash Meinel
Update DirState._validate() to detect rename errors. |
578 |
tree._validate() |
|
5609.8.2
by Martin
Add per_workingtree test for every error case bar one that has unicode problems |
579 |
|
580 |
def test_move_to_unversioned_non_ascii_dir(self): |
|
581 |
"""Check error when moving to unversioned non-ascii directory""" |
|
|
5967.12.3
by Martin Pool
Unify duplicated UnicodeFilename and _PosixPermissionsFeature |
582 |
self.requireFeature(features.UnicodeFilenameFeature) |
|
5609.8.2
by Martin
Add per_workingtree test for every error case bar one that has unicode problems |
583 |
tree = self.make_branch_and_tree(".") |
584 |
self.build_tree(["a", u"\xA7/"]) |
|
585 |
tree.add(["a"]) |
|
586 |
e = self.assertRaises(errors.BzrMoveFailedError, |
|
587 |
tree.move, ["a"], u"\xA7") |
|
588 |
self.assertIsInstance(e.extra, errors.NotVersionedError) |
|
589 |
self.assertEqual(e.extra.path, u"\xA7") |
|
590 |
||
591 |
def test_move_unversioned_non_ascii(self): |
|
592 |
"""Check error when moving an unversioned non-ascii file""" |
|
|
5967.12.3
by Martin Pool
Unify duplicated UnicodeFilename and _PosixPermissionsFeature |
593 |
self.requireFeature(features.UnicodeFilenameFeature) |
|
5609.8.2
by Martin
Add per_workingtree test for every error case bar one that has unicode problems |
594 |
tree = self.make_branch_and_tree(".") |
595 |
self.build_tree([u"\xA7", "dir/"]) |
|
596 |
tree.add("dir") |
|
597 |
e = self.assertRaises(errors.BzrMoveFailedError, |
|
598 |
tree.move, [u"\xA7"], "dir") |
|
599 |
self.assertIsInstance(e.extra, errors.NotVersionedError) |
|
600 |
self.assertEqual(e.extra.path, u"\xA7") |