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 |
|
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
36 |
branch_format = "pack-0.92" |
37 |
||
|
0.65.4
by James Westby
Make the rename handling more robust. |
38 |
def get_handler(self): |
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
39 |
branch = self.make_branch('.', format=self.branch_format) |
|
0.96.1
by Ian Clatworthy
update existing tests to reflect implicit directory pruning bahaviour |
40 |
handler = generic_processor.GenericProcessor(branch.bzrdir) |
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
41 |
return handler, branch |
|
0.65.4
by James Westby
Make the rename handling more robust. |
42 |
|
43 |
# FIXME: [] as a default is bad, as it is mutable, but I want
|
|
44 |
# to use None to mean "don't check this".
|
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
45 |
def assertChanges(self, branch, revno, expected_added=[], |
46 |
expected_removed=[], expected_modified=[], |
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
47 |
expected_renamed=[], expected_kind_changed=[]): |
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
48 |
"""Check the changes introduced in a revision of a branch. |
49 |
||
50 |
This method checks that a revision introduces expected changes.
|
|
51 |
The required changes are passed in as a list, where
|
|
52 |
each entry contains the needed information about the change.
|
|
53 |
||
54 |
If you do not wish to assert anything about a particular
|
|
55 |
category then pass None instead.
|
|
56 |
||
57 |
branch: The branch.
|
|
58 |
revno: revision number of revision to check.
|
|
59 |
expected_added: a list of (filename,) tuples that must have
|
|
60 |
been added in the delta.
|
|
61 |
expected_removed: a list of (filename,) tuples that must have
|
|
62 |
been removed in the delta.
|
|
63 |
expected_modified: a list of (filename,) tuples that must have
|
|
64 |
been modified in the delta.
|
|
65 |
expected_renamed: a list of (old_path, new_path) tuples that
|
|
66 |
must have been renamed in the delta.
|
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
67 |
expected_kind_changed: a list of (path, old_kind, new_kind) tuples
|
68 |
that must have been changed in the delta.
|
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
69 |
:return: revtree1, revtree2
|
70 |
"""
|
|
71 |
repo = branch.repository |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
72 |
revtree1 = repo.revision_tree(branch.get_rev_id(revno - 1)) |
73 |
revtree2 = repo.revision_tree(branch.get_rev_id(revno)) |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
74 |
changes = revtree2.changes_from(revtree1) |
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
75 |
self._check_changes(changes, expected_added, expected_removed, |
76 |
expected_modified, expected_renamed, expected_kind_changed) |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
77 |
return revtree1, revtree2 |
78 |
||
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
79 |
def _check_changes(self, changes, expected_added=[], |
|
0.65.4
by James Westby
Make the rename handling more robust. |
80 |
expected_removed=[], expected_modified=[], |
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
81 |
expected_renamed=[], expected_kind_changed=[]): |
|
0.65.4
by James Westby
Make the rename handling more robust. |
82 |
"""Check the changes in a TreeDelta |
83 |
||
84 |
This method checks that the TreeDelta contains the expected
|
|
85 |
modifications between the two trees that were used to generate
|
|
86 |
it. The required changes are passed in as a list, where
|
|
87 |
each entry contains the needed information about the change.
|
|
88 |
||
89 |
If you do not wish to assert anything about a particular
|
|
90 |
category then pass None instead.
|
|
91 |
||
92 |
changes: The TreeDelta to check.
|
|
93 |
expected_added: a list of (filename,) tuples that must have
|
|
94 |
been added in the delta.
|
|
95 |
expected_removed: a list of (filename,) tuples that must have
|
|
96 |
been removed in the delta.
|
|
97 |
expected_modified: a list of (filename,) tuples that must have
|
|
98 |
been modified in the delta.
|
|
99 |
expected_renamed: a list of (old_path, new_path) tuples that
|
|
100 |
must have been renamed in the delta.
|
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
101 |
expected_kind_changed: a list of (path, old_kind, new_kind) tuples
|
102 |
that must have been changed in the delta.
|
|
|
0.65.4
by James Westby
Make the rename handling more robust. |
103 |
"""
|
104 |
renamed = changes.renamed |
|
105 |
added = changes.added |
|
106 |
removed = changes.removed |
|
107 |
modified = changes.modified |
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
108 |
kind_changed = changes.kind_changed |
|
0.65.4
by James Westby
Make the rename handling more robust. |
109 |
if expected_renamed is not None: |
110 |
self.assertEquals(len(renamed), len(expected_renamed), |
|
|
0.74.1
by John Arbash Meinel
Change the rename code to create a new text entry. |
111 |
"%s is renamed, expected %s" % (renamed, expected_renamed)) |
|
0.65.4
by James Westby
Make the rename handling more robust. |
112 |
renamed_files = [(item[0], item[1]) for item in renamed] |
113 |
for expected_renamed_entry in expected_renamed: |
|
114 |
self.assertTrue(expected_renamed_entry in renamed_files, |
|
115 |
"%s is not renamed, %s are" % (str(expected_renamed_entry), |
|
116 |
renamed_files)) |
|
117 |
if expected_added is not None: |
|
118 |
self.assertEquals(len(added), len(expected_added), |
|
119 |
"%s is added" % str(added)) |
|
120 |
added_files = [(item[0],) for item in added] |
|
121 |
for expected_added_entry in expected_added: |
|
122 |
self.assertTrue(expected_added_entry in added_files, |
|
123 |
"%s is not added, %s are" % (str(expected_added_entry), |
|
124 |
added_files)) |
|
125 |
if expected_removed is not None: |
|
126 |
self.assertEquals(len(removed), len(expected_removed), |
|
127 |
"%s is removed" % str(removed)) |
|
128 |
removed_files = [(item[0],) for item in removed] |
|
129 |
for expected_removed_entry in expected_removed: |
|
130 |
self.assertTrue(expected_removed_entry in removed_files, |
|
131 |
"%s is not removed, %s are" % (str(expected_removed_entry), |
|
132 |
removed_files)) |
|
133 |
if expected_modified is not None: |
|
134 |
self.assertEquals(len(modified), len(expected_modified), |
|
135 |
"%s is modified" % str(modified)) |
|
136 |
modified_files = [(item[0],) for item in modified] |
|
137 |
for expected_modified_entry in expected_modified: |
|
138 |
self.assertTrue(expected_modified_entry in modified_files, |
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
139 |
"%s is not modified, %s are" % ( |
140 |
str(expected_modified_entry), modified_files)) |
|
141 |
if expected_kind_changed is not None: |
|
142 |
self.assertEquals(len(kind_changed), len(expected_kind_changed), |
|
143 |
"%s is kind-changed, expected %s" % (kind_changed, |
|
144 |
expected_kind_changed)) |
|
145 |
kind_changed_files = [(item[0], item[2], item[3]) |
|
146 |
for item in kind_changed] |
|
147 |
for expected_kind_changed_entry in expected_kind_changed: |
|
148 |
self.assertTrue(expected_kind_changed_entry in |
|
149 |
kind_changed_files, "%s is not kind-changed, %s are" % ( |
|
150 |
str(expected_kind_changed_entry), kind_changed_files)) |
|
|
0.65.4
by James Westby
Make the rename handling more robust. |
151 |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
152 |
def assertContent(self, branch, tree, path, content): |
153 |
file_id = tree.inventory.path2id(path) |
|
154 |
branch.lock_read() |
|
155 |
self.addCleanup(branch.unlock) |
|
156 |
self.assertEqual(tree.get_file_text(file_id), content) |
|
157 |
||
158 |
def assertSymlinkTarget(self, branch, tree, path, target): |
|
159 |
file_id = tree.inventory.path2id(path) |
|
160 |
branch.lock_read() |
|
161 |
self.addCleanup(branch.unlock) |
|
162 |
self.assertEqual(tree.get_symlink_target(file_id), target) |
|
163 |
||
|
0.80.4
by Ian Clatworthy
file executable off <-> on tests |
164 |
def assertExecutable(self, branch, tree, path, executable): |
165 |
file_id = tree.inventory.path2id(path) |
|
166 |
branch.lock_read() |
|
167 |
self.addCleanup(branch.unlock) |
|
168 |
self.assertEqual(tree.is_executable(file_id), executable) |
|
169 |
||
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
170 |
def assertRevisionRoot(self, revtree, path): |
171 |
self.assertEqual(revtree.get_revision_id(), |
|
172 |
revtree.inventory.root.children[path].revision) |
|
173 |
||
174 |
||
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
175 |
class TestImportToPackModify(TestCaseForGenericProcessor): |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
176 |
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
177 |
def file_command_iter(self, path, kind='file', content='aaa', |
|
0.80.4
by Ian Clatworthy
file executable off <-> on tests |
178 |
executable=False, to_kind=None, to_content='bbb', to_executable=None): |
179 |
# Revno 1: create a file or symlink
|
|
180 |
# Revno 2: modify it
|
|
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
181 |
if to_kind is None: |
182 |
to_kind = kind |
|
|
0.80.4
by Ian Clatworthy
file executable off <-> on tests |
183 |
if to_executable is None: |
184 |
to_executable = executable |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
185 |
def command_list(): |
186 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
187 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
188 |
def files_one(): |
|
|
0.80.4
by Ian Clatworthy
file executable off <-> on tests |
189 |
yield commands.FileModifyCommand(path, kind, executable, |
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
190 |
None, content) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
191 |
yield commands.CommitCommand('head', '1', author, |
192 |
committer, "commit 1", None, [], files_one) |
|
193 |
def files_two(): |
|
|
0.80.4
by Ian Clatworthy
file executable off <-> on tests |
194 |
yield commands.FileModifyCommand(path, to_kind, to_executable, |
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
195 |
None, to_content) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
196 |
yield commands.CommitCommand('head', '2', author, |
197 |
committer, "commit 2", ":1", [], files_two) |
|
198 |
return command_list |
|
199 |
||
200 |
def test_modify_file_in_root(self): |
|
201 |
handler, branch = self.get_handler() |
|
202 |
path = 'a' |
|
203 |
handler.process(self.file_command_iter(path)) |
|
204 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
205 |
expected_added=[(path,)]) |
|
206 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
207 |
expected_modified=[(path,)]) |
|
208 |
self.assertContent(branch, revtree1, path, "aaa") |
|
209 |
self.assertContent(branch, revtree2, path, "bbb") |
|
210 |
self.assertRevisionRoot(revtree1, path) |
|
211 |
self.assertRevisionRoot(revtree2, path) |
|
212 |
||
213 |
def test_modify_file_in_subdir(self): |
|
214 |
handler, branch = self.get_handler() |
|
215 |
path = 'a/a' |
|
216 |
handler.process(self.file_command_iter(path)) |
|
217 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
218 |
expected_added=[('a',), (path,)]) |
|
219 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
220 |
expected_modified=[(path,)]) |
|
221 |
self.assertContent(branch, revtree1, path, "aaa") |
|
222 |
self.assertContent(branch, revtree2, path, "bbb") |
|
223 |
||
224 |
def test_modify_symlink_in_root(self): |
|
225 |
handler, branch = self.get_handler() |
|
226 |
path = 'a' |
|
227 |
handler.process(self.file_command_iter(path, kind='symlink')) |
|
228 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
229 |
expected_modified=[(path,)]) |
|
230 |
self.assertSymlinkTarget(branch, revtree1, path, "aaa") |
|
231 |
self.assertSymlinkTarget(branch, revtree2, path, "bbb") |
|
232 |
self.assertRevisionRoot(revtree1, path) |
|
233 |
self.assertRevisionRoot(revtree2, path) |
|
234 |
||
235 |
def test_modify_symlink_in_subdir(self): |
|
236 |
handler, branch = self.get_handler() |
|
237 |
path = 'a/a' |
|
238 |
handler.process(self.file_command_iter(path, kind='symlink')) |
|
239 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
240 |
expected_added=[('a',), (path,)]) |
|
241 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
242 |
expected_modified=[(path,)]) |
|
243 |
self.assertSymlinkTarget(branch, revtree1, path, "aaa") |
|
244 |
self.assertSymlinkTarget(branch, revtree2, path, "bbb") |
|
245 |
||
|
0.80.3
by Ian Clatworthy
file <-> symlink change tests |
246 |
def test_modify_file_becomes_symlink(self): |
247 |
handler, branch = self.get_handler() |
|
248 |
path = 'a/a' |
|
249 |
handler.process(self.file_command_iter(path, |
|
250 |
kind='file', to_kind='symlink')) |
|
251 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
252 |
expected_added=[('a',), (path,)]) |
|
253 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
254 |
expected_kind_changed=[(path, 'file', 'symlink')]) |
|
255 |
self.assertContent(branch, revtree1, path, "aaa") |
|
256 |
self.assertSymlinkTarget(branch, revtree2, path, "bbb") |
|
257 |
||
258 |
def test_modify_symlink_becomes_file(self): |
|
259 |
handler, branch = self.get_handler() |
|
260 |
path = 'a/a' |
|
261 |
handler.process(self.file_command_iter(path, |
|
262 |
kind='symlink', to_kind='file')) |
|
263 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
264 |
expected_added=[('a',), (path,)]) |
|
265 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
266 |
expected_kind_changed=[(path, 'symlink', 'file')]) |
|
267 |
self.assertSymlinkTarget(branch, revtree1, path, "aaa") |
|
268 |
self.assertContent(branch, revtree2, path, "bbb") |
|
269 |
||
|
0.80.4
by Ian Clatworthy
file executable off <-> on tests |
270 |
def test_modify_file_now_executable(self): |
271 |
handler, branch = self.get_handler() |
|
272 |
path = 'a/a' |
|
273 |
handler.process(self.file_command_iter(path, |
|
274 |
executable=False, to_executable=True, to_content='aaa')) |
|
275 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
276 |
expected_added=[('a',), (path,)]) |
|
277 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
278 |
expected_modified=[(path,)]) |
|
279 |
self.assertExecutable(branch, revtree1, path, False) |
|
280 |
self.assertExecutable(branch, revtree2, path, True) |
|
281 |
||
282 |
def test_modify_file_no_longer_executable(self): |
|
283 |
handler, branch = self.get_handler() |
|
284 |
path = 'a/a' |
|
285 |
handler.process(self.file_command_iter(path, |
|
286 |
executable=True, to_executable=False, to_content='aaa')) |
|
287 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
288 |
expected_added=[('a',), (path,)]) |
|
289 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
290 |
expected_modified=[(path,)]) |
|
291 |
self.assertExecutable(branch, revtree1, path, True) |
|
292 |
self.assertExecutable(branch, revtree2, path, False) |
|
293 |
||
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
294 |
|
|
0.99.5
by Ian Clatworthy
handle adding the same file twice in the one commit |
295 |
class TestImportToPackModifyTwice(TestCaseForGenericProcessor): |
296 |
"""This tests when the same file is modified twice in the one commit. |
|
297 |
|
|
298 |
Note: hg-fast-export produces data like this on occasions.
|
|
299 |
"""
|
|
300 |
||
301 |
def file_command_iter(self, path, kind='file', content='aaa', |
|
302 |
executable=False, to_kind=None, to_content='bbb', to_executable=None): |
|
303 |
# Revno 1: create a file twice
|
|
304 |
if to_kind is None: |
|
305 |
to_kind = kind |
|
306 |
if to_executable is None: |
|
307 |
to_executable = executable |
|
308 |
def command_list(): |
|
309 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
310 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
311 |
def files_one(): |
|
312 |
yield commands.FileModifyCommand(path, kind, executable, |
|
313 |
None, content) |
|
314 |
yield commands.FileModifyCommand(path, to_kind, to_executable, |
|
315 |
None, to_content) |
|
316 |
yield commands.CommitCommand('head', '1', author, |
|
317 |
committer, "commit 1", None, [], files_one) |
|
318 |
return command_list |
|
319 |
||
320 |
def test_modify_file_twice_in_root(self): |
|
321 |
handler, branch = self.get_handler() |
|
322 |
path = 'a' |
|
323 |
handler.process(self.file_command_iter(path)) |
|
324 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
325 |
expected_added=[(path,)]) |
|
326 |
self.assertContent(branch, revtree1, path, "aaa") |
|
327 |
self.assertRevisionRoot(revtree1, path) |
|
328 |
||
329 |
||
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
330 |
class TestImportToPackModifyTricky(TestCaseForGenericProcessor): |
|
0.80.5
by Ian Clatworthy
file/symlink <-> directory change tests & fix |
331 |
|
332 |
def file_command_iter(self, path1, path2, kind='file'): |
|
333 |
# Revno 1: create a file or symlink in a directory
|
|
334 |
# Revno 2: create a second file that implicitly deletes the
|
|
335 |
# first one because either:
|
|
336 |
# * the new file is a in directory with the old file name
|
|
337 |
# * the new file has the same name as the directory of the first
|
|
338 |
def command_list(): |
|
339 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
340 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
341 |
def files_one(): |
|
342 |
yield commands.FileModifyCommand(path1, kind, False, |
|
343 |
None, "aaa") |
|
344 |
yield commands.CommitCommand('head', '1', author, |
|
345 |
committer, "commit 1", None, [], files_one) |
|
346 |
def files_two(): |
|
347 |
yield commands.FileModifyCommand(path2, kind, False, |
|
348 |
None, "bbb") |
|
349 |
yield commands.CommitCommand('head', '2', author, |
|
350 |
committer, "commit 2", ":1", [], files_two) |
|
351 |
return command_list |
|
352 |
||
353 |
||
354 |
def test_modify_file_becomes_directory(self): |
|
355 |
handler, branch = self.get_handler() |
|
356 |
path1 = 'a/b' |
|
357 |
path2 = 'a/b/c' |
|
358 |
handler.process(self.file_command_iter(path1, path2)) |
|
359 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
360 |
expected_added=[('a',), (path1,)]) |
|
361 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
362 |
expected_added=[(path2,)], |
|
363 |
expected_kind_changed=[(path1, 'file', 'directory')]) |
|
364 |
self.assertContent(branch, revtree1, path1, "aaa") |
|
365 |
self.assertContent(branch, revtree2, path2, "bbb") |
|
366 |
||
367 |
def test_modify_directory_becomes_file(self): |
|
368 |
handler, branch = self.get_handler() |
|
369 |
path1 = 'a/b/c' |
|
370 |
path2 = 'a/b' |
|
371 |
handler.process(self.file_command_iter(path1, path2)) |
|
372 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
373 |
expected_added=[('a',), ('a/b',), (path1,)]) |
|
374 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
375 |
expected_removed=[(path1,),], |
|
376 |
expected_kind_changed=[(path2, 'directory', 'file')]) |
|
377 |
self.assertContent(branch, revtree1, path1, "aaa") |
|
378 |
self.assertContent(branch, revtree2, path2, "bbb") |
|
379 |
||
380 |
def test_modify_symlink_becomes_directory(self): |
|
381 |
handler, branch = self.get_handler() |
|
382 |
path1 = 'a/b' |
|
383 |
path2 = 'a/b/c' |
|
384 |
handler.process(self.file_command_iter(path1, path2, 'symlink')) |
|
385 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
386 |
expected_added=[('a',), (path1,)]) |
|
387 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
388 |
expected_added=[(path2,)], |
|
389 |
expected_kind_changed=[(path1, 'symlink', 'directory')]) |
|
390 |
self.assertSymlinkTarget(branch, revtree1, path1, "aaa") |
|
391 |
self.assertSymlinkTarget(branch, revtree2, path2, "bbb") |
|
392 |
||
393 |
def test_modify_directory_becomes_symlink(self): |
|
394 |
handler, branch = self.get_handler() |
|
395 |
path1 = 'a/b/c' |
|
396 |
path2 = 'a/b' |
|
397 |
handler.process(self.file_command_iter(path1, path2, 'symlink')) |
|
398 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
399 |
expected_added=[('a',), ('a/b',), (path1,)]) |
|
400 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
401 |
expected_removed=[(path1,),], |
|
402 |
expected_kind_changed=[(path2, 'directory', 'symlink')]) |
|
403 |
self.assertSymlinkTarget(branch, revtree1, path1, "aaa") |
|
404 |
self.assertSymlinkTarget(branch, revtree2, path2, "bbb") |
|
405 |
||
406 |
||
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
407 |
class TestImportToPackDelete(TestCaseForGenericProcessor): |
|
0.80.2
by Ian Clatworthy
basic delete tests |
408 |
|
409 |
def file_command_iter(self, path, kind='file'): |
|
|
0.80.4
by Ian Clatworthy
file executable off <-> on tests |
410 |
# Revno 1: create a file or symlink
|
411 |
# Revno 2: delete it
|
|
|
0.80.2
by Ian Clatworthy
basic delete tests |
412 |
def command_list(): |
413 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
414 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
415 |
def files_one(): |
|
416 |
yield commands.FileModifyCommand(path, kind, False, |
|
417 |
None, "aaa") |
|
418 |
yield commands.CommitCommand('head', '1', author, |
|
419 |
committer, "commit 1", None, [], files_one) |
|
420 |
def files_two(): |
|
421 |
yield commands.FileDeleteCommand(path) |
|
422 |
yield commands.CommitCommand('head', '2', author, |
|
423 |
committer, "commit 2", ":1", [], files_two) |
|
424 |
return command_list |
|
425 |
||
426 |
def test_delete_file_in_root(self): |
|
427 |
handler, branch = self.get_handler() |
|
428 |
path = 'a' |
|
429 |
handler.process(self.file_command_iter(path)) |
|
430 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
431 |
expected_added=[(path,)]) |
|
432 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
433 |
expected_removed=[(path,)]) |
|
434 |
self.assertContent(branch, revtree1, path, "aaa") |
|
435 |
self.assertRevisionRoot(revtree1, path) |
|
436 |
||
437 |
def test_delete_file_in_subdir(self): |
|
438 |
handler, branch = self.get_handler() |
|
439 |
path = 'a/a' |
|
440 |
handler.process(self.file_command_iter(path)) |
|
441 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
442 |
expected_added=[('a',), (path,)]) |
|
443 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
|
0.96.1
by Ian Clatworthy
update existing tests to reflect implicit directory pruning bahaviour |
444 |
expected_removed=[('a',), (path,)]) |
|
0.80.2
by Ian Clatworthy
basic delete tests |
445 |
self.assertContent(branch, revtree1, path, "aaa") |
446 |
||
447 |
def test_delete_symlink_in_root(self): |
|
448 |
handler, branch = self.get_handler() |
|
449 |
path = 'a' |
|
450 |
handler.process(self.file_command_iter(path, kind='symlink')) |
|
451 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
452 |
expected_removed=[(path,)]) |
|
453 |
self.assertSymlinkTarget(branch, revtree1, path, "aaa") |
|
454 |
self.assertRevisionRoot(revtree1, path) |
|
455 |
||
456 |
def test_delete_symlink_in_subdir(self): |
|
457 |
handler, branch = self.get_handler() |
|
458 |
path = 'a/a' |
|
459 |
handler.process(self.file_command_iter(path, kind='symlink')) |
|
460 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
461 |
expected_added=[('a',), (path,)]) |
|
462 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
|
0.96.1
by Ian Clatworthy
update existing tests to reflect implicit directory pruning bahaviour |
463 |
expected_removed=[('a',), (path,)]) |
|
0.80.2
by Ian Clatworthy
basic delete tests |
464 |
self.assertSymlinkTarget(branch, revtree1, path, "aaa") |
465 |
||
|
0.96.2
by Ian Clatworthy
test and fix for implicit directory delete recursing up |
466 |
def test_delete_file_in_deep_subdir(self): |
467 |
handler, branch = self.get_handler() |
|
468 |
path = 'a/b/c/d' |
|
469 |
handler.process(self.file_command_iter(path)) |
|
470 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
471 |
expected_added=[('a',), ('a/b',), ('a/b/c',), (path,)]) |
|
472 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
473 |
expected_removed=[('a',), ('a/b',), ('a/b/c',), (path,)]) |
|
474 |
self.assertContent(branch, revtree1, path, "aaa") |
|
475 |
||
|
0.80.2
by Ian Clatworthy
basic delete tests |
476 |
|
|
0.99.7
by Ian Clatworthy
handle a delete of a newly added file |
477 |
class TestImportToPackDeleteNew(TestCaseForGenericProcessor): |
478 |
"""Test deletion of a newly added file.""" |
|
479 |
||
480 |
def file_command_iter(self, path, kind='file'): |
|
481 |
# Revno 1: create a file or symlink then delete it
|
|
482 |
def command_list(): |
|
483 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
484 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
485 |
def files_one(): |
|
486 |
yield commands.FileModifyCommand(path, kind, False, |
|
487 |
None, "aaa") |
|
488 |
yield commands.FileDeleteCommand(path) |
|
489 |
yield commands.CommitCommand('head', '1', author, |
|
490 |
committer, "commit 1", None, [], files_one) |
|
491 |
return command_list |
|
492 |
||
493 |
def test_delete_new_file_in_root(self): |
|
494 |
handler, branch = self.get_handler() |
|
495 |
path = 'a' |
|
496 |
handler.process(self.file_command_iter(path)) |
|
497 |
revtree0, revtree1 = self.assertChanges(branch, 1,) |
|
498 |
||
499 |
def test_delete_new_file_in_subdir(self): |
|
500 |
handler, branch = self.get_handler() |
|
501 |
path = 'a/a' |
|
502 |
handler.process(self.file_command_iter(path)) |
|
503 |
revtree0, revtree1 = self.assertChanges(branch, 1,) |
|
504 |
||
505 |
def test_delete_new_symlink_in_root(self): |
|
506 |
handler, branch = self.get_handler() |
|
507 |
path = 'a' |
|
508 |
handler.process(self.file_command_iter(path, kind='symlink')) |
|
509 |
revtree0, revtree1 = self.assertChanges(branch, 1,) |
|
510 |
||
511 |
def test_delete_new_symlink_in_subdir(self): |
|
512 |
handler, branch = self.get_handler() |
|
513 |
path = 'a/a' |
|
514 |
handler.process(self.file_command_iter(path, kind='symlink')) |
|
515 |
revtree0, revtree1 = self.assertChanges(branch, 1,) |
|
516 |
||
517 |
def test_delete_new_file_in_deep_subdir(self): |
|
518 |
handler, branch = self.get_handler() |
|
519 |
path = 'a/b/c/d' |
|
520 |
handler.process(self.file_command_iter(path)) |
|
521 |
revtree0, revtree1 = self.assertChanges(branch, 1,) |
|
522 |
||
523 |
||
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
524 |
class TestImportToPackDeleteDirectory(TestCaseForGenericProcessor): |
|
0.80.7
by Ian Clatworthy
add directory delete test |
525 |
|
526 |
def file_command_iter(self, paths, dir): |
|
527 |
# Revno 1: create multiple files
|
|
528 |
# Revno 2: delete a directory holding those files
|
|
529 |
def command_list(): |
|
530 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
531 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
532 |
def files_one(): |
|
533 |
for i, path in enumerate(paths): |
|
534 |
yield commands.FileModifyCommand(path, 'file', False, |
|
535 |
None, "aaa%d" % i) |
|
536 |
yield commands.CommitCommand('head', '1', author, |
|
537 |
committer, "commit 1", None, [], files_one) |
|
538 |
def files_two(): |
|
539 |
yield commands.FileDeleteCommand(dir) |
|
540 |
yield commands.CommitCommand('head', '2', author, |
|
541 |
committer, "commit 2", ":1", [], files_two) |
|
542 |
return command_list |
|
543 |
||
544 |
def test_delete_dir(self): |
|
545 |
handler, branch = self.get_handler() |
|
546 |
paths = ['a/b/c', 'a/b/d', 'a/b/e/f', 'a/g'] |
|
547 |
dir = 'a/b' |
|
548 |
handler.process(self.file_command_iter(paths, dir)) |
|
549 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
550 |
expected_added=[ |
|
551 |
('a',), ('a/b',), ('a/b/c',), |
|
552 |
('a/b/d',), |
|
553 |
('a/b/e',), ('a/b/e/f',), |
|
554 |
('a/g',), |
|
555 |
])
|
|
556 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
557 |
expected_removed=[ |
|
558 |
('a/b',), ('a/b/c',), |
|
559 |
('a/b/d',), |
|
560 |
('a/b/e',), ('a/b/e/f',), |
|
561 |
])
|
|
562 |
||
563 |
||
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
564 |
class TestImportToPackRename(TestCaseForGenericProcessor): |
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
565 |
|
566 |
def get_command_iter(self, old_path, new_path): |
|
|
0.80.4
by Ian Clatworthy
file executable off <-> on tests |
567 |
# Revno 1: create a file or symlink
|
568 |
# Revno 2: rename it
|
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
569 |
def command_list(): |
570 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
571 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
572 |
def files_one(): |
|
573 |
yield commands.FileModifyCommand(old_path, 'file', False, |
|
574 |
None, "aaa") |
|
575 |
yield commands.CommitCommand('head', '1', author, |
|
576 |
committer, "commit 1", None, [], files_one) |
|
577 |
def files_two(): |
|
578 |
yield commands.FileRenameCommand(old_path, new_path) |
|
579 |
yield commands.CommitCommand('head', '2', author, |
|
580 |
committer, "commit 2", ":1", [], files_two) |
|
581 |
return command_list |
|
582 |
||
|
0.65.4
by James Westby
Make the rename handling more robust. |
583 |
def test_rename_in_root(self): |
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
584 |
handler, branch = self.get_handler() |
|
0.65.4
by James Westby
Make the rename handling more robust. |
585 |
old_path = 'a' |
586 |
new_path = 'b' |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
587 |
handler.process(self.get_command_iter(old_path, new_path)) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
588 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
589 |
expected_renamed=[(old_path, new_path)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
590 |
self.assertRevisionRoot(revtree1, old_path) |
591 |
self.assertRevisionRoot(revtree2, new_path) |
|
|
0.65.4
by James Westby
Make the rename handling more robust. |
592 |
|
593 |
def test_rename_in_subdir(self): |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
594 |
handler, branch = self.get_handler() |
|
0.65.4
by James Westby
Make the rename handling more robust. |
595 |
old_path = 'a/a' |
596 |
new_path = 'a/b' |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
597 |
handler.process(self.get_command_iter(old_path, new_path)) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
598 |
self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)]) |
|
0.65.4
by James Westby
Make the rename handling more robust. |
599 |
|
600 |
def test_move_to_new_dir(self): |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
601 |
handler, branch = self.get_handler() |
|
0.65.4
by James Westby
Make the rename handling more robust. |
602 |
old_path = 'a/a' |
603 |
new_path = 'b/a' |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
604 |
handler.process(self.get_command_iter(old_path, new_path)) |
|
0.96.1
by Ian Clatworthy
update existing tests to reflect implicit directory pruning bahaviour |
605 |
self.assertChanges(branch, 2, |
606 |
expected_renamed=[(old_path, new_path)], |
|
607 |
expected_added=[('b',)], |
|
608 |
expected_removed=[('a',)]) |
|
|
0.64.74
by Ian Clatworthy
fix symlink importing |
609 |
|
610 |
||
|
0.99.6
by Ian Clatworthy
Handle rename of a just added file |
611 |
class TestImportToPackRenameNew(TestCaseForGenericProcessor): |
612 |
||
613 |
def get_command_iter(self, old_path, new_path): |
|
614 |
# Revno 1: create a file and rename it
|
|
615 |
def command_list(): |
|
616 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
617 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
618 |
def files_one(): |
|
619 |
yield commands.FileModifyCommand(old_path, 'file', False, |
|
620 |
None, "aaa") |
|
621 |
yield commands.FileRenameCommand(old_path, new_path) |
|
622 |
yield commands.CommitCommand('head', '1', author, |
|
623 |
committer, "commit 1", None, [], files_one) |
|
624 |
return command_list |
|
625 |
||
626 |
def test_rename_new_in_root(self): |
|
627 |
handler, branch = self.get_handler() |
|
628 |
old_path = 'a' |
|
629 |
new_path = 'b' |
|
630 |
handler.process(self.get_command_iter(old_path, new_path)) |
|
631 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
632 |
expected_added=[(new_path,)]) |
|
633 |
self.assertRevisionRoot(revtree1, new_path) |
|
634 |
||
635 |
def test_rename_new_in_subdir(self): |
|
636 |
handler, branch = self.get_handler() |
|
637 |
old_path = 'a/a' |
|
638 |
new_path = 'a/b' |
|
639 |
handler.process(self.get_command_iter(old_path, new_path)) |
|
640 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
641 |
expected_added=[('a',), (new_path,)]) |
|
642 |
||
643 |
||
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
644 |
class TestImportToPackRenameTricky(TestCaseForGenericProcessor): |
|
0.80.6
by Ian Clatworthy
file/symlink <-> directory rename tests |
645 |
|
646 |
def file_command_iter(self, path1, old_path2, new_path2, kind='file'): |
|
647 |
# Revno 1: create two files or symlinks in a directory
|
|
648 |
# Revno 2: rename the second file so that it implicitly deletes the
|
|
649 |
# first one because either:
|
|
650 |
# * the new file is a in directory with the old file name
|
|
651 |
# * the new file has the same name as the directory of the first
|
|
652 |
def command_list(): |
|
653 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
654 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
655 |
def files_one(): |
|
656 |
yield commands.FileModifyCommand(path1, kind, False, |
|
657 |
None, "aaa") |
|
658 |
yield commands.FileModifyCommand(old_path2, kind, False, |
|
659 |
None, "bbb") |
|
660 |
yield commands.CommitCommand('head', '1', author, |
|
661 |
committer, "commit 1", None, [], files_one) |
|
662 |
def files_two(): |
|
663 |
yield commands.FileRenameCommand(old_path2, new_path2) |
|
664 |
yield commands.CommitCommand('head', '2', author, |
|
665 |
committer, "commit 2", ":1", [], files_two) |
|
666 |
return command_list |
|
667 |
||
668 |
||
669 |
def test_rename_file_becomes_directory(self): |
|
670 |
handler, branch = self.get_handler() |
|
671 |
old_path2 = 'foo' |
|
672 |
path1 = 'a/b' |
|
673 |
new_path2 = 'a/b/c' |
|
674 |
handler.process(self.file_command_iter(path1, old_path2, new_path2)) |
|
675 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
676 |
expected_added=[('a',), (path1,), (old_path2,)]) |
|
677 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
678 |
expected_renamed=[(old_path2, new_path2)], |
|
679 |
expected_kind_changed=[(path1, 'file', 'directory')]) |
|
680 |
self.assertContent(branch, revtree1, path1, "aaa") |
|
681 |
self.assertContent(branch, revtree2, new_path2, "bbb") |
|
682 |
||
683 |
def test_rename_directory_becomes_file(self): |
|
684 |
handler, branch = self.get_handler() |
|
685 |
old_path2 = 'foo' |
|
686 |
path1 = 'a/b/c' |
|
687 |
new_path2 = 'a/b' |
|
688 |
handler.process(self.file_command_iter(path1, old_path2, new_path2)) |
|
689 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
690 |
expected_added=[('a',), ('a/b',), (path1,), (old_path2,)]) |
|
691 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
692 |
expected_renamed=[(old_path2, new_path2)], |
|
693 |
expected_removed=[(path1,), (new_path2,)]) |
|
694 |
self.assertContent(branch, revtree1, path1, "aaa") |
|
695 |
self.assertContent(branch, revtree2, new_path2, "bbb") |
|
696 |
||
697 |
def test_rename_symlink_becomes_directory(self): |
|
698 |
handler, branch = self.get_handler() |
|
699 |
old_path2 = 'foo' |
|
700 |
path1 = 'a/b' |
|
701 |
new_path2 = 'a/b/c' |
|
702 |
handler.process(self.file_command_iter(path1, old_path2, new_path2, |
|
703 |
'symlink')) |
|
704 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
705 |
expected_added=[('a',), (path1,), (old_path2,)]) |
|
706 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
707 |
expected_renamed=[(old_path2, new_path2)], |
|
708 |
expected_kind_changed=[(path1, 'symlink', 'directory')]) |
|
709 |
self.assertSymlinkTarget(branch, revtree1, path1, "aaa") |
|
710 |
self.assertSymlinkTarget(branch, revtree2, new_path2, "bbb") |
|
711 |
||
712 |
def test_rename_directory_becomes_symlink(self): |
|
713 |
handler, branch = self.get_handler() |
|
714 |
old_path2 = 'foo' |
|
715 |
path1 = 'a/b/c' |
|
716 |
new_path2 = 'a/b' |
|
717 |
handler.process(self.file_command_iter(path1, old_path2, new_path2, |
|
718 |
'symlink')) |
|
719 |
revtree0, revtree1 = self.assertChanges(branch, 1, |
|
720 |
expected_added=[('a',), ('a/b',), (path1,), (old_path2,)]) |
|
721 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
722 |
expected_renamed=[(old_path2, new_path2)], |
|
723 |
expected_removed=[(path1,), (new_path2,)]) |
|
724 |
self.assertSymlinkTarget(branch, revtree1, path1, "aaa") |
|
725 |
self.assertSymlinkTarget(branch, revtree2, new_path2, "bbb") |
|
726 |
||
727 |
||
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
728 |
class TestImportToPackCopy(TestCaseForGenericProcessor): |
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
729 |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
730 |
def file_command_iter(self, src_path, dest_path, kind='file'): |
|
0.80.4
by Ian Clatworthy
file executable off <-> on tests |
731 |
# Revno 1: create a file or symlink
|
732 |
# Revno 2: copy it
|
|
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
733 |
def command_list(): |
734 |
author = ['', 'bugs@a.com', time.time(), time.timezone] |
|
735 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
736 |
def files_one(): |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
737 |
yield commands.FileModifyCommand(src_path, kind, False, |
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
738 |
None, "aaa") |
739 |
yield commands.CommitCommand('head', '1', author, |
|
740 |
committer, "commit 1", None, [], files_one) |
|
741 |
def files_two(): |
|
742 |
yield commands.FileCopyCommand(src_path, dest_path) |
|
743 |
yield commands.CommitCommand('head', '2', author, |
|
744 |
committer, "commit 2", ":1", [], files_two) |
|
745 |
return command_list |
|
746 |
||
747 |
def test_copy_file_in_root(self): |
|
748 |
handler, branch = self.get_handler() |
|
749 |
src_path = 'a' |
|
750 |
dest_path = 'b' |
|
751 |
handler.process(self.file_command_iter(src_path, dest_path)) |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
752 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
753 |
expected_added=[(dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
754 |
self.assertContent(branch, revtree1, src_path, "aaa") |
755 |
self.assertContent(branch, revtree2, src_path, "aaa") |
|
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
756 |
self.assertContent(branch, revtree2, dest_path, "aaa") |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
757 |
self.assertRevisionRoot(revtree1, src_path) |
758 |
self.assertRevisionRoot(revtree2, dest_path) |
|
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
759 |
|
760 |
def test_copy_file_in_subdir(self): |
|
761 |
handler, branch = self.get_handler() |
|
762 |
src_path = 'a/a' |
|
763 |
dest_path = 'a/b' |
|
764 |
handler.process(self.file_command_iter(src_path, dest_path)) |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
765 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
766 |
expected_added=[(dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
767 |
self.assertContent(branch, revtree1, src_path, "aaa") |
768 |
self.assertContent(branch, revtree2, src_path, "aaa") |
|
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
769 |
self.assertContent(branch, revtree2, dest_path, "aaa") |
770 |
||
771 |
def test_copy_file_to_new_dir(self): |
|
772 |
handler, branch = self.get_handler() |
|
773 |
src_path = 'a/a' |
|
774 |
dest_path = 'b/a' |
|
775 |
handler.process(self.file_command_iter(src_path, dest_path)) |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
776 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
777 |
expected_added=[('b',), (dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
778 |
self.assertContent(branch, revtree1, src_path, "aaa") |
779 |
self.assertContent(branch, revtree2, src_path, "aaa") |
|
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
780 |
self.assertContent(branch, revtree2, dest_path, "aaa") |
781 |
||
|
0.76.3
by Ian Clatworthy
symlink copying tests |
782 |
def test_copy_symlink_in_root(self): |
783 |
handler, branch = self.get_handler() |
|
784 |
src_path = 'a' |
|
785 |
dest_path = 'b' |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
786 |
handler.process(self.file_command_iter(src_path, dest_path, 'symlink')) |
787 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
788 |
expected_added=[(dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
789 |
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa") |
790 |
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa") |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
791 |
self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa") |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
792 |
self.assertRevisionRoot(revtree1, src_path) |
793 |
self.assertRevisionRoot(revtree2, dest_path) |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
794 |
|
795 |
def test_copy_symlink_in_subdir(self): |
|
796 |
handler, branch = self.get_handler() |
|
797 |
src_path = 'a/a' |
|
798 |
dest_path = 'a/b' |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
799 |
handler.process(self.file_command_iter(src_path, dest_path, 'symlink')) |
800 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
801 |
expected_added=[(dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
802 |
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa") |
803 |
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa") |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
804 |
self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa") |
805 |
||
806 |
def test_copy_symlink_to_new_dir(self): |
|
807 |
handler, branch = self.get_handler() |
|
808 |
src_path = 'a/a' |
|
809 |
dest_path = 'b/a' |
|
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
810 |
handler.process(self.file_command_iter(src_path, dest_path, 'symlink')) |
811 |
revtree1, revtree2 = self.assertChanges(branch, 2, |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
812 |
expected_added=[('b',), (dest_path,)]) |
|
0.80.1
by Ian Clatworthy
basic units tests for filemodify |
813 |
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa") |
814 |
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa") |
|
|
0.76.3
by Ian Clatworthy
symlink copying tests |
815 |
self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa") |
816 |
||
|
0.76.2
by Ian Clatworthy
code & tests for file copying |
817 |
|
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
818 |
class TestImportToPackFileKinds(TestCaseForGenericProcessor): |
|
0.64.74
by Ian Clatworthy
fix symlink importing |
819 |
|
820 |
def get_command_iter(self, path, kind, content): |
|
821 |
def command_list(): |
|
822 |
committer = ['', 'elmer@a.com', time.time(), time.timezone] |
|
823 |
def files_one(): |
|
824 |
yield commands.FileModifyCommand(path, kind, False, |
|
825 |
None, content) |
|
826 |
yield commands.CommitCommand('head', '1', None, |
|
827 |
committer, "commit 1", None, [], files_one) |
|
828 |
return command_list |
|
829 |
||
830 |
def test_import_plainfile(self): |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
831 |
handler, branch = self.get_handler() |
832 |
handler.process(self.get_command_iter('foo', 'file', 'aaa')) |
|
|
0.64.74
by Ian Clatworthy
fix symlink importing |
833 |
|
834 |
def test_import_symlink(self): |
|
|
0.76.1
by Ian Clatworthy
clean-up tests for GenericProcessor |
835 |
handler, branch = self.get_handler() |
836 |
handler.process(self.get_command_iter('foo', 'symlink', 'bar')) |
|
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
837 |
|
838 |
||
839 |
### TODO: Parameterise tests rather than below hack
|
|
840 |
||
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
841 |
class TestImportToRichRootModify(TestImportToPackModify): |
842 |
branch_format = "1.9-rich-root" |
|
843 |
||
|
0.99.5
by Ian Clatworthy
handle adding the same file twice in the one commit |
844 |
class TestImportToRichRootModifyTwice(TestImportToPackModifyTwice): |
845 |
branch_format = "1.9-rich-root" |
|
846 |
||
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
847 |
class TestImportToRichRootModifyTricky(TestImportToPackModifyTricky): |
848 |
branch_format = "1.9-rich-root" |
|
849 |
||
850 |
class TestImportToRichRootDelete(TestImportToPackDelete): |
|
851 |
branch_format = "1.9-rich-root" |
|
852 |
||
|
0.99.7
by Ian Clatworthy
handle a delete of a newly added file |
853 |
class TestImportToRichRootDeleteNew(TestImportToPackDeleteNew): |
854 |
branch_format = "1.9-rich-root" |
|
855 |
||
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
856 |
class TestImportToRichRootDeleteDirectory(TestImportToPackDeleteDirectory): |
857 |
branch_format = "1.9-rich-root" |
|
858 |
||
859 |
class TestImportToRichRootRename(TestImportToPackRename): |
|
860 |
branch_format = "1.9-rich-root" |
|
861 |
||
|
0.99.6
by Ian Clatworthy
Handle rename of a just added file |
862 |
class TestImportToRichRootRenameNew(TestImportToPackRenameNew): |
863 |
branch_format = "1.9-rich-root" |
|
864 |
||
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
865 |
class TestImportToRichRootRenameTricky(TestImportToPackRenameTricky): |
866 |
branch_format = "1.9-rich-root" |
|
867 |
||
868 |
class TestImportToRichRootCopy(TestImportToPackCopy): |
|
869 |
branch_format = "1.9-rich-root" |
|
870 |
||
871 |
class TestImportToRichRootFileKinds(TestImportToPackFileKinds): |
|
872 |
branch_format = "1.9-rich-root" |
|
873 |
||
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
874 |
try: |
|
0.64.179
by Ian Clatworthy
upgrade tests to use --development6-rich-root |
875 |
from bzrlib.repofmt.groupcompress_repo import RepositoryFormatCHK1 |
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
876 |
|
877 |
class TestImportToChkModify(TestImportToPackModify): |
|
|
0.64.179
by Ian Clatworthy
upgrade tests to use --development6-rich-root |
878 |
branch_format = "development6-rich-root" |
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
879 |
|
|
0.99.5
by Ian Clatworthy
handle adding the same file twice in the one commit |
880 |
class TestImportToChkModifyTwice(TestImportToPackModifyTwice): |
881 |
branch_format = "development6-rich-root" |
|
882 |
||
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
883 |
class TestImportToChkModifyTricky(TestImportToPackModifyTricky): |
|
0.64.179
by Ian Clatworthy
upgrade tests to use --development6-rich-root |
884 |
branch_format = "development6-rich-root" |
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
885 |
|
886 |
class TestImportToChkDelete(TestImportToPackDelete): |
|
|
0.64.179
by Ian Clatworthy
upgrade tests to use --development6-rich-root |
887 |
branch_format = "development6-rich-root" |
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
888 |
|
|
0.99.7
by Ian Clatworthy
handle a delete of a newly added file |
889 |
class TestImportToChkDeleteNew(TestImportToPackDeleteNew): |
890 |
branch_format = "development6-rich-root" |
|
891 |
||
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
892 |
class TestImportToChkDeleteDirectory(TestImportToPackDeleteDirectory): |
|
0.64.179
by Ian Clatworthy
upgrade tests to use --development6-rich-root |
893 |
branch_format = "development6-rich-root" |
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
894 |
|
895 |
class TestImportToChkRename(TestImportToPackRename): |
|
|
0.64.179
by Ian Clatworthy
upgrade tests to use --development6-rich-root |
896 |
branch_format = "development6-rich-root" |
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
897 |
|
|
0.99.6
by Ian Clatworthy
Handle rename of a just added file |
898 |
class TestImportToChkRenameNew(TestImportToPackRenameNew): |
899 |
branch_format = "development6-rich-root" |
|
900 |
||
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
901 |
class TestImportToChkRenameTricky(TestImportToPackRenameTricky): |
|
0.64.179
by Ian Clatworthy
upgrade tests to use --development6-rich-root |
902 |
branch_format = "development6-rich-root" |
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
903 |
|
904 |
class TestImportToChkCopy(TestImportToPackCopy): |
|
|
0.64.179
by Ian Clatworthy
upgrade tests to use --development6-rich-root |
905 |
branch_format = "development6-rich-root" |
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
906 |
|
907 |
class TestImportToChkFileKinds(TestImportToPackFileKinds): |
|
|
0.64.179
by Ian Clatworthy
upgrade tests to use --development6-rich-root |
908 |
branch_format = "development6-rich-root" |
|
0.85.1
by Ian Clatworthy
extend tests to test the chk code path |
909 |
|
910 |
except ImportError: |
|
911 |
pass
|