bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.65.4
by James Westby
Make the rename handling more robust. |
1 |
# Copyright (C) 2008 Canonical Ltd
|
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 |
||
17 |
import time |
|
18 |
||
19 |
from bzrlib import ( |
|
20 |
branch, |
|
21 |
tests, |
|
22 |
)
|
|
23 |
||
24 |
from bzrlib.plugins.fastimport import ( |
|
25 |
commands, |
|
26 |
errors, |
|
27 |
)
|
|
28 |
||
29 |
from bzrlib.plugins.fastimport.processors import ( |
|
30 |
generic_processor, |
|
31 |
)
|
|
32 |
||
33 |
||
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
34 |
class TestCaseForGenericProcessor(tests.TestCaseWithTransport): |
|
0.65.4
by James Westby
Make the rename handling more robust. |
35 |
|
36 |
def get_handler(self): |
|
37 |
branch = self.make_branch('.') |
|
38 |
handler = generic_processor.GenericProcessor(branch.bzrdir) |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
39 |
return handler, branch |
|
0.65.4
by James Westby
Make the rename handling more robust. |
40 |
|
41 |
# FIXME: [] as a default is bad, as it is mutable, but I want
|
|
42 |
# to use None to mean "don't check this".
|
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
43 |
def assertChanges(self, branch, revno, expected_added=[], |
44 |
expected_removed=[], expected_modified=[], |
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
45 |
expected_renamed=[], expected_kind_changed=[]): |
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
46 |
"""Check the changes introduced in a revision of a branch. |
47 |
||
48 |
This method checks that a revision introduces expected changes.
|
|
49 |
The required changes are passed in as a list, where
|
|
50 |
each entry contains the needed information about the change.
|
|
51 |
||
52 |
If you do not wish to assert anything about a particular
|
|
53 |
category then pass None instead.
|
|
54 |
||
55 |
branch: The branch.
|
|
56 |
revno: revision number of revision to check.
|
|
57 |
expected_added: a list of (filename,) tuples that must have
|
|
58 |
been added in the delta.
|
|
59 |
expected_removed: a list of (filename,) tuples that must have
|
|
60 |
been removed in the delta.
|
|
61 |
expected_modified: a list of (filename,) tuples that must have
|
|
62 |
been modified in the delta.
|
|
63 |
expected_renamed: a list of (old_path, new_path) tuples that
|
|
64 |
must have been renamed in the delta.
|
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
65 |
expected_kind_changed: a list of (path, old_kind, new_kind) tuples
|
66 |
that must have been changed in the delta.
|
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
67 |
:return: revtree1, revtree2
|
68 |
"""
|
|
69 |
repo = branch.repository |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
70 |
revtree1 = repo.revision_tree(branch.get_rev_id(revno - 1)) |
71 |
revtree2 = repo.revision_tree(branch.get_rev_id(revno)) |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
72 |
changes = revtree2.changes_from(revtree1) |
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
73 |
self._check_changes(changes, expected_added, expected_removed, |
74 |
expected_modified, expected_renamed, expected_kind_changed) |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
75 |
return revtree1, revtree2 |
76 |
||
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
77 |
def _check_changes(self, changes, expected_added=[], |
|
0.65.4
by James Westby
Make the rename handling more robust. |
78 |
expected_removed=[], expected_modified=[], |
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
79 |
expected_renamed=[], expected_kind_changed=[]): |
|
0.65.4
by James Westby
Make the rename handling more robust. |
80 |
"""Check the changes in a TreeDelta |
81 |
||
82 |
This method checks that the TreeDelta contains the expected
|
|
83 |
modifications between the two trees that were used to generate
|
|
84 |
it. The required changes are passed in as a list, where
|
|
85 |
each entry contains the needed information about the change.
|
|
86 |
||
87 |
If you do not wish to assert anything about a particular
|
|
88 |
category then pass None instead.
|
|
89 |
||
90 |
changes: The TreeDelta to check.
|
|
91 |
expected_added: a list of (filename,) tuples that must have
|
|
92 |
been added in the delta.
|
|
93 |
expected_removed: a list of (filename,) tuples that must have
|
|
94 |
been removed in the delta.
|
|
95 |
expected_modified: a list of (filename,) tuples that must have
|
|
96 |
been modified in the delta.
|
|
97 |
expected_renamed: a list of (old_path, new_path) tuples that
|
|
98 |
must have been renamed in the delta.
|
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
99 |
expected_kind_changed: a list of (path, old_kind, new_kind) tuples
|
100 |
that must have been changed in the delta.
|
|
|
0.65.4
by James Westby
Make the rename handling more robust. |
101 |
"""
|
102 |
renamed = changes.renamed |
|
103 |
added = changes.added |
|
104 |
removed = changes.removed |
|
105 |
modified = changes.modified |
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
106 |
kind_changed = changes.kind_changed |
|
0.65.4
by James Westby
Make the rename handling more robust. |
107 |
if expected_renamed is not None: |
108 |
self.assertEquals(len(renamed), len(expected_renamed), |
|
|
0.74.1
by John Arbash Meinel
Change the rename code to create a new text entry. |
109 |
"%s is renamed, expected %s" % (renamed, expected_renamed)) |
|
0.65.4
by James Westby
Make the rename handling more robust. |
110 |
renamed_files = [(item[0], item[1]) for item in renamed] |
111 |
for expected_renamed_entry in expected_renamed: |
|
112 |
self.assertTrue(expected_renamed_entry in renamed_files, |
|
113 |
"%s is not renamed, %s are" % (str(expected_renamed_entry), |
|
114 |
renamed_files)) |
|
115 |
if expected_added is not None: |
|
116 |
self.assertEquals(len(added), len(expected_added), |
|
117 |
"%s is added" % str(added)) |
|
118 |
added_files = [(item[0],) for item in added] |
|
119 |
for expected_added_entry in expected_added: |
|
120 |
self.assertTrue(expected_added_entry in added_files, |
|
121 |
"%s is not added, %s are" % (str(expected_added_entry), |
|
122 |
added_files)) |
|
123 |
if expected_removed is not None: |
|
124 |
self.assertEquals(len(removed), len(expected_removed), |
|
125 |
"%s is removed" % str(removed)) |
|
126 |
removed_files = [(item[0],) for item in removed] |
|
127 |
for expected_removed_entry in expected_removed: |
|
128 |
self.assertTrue(expected_removed_entry in removed_files, |
|
129 |
"%s is not removed, %s are" % (str(expected_removed_entry), |
|
130 |
removed_files)) |
|
131 |
if expected_modified is not None: |
|
132 |
self.assertEquals(len(modified), len(expected_modified), |
|
133 |
"%s is modified" % str(modified)) |
|
134 |
modified_files = [(item[0],) for item in modified] |
|
135 |
for expected_modified_entry in expected_modified: |
|
136 |
self.assertTrue(expected_modified_entry in modified_files, |
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
137 |
"%s is not modified, %s are" % ( |
138 |
str(expected_modified_entry), modified_files)) |
|
139 |
if expected_kind_changed is not None: |
|
140 |
self.assertEquals(len(kind_changed), len(expected_kind_changed), |
|
141 |
"%s is kind-changed, expected %s" % (kind_changed, |
|
142 |
expected_kind_changed)) |
|
143 |
kind_changed_files = [(item[0], item[2], item[3]) |
|
144 |
for item in kind_changed] |
|
145 |
for expected_kind_changed_entry in expected_kind_changed: |
|
146 |
self.assertTrue(expected_kind_changed_entry in |
|
147 |
kind_changed_files, "%s is not kind-changed, %s are" % ( |
|
148 |
str(expected_kind_changed_entry), kind_changed_files)) |
|
|
0.65.4
by James Westby
Make the rename handling more robust. |
149 |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
150 |
def assertContent(self, branch, tree, path, content): |
151 |
file_id = tree.inventory.path2id(path) |
|
152 |
branch.lock_read() |
|
153 |
self.addCleanup(branch.unlock) |
|
154 |
self.assertEqual(tree.get_file_text(file_id), content) |
|
155 |
||
156 |
def assertSymlinkTarget(self, branch, tree, path, target): |
|
157 |
file_id = tree.inventory.path2id(path) |
|
158 |
branch.lock_read() |
|
159 |
self.addCleanup(branch.unlock) |
|
160 |
self.assertEqual(tree.get_symlink_target(file_id), target) |
|
161 |
||
162 |
def assertRevisionRoot(self, revtree, path): |
|
163 |
self.assertEqual(revtree.get_revision_id(), |
|
164 |
revtree.inventory.root.children[path].revision) |
|
165 |
||
166 |
||
167 |
class TestModify(TestCaseForGenericProcessor): |
|
168 |
||
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
169 |
def file_command_iter(self, path, kind='file', content='aaa', |
170 |
to_kind=None, to_content='bbb'): |
|
171 |
if to_kind is None: |
|
172 |
to_kind = kind |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
173 |
def command_list(): |
174 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
175 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
176 |
def files_one(): |
|
177 |
yield commands.FileModifyCommand(path, kind, False, |
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
178 |
None, content) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
179 |
yield commands.CommitCommand('head', '1', author, |
180 |
committer, "commit 1", None, [], files_one) |
|
181 |
def files_two(): |
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
182 |
yield commands.FileModifyCommand(path, to_kind, False, |
183 |
None, to_content) |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
184 |
yield commands.CommitCommand('head', '2', author, |
185 |
committer, "commit 2", ":1", [], files_two) |
|
186 |
return command_list |
|
187 |
||
188 |
def test_modify_file_in_root(self): |
|
189 |
handler, branch = self.get_handler() |
|
190 |
path = 'a' |
|
191 |
handler.process(self.file_command_iter(path)) |
|
192 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
193 |
expected_added=[(path,)]) |
|
194 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
195 |
expected_modified=[(path,)]) |
|
196 |
self.assertContent(branch, revtree1, path, "aaa") |
|
197 |
self.assertContent(branch, revtree2, path, "bbb") |
|
198 |
self.assertRevisionRoot(revtree1, path) |
|
199 |
self.assertRevisionRoot(revtree2, path) |
|
200 |
||
201 |
def test_modify_file_in_subdir(self): |
|
202 |
handler, branch = self.get_handler() |
|
203 |
path = 'a/a' |
|
204 |
handler.process(self.file_command_iter(path)) |
|
205 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
206 |
expected_added=[('a',), (path,)]) |
|
207 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
208 |
expected_modified=[(path,)]) |
|
209 |
self.assertContent(branch, revtree1, path, "aaa") |
|
210 |
self.assertContent(branch, revtree2, path, "bbb") |
|
211 |
||
212 |
def test_modify_symlink_in_root(self): |
|
213 |
handler, branch = self.get_handler() |
|
214 |
path = 'a' |
|
215 |
handler.process(self.file_command_iter(path, kind='symlink')) |
|
216 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
217 |
expected_modified=[(path,)]) |
|
218 |
self.assertSymlinkTarget(branch, revtree1, path, "aaa") |
|
219 |
self.assertSymlinkTarget(branch, revtree2, path, "bbb") |
|
220 |
self.assertRevisionRoot(revtree1, path) |
|
221 |
self.assertRevisionRoot(revtree2, path) |
|
222 |
||
223 |
def test_modify_symlink_in_subdir(self): |
|
224 |
handler, branch = self.get_handler() |
|
225 |
path = 'a/a' |
|
226 |
handler.process(self.file_command_iter(path, kind='symlink')) |
|
227 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
228 |
expected_added=[('a',), (path,)]) |
|
229 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
230 |
expected_modified=[(path,)]) |
|
231 |
self.assertSymlinkTarget(branch, revtree1, path, "aaa") |
|
232 |
self.assertSymlinkTarget(branch, revtree2, path, "bbb") |
|
233 |
||
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
234 |
def test_modify_file_becomes_symlink(self): |
235 |
handler, branch = self.get_handler() |
|
236 |
path = 'a/a' |
|
237 |
handler.process(self.file_command_iter(path, |
|
238 |
kind='file', to_kind='symlink')) |
|
239 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
240 |
expected_added=[('a',), (path,)]) |
|
241 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
242 |
expected_kind_changed=[(path, 'file', 'symlink')]) |
|
243 |
self.assertContent(branch, revtree1, path, "aaa") |
|
244 |
self.assertSymlinkTarget(branch, revtree2, path, "bbb") |
|
245 |
||
246 |
def test_modify_symlink_becomes_file(self): |
|
247 |
handler, branch = self.get_handler() |
|
248 |
path = 'a/a' |
|
249 |
handler.process(self.file_command_iter(path, |
|
250 |
kind='symlink', to_kind='file')) |
|
251 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
252 |
expected_added=[('a',), (path,)]) |
|
253 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
254 |
expected_kind_changed=[(path, 'symlink', 'file')]) |
|
255 |
self.assertSymlinkTarget(branch, revtree1, path, "aaa") |
|
256 |
self.assertContent(branch, revtree2, path, "bbb") |
|
257 |
||
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
258 |
|
|
0.80.2
by Ian Clatworthy
basic delete tests |
259 |
class TestDelete(TestCaseForGenericProcessor): |
260 |
||
261 |
def file_command_iter(self, path, kind='file'): |
|
262 |
def command_list(): |
|
263 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
264 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
265 |
def files_one(): |
|
266 |
yield commands.FileModifyCommand(path, kind, False, |
|
267 |
None, "aaa") |
|
268 |
yield commands.CommitCommand('head', '1', author, |
|
269 |
committer, "commit 1", None, [], files_one) |
|
270 |
def files_two(): |
|
271 |
yield commands.FileDeleteCommand(path) |
|
272 |
yield commands.CommitCommand('head', '2', author, |
|
273 |
committer, "commit 2", ":1", [], files_two) |
|
274 |
return command_list |
|
275 |
||
276 |
def test_delete_file_in_root(self): |
|
277 |
handler, branch = self.get_handler() |
|
278 |
path = 'a' |
|
279 |
handler.process(self.file_command_iter(path)) |
|
280 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
281 |
expected_added=[(path,)]) |
|
282 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
283 |
expected_removed=[(path,)]) |
|
284 |
self.assertContent(branch, revtree1, path, "aaa") |
|
285 |
self.assertRevisionRoot(revtree1, path) |
|
286 |
||
287 |
def test_delete_file_in_subdir(self): |
|
288 |
handler, branch = self.get_handler() |
|
289 |
path = 'a/a' |
|
290 |
handler.process(self.file_command_iter(path)) |
|
291 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
292 |
expected_added=[('a',), (path,)]) |
|
293 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
294 |
expected_removed=[(path,)]) |
|
295 |
self.assertContent(branch, revtree1, path, "aaa") |
|
296 |
||
297 |
def test_delete_symlink_in_root(self): |
|
298 |
handler, branch = self.get_handler() |
|
299 |
path = 'a' |
|
300 |
handler.process(self.file_command_iter(path, kind='symlink')) |
|
301 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
302 |
expected_removed=[(path,)]) |
|
303 |
self.assertSymlinkTarget(branch, revtree1, path, "aaa") |
|
304 |
self.assertRevisionRoot(revtree1, path) |
|
305 |
||
306 |
def test_delete_symlink_in_subdir(self): |
|
307 |
handler, branch = self.get_handler() |
|
308 |
path = 'a/a' |
|
309 |
handler.process(self.file_command_iter(path, kind='symlink')) |
|
310 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
311 |
expected_added=[('a',), (path,)]) |
|
312 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
313 |
expected_removed=[(path,)]) |
|
314 |
self.assertSymlinkTarget(branch, revtree1, path, "aaa") |
|
315 |
||
316 |
||
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
317 |
class TestRename(TestCaseForGenericProcessor): |
318 |
||
319 |
def get_command_iter(self, old_path, new_path): |
|
320 |
def command_list(): |
|
321 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
322 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
323 |
def files_one(): |
|
324 |
yield commands.FileModifyCommand(old_path, 'file', False, |
|
325 |
None, "aaa") |
|
326 |
yield commands.CommitCommand('head', '1', author, |
|
327 |
committer, "commit 1", None, [], files_one) |
|
328 |
def files_two(): |
|
329 |
yield commands.FileRenameCommand(old_path, new_path) |
|
330 |
yield commands.CommitCommand('head', '2', author, |
|
331 |
committer, "commit 2", ":1", [], files_two) |
|
332 |
return command_list |
|
333 |
||
|
0.65.4
by James Westby
Make the rename handling more robust. |
334 |
def test_rename_in_root(self): |
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
335 |
handler, branch = self.get_handler() |
|
0.65.4
by James Westby
Make the rename handling more robust. |
336 |
old_path = 'a' |
337 |
new_path = 'b' |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
338 |
handler.process(self.get_command_iter(old_path, new_path)) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
339 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
340 |
expected_renamed=[(old_path, new_path)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
341 |
self.assertRevisionRoot(revtree1, old_path) |
342 |
self.assertRevisionRoot(revtree2, new_path) |
|
|
0.65.4
by James Westby
Make the rename handling more robust. |
343 |
|
344 |
def test_rename_in_subdir(self): |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
345 |
handler, branch = self.get_handler() |
|
0.65.4
by James Westby
Make the rename handling more robust. |
346 |
old_path = 'a/a' |
347 |
new_path = 'a/b' |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
348 |
handler.process(self.get_command_iter(old_path, new_path)) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
349 |
self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)]) |
|
0.65.4
by James Westby
Make the rename handling more robust. |
350 |
|
351 |
def test_move_to_new_dir(self): |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
352 |
handler, branch = self.get_handler() |
|
0.65.4
by James Westby
Make the rename handling more robust. |
353 |
old_path = 'a/a' |
354 |
new_path = 'b/a' |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
355 |
handler.process(self.get_command_iter(old_path, new_path)) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
356 |
self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)], |
|
0.65.4
by James Westby
Make the rename handling more robust. |
357 |
expected_added=[('b',)]) |
|
0.64.74
by Ian Clatworthy
fix symlink importing |
358 |
|
359 |
||
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
360 |
class TestCopy(TestCaseForGenericProcessor): |
361 |
||
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
362 |
def file_command_iter(self, src_path, dest_path, kind='file'): |
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
363 |
def command_list(): |
364 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
365 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
366 |
def files_one(): |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
367 |
yield commands.FileModifyCommand(src_path, kind, False, |
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
368 |
None, "aaa") |
369 |
yield commands.CommitCommand('head', '1', author, |
|
370 |
committer, "commit 1", None, [], files_one) |
|
371 |
def files_two(): |
|
372 |
yield commands.FileCopyCommand(src_path, dest_path) |
|
373 |
yield commands.CommitCommand('head', '2', author, |
|
374 |
committer, "commit 2", ":1", [], files_two) |
|
375 |
return command_list |
|
376 |
||
377 |
def test_copy_file_in_root(self): |
|
378 |
handler, branch = self.get_handler() |
|
379 |
src_path = 'a' |
|
380 |
dest_path = 'b' |
|
381 |
handler.process(self.file_command_iter(src_path, dest_path)) |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
382 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
383 |
expected_added=[(dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
384 |
self.assertContent(branch, revtree1, src_path, "aaa") |
385 |
self.assertContent(branch, revtree2, src_path, "aaa") |
|
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
386 |
self.assertContent(branch, revtree2, dest_path, "aaa") |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
387 |
self.assertRevisionRoot(revtree1, src_path) |
388 |
self.assertRevisionRoot(revtree2, dest_path) |
|
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
389 |
|
390 |
def test_copy_file_in_subdir(self): |
|
391 |
handler, branch = self.get_handler() |
|
392 |
src_path = 'a/a' |
|
393 |
dest_path = 'a/b' |
|
394 |
handler.process(self.file_command_iter(src_path, dest_path)) |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
395 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
396 |
expected_added=[(dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
397 |
self.assertContent(branch, revtree1, src_path, "aaa") |
398 |
self.assertContent(branch, revtree2, src_path, "aaa") |
|
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
399 |
self.assertContent(branch, revtree2, dest_path, "aaa") |
400 |
||
401 |
def test_copy_file_to_new_dir(self): |
|
402 |
handler, branch = self.get_handler() |
|
403 |
src_path = 'a/a' |
|
404 |
dest_path = 'b/a' |
|
405 |
handler.process(self.file_command_iter(src_path, dest_path)) |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
406 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
407 |
expected_added=[('b',), (dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
408 |
self.assertContent(branch, revtree1, src_path, "aaa") |
409 |
self.assertContent(branch, revtree2, src_path, "aaa") |
|
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
410 |
self.assertContent(branch, revtree2, dest_path, "aaa") |
411 |
||
|
0.76.3
by Ian Clatworthy
symlink copying tests |
412 |
def test_copy_symlink_in_root(self): |
413 |
handler, branch = self.get_handler() |
|
414 |
src_path = 'a' |
|
415 |
dest_path = 'b' |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
416 |
handler.process(self.file_command_iter(src_path, dest_path, 'symlink')) |
417 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
418 |
expected_added=[(dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
419 |
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa") |
420 |
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa") |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
421 |
self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa") |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
422 |
self.assertRevisionRoot(revtree1, src_path) |
423 |
self.assertRevisionRoot(revtree2, dest_path) |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
424 |
|
425 |
def test_copy_symlink_in_subdir(self): |
|
426 |
handler, branch = self.get_handler() |
|
427 |
src_path = 'a/a' |
|
428 |
dest_path = 'a/b' |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
429 |
handler.process(self.file_command_iter(src_path, dest_path, 'symlink')) |
430 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
431 |
expected_added=[(dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
432 |
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa") |
433 |
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa") |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
434 |
self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa") |
435 |
||
436 |
def test_copy_symlink_to_new_dir(self): |
|
437 |
handler, branch = self.get_handler() |
|
438 |
src_path = 'a/a' |
|
439 |
dest_path = 'b/a' |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
440 |
handler.process(self.file_command_iter(src_path, dest_path, 'symlink')) |
441 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
442 |
expected_added=[('b',), (dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
443 |
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa") |
444 |
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa") |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
445 |
self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa") |
446 |
||
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
447 |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
448 |
class TestFileKinds(TestCaseForGenericProcessor): |
|
0.64.74
by Ian Clatworthy
fix symlink importing |
449 |
|
450 |
def get_command_iter(self, path, kind, content): |
|
451 |
def command_list(): |
|
452 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
453 |
def files_one(): |
|
454 |
yield commands.FileModifyCommand(path, kind, False, |
|
455 |
None, content) |
|
456 |
yield commands.CommitCommand('head', '1', None, |
|
457 |
committer, "commit 1", None, [], files_one) |
|
458 |
return command_list |
|
459 |
||
460 |
def test_import_plainfile(self): |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
461 |
handler, branch = self.get_handler() |
462 |
handler.process(self.get_command_iter('foo', 'file', 'aaa')) |
|
|
0.64.74
by Ian Clatworthy
fix symlink importing |
463 |
|
464 |
def test_import_symlink(self): |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
465 |
handler, branch = self.get_handler() |
466 |
handler.process(self.get_command_iter('foo', 'symlink', 'bar')) |