/brz/remove-bazaar

To get this branch, use:
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.101.1 by Tom Widmer
Add test cases to check deletions from multiple levels in a tree still cause pruning of empty dirs to happen correctly.
524
class TestImportToPackDeleteMultiLevel(TestCaseForGenericProcessor):
525
526
    def file_command_iter(self, paths, paths_to_delete):
527
        # Revno 1: create multiple files
528
        # Revno 2: delete multiple 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
                for path in paths_to_delete:
540
                    yield commands.FileDeleteCommand(path)
541
            yield commands.CommitCommand('head', '2', author,
542
                committer, "commit 2", ":1", [], files_two)
543
        return command_list
544
545
    def test_delete_files_in_multiple_levels(self):
546
        handler, branch = self.get_handler()
547
        paths = ['a/b/c', 'a/b/d/e']
548
        paths_to_delete = ['a/b/c', 'a/b/d/e']
549
        handler.process(self.file_command_iter(paths, paths_to_delete))
550
        revtree0, revtree1 = self.assertChanges(branch, 1,
551
            expected_added=[
552
                ('a',), ('a/b',), ('a/b/c',),
553
                ('a/b/d',), ('a/b/d/e',),
554
                ])
555
        revtree1, revtree2 = self.assertChanges(branch, 2,
556
            expected_removed=[
557
                ('a',), ('a/b',), ('a/b/c',),
558
                ('a/b/d',), ('a/b/d/e',),
559
                ])
560
561
    def test_delete_file_single_level(self):
562
        handler, branch = self.get_handler()
563
        paths = ['a/b/c', 'a/b/d/e']
564
        paths_to_delete = ['a/b/d/e']
565
        handler.process(self.file_command_iter(paths, paths_to_delete))
566
        revtree0, revtree1 = self.assertChanges(branch, 1,
567
            expected_added=[
568
                ('a',), ('a/b',), ('a/b/c',),
569
                ('a/b/d',), ('a/b/d/e',),
570
                ])
571
        revtree1, revtree2 = self.assertChanges(branch, 2,
572
            expected_removed=[
573
                ('a/b/d',), ('a/b/d/e',),
574
                ])
575
576
    def test_delete_file_complex_level(self):
577
        handler, branch = self.get_handler()
578
        paths = ['a/b/c', 'a/b/d/e', 'a/f/g', 'a/h', 'a/b/d/i/j']
579
        paths_to_delete = ['a/b/c', 'a/b/d/e', 'a/f/g', 'a/b/d/i/j']
580
        handler.process(self.file_command_iter(paths, paths_to_delete))
581
        revtree0, revtree1 = self.assertChanges(branch, 1,
582
            expected_added=[
583
                ('a',), ('a/b',), ('a/b/c',),
584
                ('a/b/d',), ('a/b/d/e',),
585
                ('a/f',), ('a/f/g',),
586
                ('a/h',),
587
                ('a/b/d/i',), ('a/b/d/i/j',),
588
                ])
589
        revtree1, revtree2 = self.assertChanges(branch, 2,
590
            expected_removed=[
591
                ('a/b',), ('a/b/c',),
592
                ('a/b/d',), ('a/b/d/e',),
593
                ('a/f',), ('a/f/g',),
594
                ('a/b/d/i',), ('a/b/d/i/j',),
595
                ])
596
0.99.13 by Ian Clatworthy
Handle delete then add of a file/symlink in the one commit
597
class TestImportToPackDeleteThenAdd(TestCaseForGenericProcessor):
598
    """Test delete followed by an add. Merges can cause this."""
599
600
    def file_command_iter(self, path, kind='file', content='aaa',
601
        executable=False, to_kind=None, to_content='bbb', to_executable=None):
602
        # Revno 1: create a file or symlink
603
        # Revno 2: delete it and add it
604
        if to_kind is None:
605
            to_kind = kind
606
        if to_executable is None:
607
            to_executable = executable
608
        def command_list():
609
            author = ['', 'bugs@a.com', time.time(), time.timezone]
610
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
611
            def files_one():
612
                yield commands.FileModifyCommand(path, kind, executable,
613
                        None, content)
614
            yield commands.CommitCommand('head', '1', author,
615
                committer, "commit 1", None, [], files_one)
616
            def files_two():
617
                yield commands.FileDeleteCommand(path)
618
                yield commands.FileModifyCommand(path, to_kind, to_executable,
619
                        None, to_content)
620
            yield commands.CommitCommand('head', '2', author,
621
                committer, "commit 2", ":1", [], files_two)
622
        return command_list
623
624
    def test_delete_then_add_file_in_root(self):
625
        handler, branch = self.get_handler()
626
        path = 'a'
627
        handler.process(self.file_command_iter(path))
628
        revtree0, revtree1 = self.assertChanges(branch, 1,
629
            expected_added=[(path,)])
630
        revtree1, revtree2 = self.assertChanges(branch, 2,
631
            expected_removed=[(path,)],
632
            expected_added=[(path,)])
633
        self.assertContent(branch, revtree1, path, "aaa")
634
        self.assertContent(branch, revtree2, path, "bbb")
635
        self.assertRevisionRoot(revtree1, path)
636
        self.assertRevisionRoot(revtree2, path)
637
638
    def test_delete_then_add_file_in_subdir(self):
639
        handler, branch = self.get_handler()
640
        path = 'a/a'
641
        handler.process(self.file_command_iter(path))
642
        revtree0, revtree1 = self.assertChanges(branch, 1,
643
            expected_added=[('a',), (path,)])
644
        revtree1, revtree2 = self.assertChanges(branch, 2,
645
            expected_removed=[(path,)],
646
            expected_added=[(path,)])
647
        self.assertContent(branch, revtree1, path, "aaa")
648
        self.assertContent(branch, revtree2, path, "bbb")
649
650
    def test_delete_then_add_symlink_in_root(self):
651
        handler, branch = self.get_handler()
652
        path = 'a'
653
        handler.process(self.file_command_iter(path, kind='symlink'))
654
        revtree1, revtree2 = self.assertChanges(branch, 2,
655
            expected_removed=[(path,)],
656
            expected_added=[(path,)])
657
        self.assertSymlinkTarget(branch, revtree1, path, "aaa")
658
        self.assertSymlinkTarget(branch, revtree2, path, "bbb")
659
        self.assertRevisionRoot(revtree1, path)
660
        self.assertRevisionRoot(revtree2, path)
661
662
    def test_delete_then_add_symlink_in_subdir(self):
663
        handler, branch = self.get_handler()
664
        path = 'a/a'
665
        handler.process(self.file_command_iter(path, kind='symlink'))
666
        revtree0, revtree1 = self.assertChanges(branch, 1,
667
            expected_added=[('a',), (path,)])
668
        revtree1, revtree2 = self.assertChanges(branch, 2,
669
            expected_removed=[(path,)],
670
            expected_added=[(path,)])
671
        self.assertSymlinkTarget(branch, revtree1, path, "aaa")
672
        self.assertSymlinkTarget(branch, revtree2, path, "bbb")
673
674
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
675
class TestImportToPackDeleteDirectory(TestCaseForGenericProcessor):
0.80.7 by Ian Clatworthy
add directory delete test
676
677
    def file_command_iter(self, paths, dir):
678
        # Revno 1: create multiple files
679
        # Revno 2: delete a directory holding those files
680
        def command_list():
681
            author = ['', 'bugs@a.com', time.time(), time.timezone]
682
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
683
            def files_one():
684
                for i, path in enumerate(paths):
685
                    yield commands.FileModifyCommand(path, 'file', False,
686
                            None, "aaa%d" % i)
687
            yield commands.CommitCommand('head', '1', author,
688
                committer, "commit 1", None, [], files_one)
689
            def files_two():
690
                yield commands.FileDeleteCommand(dir)
691
            yield commands.CommitCommand('head', '2', author,
692
                committer, "commit 2", ":1", [], files_two)
693
        return command_list
694
695
    def test_delete_dir(self):
696
        handler, branch = self.get_handler()
697
        paths = ['a/b/c', 'a/b/d', 'a/b/e/f', 'a/g']
698
        dir = 'a/b'
699
        handler.process(self.file_command_iter(paths, dir))
700
        revtree0, revtree1 = self.assertChanges(branch, 1,
701
            expected_added=[
702
                ('a',), ('a/b',), ('a/b/c',),
703
                ('a/b/d',),
704
                ('a/b/e',), ('a/b/e/f',),
705
                ('a/g',),
706
                ])
707
        revtree1, revtree2 = self.assertChanges(branch, 2,
708
            expected_removed=[
709
                ('a/b',), ('a/b/c',),
710
                ('a/b/d',),
711
                ('a/b/e',), ('a/b/e/f',),
712
                ])
713
714
0.99.21 by Ian Clatworthy
Handle deleting a directory then adding a file within it in the same commit
715
class TestImportToPackDeleteDirectoryThenAddFile(TestCaseForGenericProcessor):
716
    """Test deleting a directory then adding a file in the same commit."""
717
718
    def file_command_iter(self, paths, dir, new_path, kind='file'):
719
        # Revno 1: create files in a directory
720
        # Revno 2: delete the directory then add a file into it
721
        def command_list():
722
            author = ['', 'bugs@a.com', time.time(), time.timezone]
723
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
724
            def files_one():
725
                for i, path in enumerate(paths):
726
                    yield commands.FileModifyCommand(path, kind, False,
727
                            None, "aaa%d" % i)
728
            yield commands.CommitCommand('head', '1', author,
729
                committer, "commit 1", None, [], files_one)
730
            def files_two():
731
                yield commands.FileDeleteCommand(dir)
732
                yield commands.FileModifyCommand(new_path, kind, False,
733
                        None, "bbb")
734
            yield commands.CommitCommand('head', '2', author,
735
                committer, "commit 2", ":1", [], files_two)
736
        return command_list
737
738
    def test_delete_dir_then_add_file(self):
739
        handler, branch = self.get_handler()
740
        paths = ['a/b/c', 'a/b/d']
741
        dir = 'a/b'
742
        new_path = 'a/b/z'
743
        handler.process(self.file_command_iter(paths, dir, new_path))
744
        revtree0, revtree1 = self.assertChanges(branch, 1,
745
            expected_added=[('a',), ('a/b',), ('a/b/c',), ('a/b/d',),])
746
        revtree1, revtree2 = self.assertChanges(branch, 2,
747
            expected_removed=[('a/b',), ('a/b/c',), ('a/b/d',)],
748
            expected_added=[('a/b',), ('a/b/z',)])
749
        self.assertContent(branch, revtree2, new_path, "bbb")
750
751
    def test_delete_dir_then_add_symlink(self):
752
        handler, branch = self.get_handler()
753
        paths = ['a/b/c', 'a/b/d']
754
        dir = 'a/b'
755
        new_path = 'a/b/z'
756
        handler.process(self.file_command_iter(paths, dir, new_path, 'symlink'))
757
        revtree0, revtree1 = self.assertChanges(branch, 1,
758
            expected_added=[('a',), ('a/b',), ('a/b/c',), ('a/b/d',),])
759
        revtree1, revtree2 = self.assertChanges(branch, 2,
760
            expected_removed=[('a/b',), ('a/b/c',), ('a/b/d',)],
761
            expected_added=[('a/b',), ('a/b/z',)])
762
        self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
763
764
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
765
class TestImportToPackRename(TestCaseForGenericProcessor):
0.76.1 by Ian Clatworthy
clean-up tests for GenericProcessor
766
0.99.16 by Ian Clatworthy
add tests for symlink renaming
767
    def get_command_iter(self, old_path, new_path, kind='file'):
0.80.4 by Ian Clatworthy
file executable off <-> on tests
768
        # Revno 1: create a file or symlink
769
        # Revno 2: rename it
0.76.1 by Ian Clatworthy
clean-up tests for GenericProcessor
770
        def command_list():
771
            author = ['', 'bugs@a.com', time.time(), time.timezone]
772
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
773
            def files_one():
0.99.16 by Ian Clatworthy
add tests for symlink renaming
774
                yield commands.FileModifyCommand(old_path, kind, False,
0.76.1 by Ian Clatworthy
clean-up tests for GenericProcessor
775
                        None, "aaa")
776
            yield commands.CommitCommand('head', '1', author,
777
                committer, "commit 1", None, [], files_one)
778
            def files_two():
779
                yield commands.FileRenameCommand(old_path, new_path)
780
            yield commands.CommitCommand('head', '2', author,
781
                committer, "commit 2", ":1", [], files_two)
782
        return command_list
783
0.99.16 by Ian Clatworthy
add tests for symlink renaming
784
    def test_rename_file_in_root(self):
785
        handler, branch = self.get_handler()
786
        old_path = 'a'
787
        new_path = 'b'
788
        handler.process(self.get_command_iter(old_path, new_path))
789
        revtree1, revtree2 = self.assertChanges(branch, 2,
790
            expected_renamed=[(old_path, new_path)])
791
        self.assertRevisionRoot(revtree1, old_path)
792
        self.assertRevisionRoot(revtree2, new_path)
793
794
    def test_rename_symlink_in_root(self):
795
        handler, branch = self.get_handler()
796
        old_path = 'a'
797
        new_path = 'b'
798
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
799
        revtree1, revtree2 = self.assertChanges(branch, 2,
800
            expected_renamed=[(old_path, new_path)])
801
        self.assertRevisionRoot(revtree1, old_path)
802
        self.assertRevisionRoot(revtree2, new_path)
803
804
    def test_rename_file_in_subdir(self):
805
        handler, branch = self.get_handler()
806
        old_path = 'a/a'
807
        new_path = 'a/b'
808
        handler.process(self.get_command_iter(old_path, new_path))
809
        self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)])
810
811
    def test_rename_symlink_in_subdir(self):
812
        handler, branch = self.get_handler()
813
        old_path = 'a/a'
814
        new_path = 'a/b'
815
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
816
        self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)])
817
818
    def test_rename_file_to_new_dir(self):
819
        handler, branch = self.get_handler()
820
        old_path = 'a/a'
821
        new_path = 'b/a'
822
        handler.process(self.get_command_iter(old_path, new_path))
823
        self.assertChanges(branch, 2,
824
            expected_renamed=[(old_path, new_path)],
825
            expected_added=[('b',)],
826
            expected_removed=[('a',)])
827
828
    def test_rename_symlink_to_new_dir(self):
829
        handler, branch = self.get_handler()
830
        old_path = 'a/a'
831
        new_path = 'b/a'
832
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
0.96.1 by Ian Clatworthy
update existing tests to reflect implicit directory pruning bahaviour
833
        self.assertChanges(branch, 2,
834
            expected_renamed=[(old_path, new_path)],
835
            expected_added=[('b',)],
836
            expected_removed=[('a',)])
0.64.74 by Ian Clatworthy
fix symlink importing
837
838
0.99.6 by Ian Clatworthy
Handle rename of a just added file
839
class TestImportToPackRenameNew(TestCaseForGenericProcessor):
0.99.8 by Ian Clatworthy
handle copy of a newly added file
840
    """Test rename of a newly added file."""
0.99.6 by Ian Clatworthy
Handle rename of a just added file
841
0.99.16 by Ian Clatworthy
add tests for symlink renaming
842
    def get_command_iter(self, old_path, new_path, kind='file'):
0.99.6 by Ian Clatworthy
Handle rename of a just added file
843
        # Revno 1: create a file and rename it
844
        def command_list():
845
            author = ['', 'bugs@a.com', time.time(), time.timezone]
846
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
847
            def files_one():
0.99.16 by Ian Clatworthy
add tests for symlink renaming
848
                yield commands.FileModifyCommand(old_path, kind, False,
0.99.6 by Ian Clatworthy
Handle rename of a just added file
849
                        None, "aaa")
850
                yield commands.FileRenameCommand(old_path, new_path)
851
            yield commands.CommitCommand('head', '1', author,
852
                committer, "commit 1", None, [], files_one)
853
        return command_list
854
0.99.16 by Ian Clatworthy
add tests for symlink renaming
855
    def test_rename_new_file_in_root(self):
856
        handler, branch = self.get_handler()
857
        old_path = 'a'
858
        new_path = 'b'
859
        handler.process(self.get_command_iter(old_path, new_path))
860
        revtree0, revtree1 = self.assertChanges(branch, 1,
861
            expected_added=[(new_path,)])
862
        self.assertRevisionRoot(revtree1, new_path)
863
864
    def test_rename_new_symlink_in_root(self):
865
        handler, branch = self.get_handler()
866
        old_path = 'a'
867
        new_path = 'b'
868
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
869
        revtree0, revtree1 = self.assertChanges(branch, 1,
870
            expected_added=[(new_path,)])
871
        self.assertRevisionRoot(revtree1, new_path)
872
873
    def test_rename_new_file_in_subdir(self):
874
        handler, branch = self.get_handler()
875
        old_path = 'a/a'
876
        new_path = 'a/b'
877
        handler.process(self.get_command_iter(old_path, new_path))
878
        revtree0, revtree1 = self.assertChanges(branch, 1,
879
            expected_added=[('a',), (new_path,)])
880
881
    def test_rename_new_symlink_in_subdir(self):
882
        handler, branch = self.get_handler()
883
        old_path = 'a/a'
884
        new_path = 'a/b'
885
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
0.99.6 by Ian Clatworthy
Handle rename of a just added file
886
        revtree0, revtree1 = self.assertChanges(branch, 1,
887
            expected_added=[('a',), (new_path,)])
888
889
0.99.14 by Ian Clatworthy
Add tests for renaming to a deleted destination
890
class TestImportToPackRenameToDeleted(TestCaseForGenericProcessor):
891
    """Test rename to a destination path deleted in this commit."""
892
0.99.16 by Ian Clatworthy
add tests for symlink renaming
893
    def get_command_iter(self, old_path, new_path, kind='file'):
0.99.14 by Ian Clatworthy
Add tests for renaming to a deleted destination
894
        # Revno 1: create two files
895
        # Revno 2: delete one, rename the other one to that path
896
        def command_list():
897
            author = ['', 'bugs@a.com', time.time(), time.timezone]
898
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
899
            def files_one():
0.99.16 by Ian Clatworthy
add tests for symlink renaming
900
                yield commands.FileModifyCommand(old_path, kind, False,
0.99.14 by Ian Clatworthy
Add tests for renaming to a deleted destination
901
                        None, "aaa")
0.99.16 by Ian Clatworthy
add tests for symlink renaming
902
                yield commands.FileModifyCommand(new_path, kind, False,
0.99.14 by Ian Clatworthy
Add tests for renaming to a deleted destination
903
                        None, "bbb")
904
            yield commands.CommitCommand('head', '1', author,
905
                committer, "commit 1", None, [], files_one)
906
            def files_two():
907
                yield commands.FileDeleteCommand(new_path)
908
                yield commands.FileRenameCommand(old_path, new_path)
909
            yield commands.CommitCommand('head', '2', author,
910
                committer, "commit 2", ":1", [], files_two)
911
        return command_list
912
0.99.16 by Ian Clatworthy
add tests for symlink renaming
913
    def test_rename_to_deleted_file_in_root(self):
914
        handler, branch = self.get_handler()
915
        old_path = 'a'
916
        new_path = 'b'
917
        handler.process(self.get_command_iter(old_path, new_path))
918
        revtree0, revtree1 = self.assertChanges(branch, 1,
919
            expected_added=[(old_path,), (new_path,)])
920
        revtree1, revtree2 = self.assertChanges(branch, 2,
921
            expected_removed=[(new_path,)],
922
            expected_renamed=[(old_path, new_path)])
923
        self.assertContent(branch, revtree1, old_path, "aaa")
924
        self.assertContent(branch, revtree1, new_path, "bbb")
925
        self.assertContent(branch, revtree2, new_path, "aaa")
926
        self.assertRevisionRoot(revtree1, old_path)
927
        self.assertRevisionRoot(revtree1, new_path)
928
929
    def test_rename_to_deleted_symlink_in_root(self):
930
        handler, branch = self.get_handler()
931
        old_path = 'a'
932
        new_path = 'b'
933
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
934
        revtree0, revtree1 = self.assertChanges(branch, 1,
935
            expected_added=[(old_path,), (new_path,)])
936
        revtree1, revtree2 = self.assertChanges(branch, 2,
937
            expected_removed=[(new_path,)],
938
            expected_renamed=[(old_path, new_path)])
939
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
940
        self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
941
        self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
942
        self.assertRevisionRoot(revtree1, old_path)
943
        self.assertRevisionRoot(revtree1, new_path)
944
945
    def test_rename_to_deleted_file_in_subdir(self):
946
        handler, branch = self.get_handler()
947
        old_path = 'd/a'
948
        new_path = 'd/b'
949
        handler.process(self.get_command_iter(old_path, new_path))
950
        revtree0, revtree1 = self.assertChanges(branch, 1,
951
            expected_added=[('d',), (old_path,), (new_path,)])
952
        revtree1, revtree2 = self.assertChanges(branch, 2,
953
            expected_removed=[(new_path,)],
954
            expected_renamed=[(old_path, new_path)])
955
        self.assertContent(branch, revtree1, old_path, "aaa")
956
        self.assertContent(branch, revtree1, new_path, "bbb")
957
        self.assertContent(branch, revtree2, new_path, "aaa")
958
959
    def test_rename_to_deleted_symlink_in_subdir(self):
960
        handler, branch = self.get_handler()
961
        old_path = 'd/a'
962
        new_path = 'd/b'
963
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
964
        revtree0, revtree1 = self.assertChanges(branch, 1,
965
            expected_added=[('d',), (old_path,), (new_path,)])
966
        revtree1, revtree2 = self.assertChanges(branch, 2,
967
            expected_removed=[(new_path,)],
968
            expected_renamed=[(old_path, new_path)])
969
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
970
        self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
971
        self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
972
973
    def test_rename_to_deleted_file_in_new_dir(self):
974
        handler, branch = self.get_handler()
975
        old_path = 'd1/a'
976
        new_path = 'd2/b'
977
        handler.process(self.get_command_iter(old_path, new_path))
978
        revtree0, revtree1 = self.assertChanges(branch, 1,
979
            expected_added=[('d1',), (old_path,), ('d2',), (new_path,)])
980
        revtree1, revtree2 = self.assertChanges(branch, 2,
981
            expected_removed=[('d1',), (new_path,)],
982
            expected_renamed=[(old_path, new_path)])
983
        self.assertContent(branch, revtree1, old_path, "aaa")
984
        self.assertContent(branch, revtree1, new_path, "bbb")
985
        self.assertContent(branch, revtree2, new_path, "aaa")
986
987
    def test_rename_to_deleted_symlink_in_new_dir(self):
988
        handler, branch = self.get_handler()
989
        old_path = 'd1/a'
990
        new_path = 'd2/b'
991
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
992
        revtree0, revtree1 = self.assertChanges(branch, 1,
993
            expected_added=[('d1',), (old_path,), ('d2',), (new_path,)])
994
        revtree1, revtree2 = self.assertChanges(branch, 2,
995
            expected_removed=[('d1',), (new_path,)],
996
            expected_renamed=[(old_path, new_path)])
997
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
998
        self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
999
        self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
0.99.14 by Ian Clatworthy
Add tests for renaming to a deleted destination
1000
1001
0.99.17 by Ian Clatworthy
Handle rename of a file/symlink modified already in this commit
1002
class TestImportToPackRenameModified(TestCaseForGenericProcessor):
1003
    """Test rename of a path previously modified in this commit."""
1004
1005
    def get_command_iter(self, old_path, new_path, kind='file'):
1006
        # Revno 1: create a file or symlink
1007
        # Revno 2: modify then rename it
1008
        def command_list():
1009
            author = ['', 'bugs@a.com', time.time(), time.timezone]
1010
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
1011
            def files_one():
1012
                yield commands.FileModifyCommand(old_path, kind, False,
1013
                        None, "aaa")
1014
            yield commands.CommitCommand('head', '1', author,
1015
                committer, "commit 1", None, [], files_one)
1016
            def files_two():
1017
                yield commands.FileModifyCommand(old_path, kind, False,
1018
                        None, "bbb")
1019
                yield commands.FileRenameCommand(old_path, new_path)
1020
            yield commands.CommitCommand('head', '2', author,
1021
                committer, "commit 2", ":1", [], files_two)
1022
        return command_list
1023
1024
    def test_rename_of_modified_file_in_root(self):
1025
        handler, branch = self.get_handler()
1026
        old_path = 'a'
1027
        new_path = 'b'
1028
        handler.process(self.get_command_iter(old_path, new_path))
1029
        revtree0, revtree1 = self.assertChanges(branch, 1,
1030
            expected_added=[(old_path,)])
1031
        # Note: the delta doesn't show the modification?
1032
        # The actual new content is validated in the assertions following.
1033
        revtree1, revtree2 = self.assertChanges(branch, 2,
1034
            expected_renamed=[(old_path, new_path)])
1035
        self.assertContent(branch, revtree1, old_path, "aaa")
1036
        self.assertContent(branch, revtree2, new_path, "bbb")
1037
        self.assertRevisionRoot(revtree1, old_path)
1038
        self.assertRevisionRoot(revtree2, new_path)
1039
1040
    def test_rename_of_modified_symlink_in_root(self):
1041
        handler, branch = self.get_handler()
1042
        old_path = 'a'
1043
        new_path = 'b'
1044
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1045
        revtree0, revtree1 = self.assertChanges(branch, 1,
1046
            expected_added=[(old_path,)])
1047
        # Note: the delta doesn't show the modification?
1048
        # The actual new content is validated in the assertions following.
1049
        revtree1, revtree2 = self.assertChanges(branch, 2,
1050
            expected_renamed=[(old_path, new_path)])
1051
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1052
        self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1053
        self.assertRevisionRoot(revtree1, old_path)
1054
        self.assertRevisionRoot(revtree2, new_path)
1055
1056
    def test_rename_of_modified_file_in_subdir(self):
1057
        handler, branch = self.get_handler()
1058
        old_path = 'd/a'
1059
        new_path = 'd/b'
1060
        handler.process(self.get_command_iter(old_path, new_path))
1061
        revtree0, revtree1 = self.assertChanges(branch, 1,
1062
            expected_added=[('d',), (old_path,)])
1063
        # Note: the delta doesn't show the modification?
1064
        # The actual new content is validated in the assertions following.
1065
        revtree1, revtree2 = self.assertChanges(branch, 2,
1066
            expected_renamed=[(old_path, new_path)])
1067
        self.assertContent(branch, revtree1, old_path, "aaa")
1068
        self.assertContent(branch, revtree2, new_path, "bbb")
1069
1070
    def test_rename_of_modified_symlink_in_subdir(self):
1071
        handler, branch = self.get_handler()
1072
        old_path = 'd/a'
1073
        new_path = 'd/b'
1074
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1075
        revtree0, revtree1 = self.assertChanges(branch, 1,
1076
            expected_added=[('d',), (old_path,)])
1077
        # Note: the delta doesn't show the modification?
1078
        # The actual new content is validated in the assertions following.
1079
        revtree1, revtree2 = self.assertChanges(branch, 2,
1080
            expected_renamed=[(old_path, new_path)])
1081
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1082
        self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1083
1084
    def test_rename_of_modified_file_to_new_dir(self):
1085
        handler, branch = self.get_handler()
1086
        old_path = 'd1/a'
1087
        new_path = 'd2/b'
1088
        handler.process(self.get_command_iter(old_path, new_path))
1089
        revtree0, revtree1 = self.assertChanges(branch, 1,
1090
            expected_added=[('d1',), (old_path,)])
1091
        # Note: the delta doesn't show the modification?
1092
        # The actual new content is validated in the assertions following.
1093
        revtree1, revtree2 = self.assertChanges(branch, 2,
1094
            expected_renamed=[(old_path, new_path)],
1095
            expected_added=[('d2',)],
1096
            expected_removed=[('d1',)])
1097
        self.assertContent(branch, revtree1, old_path, "aaa")
1098
        self.assertContent(branch, revtree2, new_path, "bbb")
1099
1100
    def test_rename_of_modified_symlink_to_new_dir(self):
1101
        handler, branch = self.get_handler()
1102
        old_path = 'd1/a'
1103
        new_path = 'd2/b'
1104
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1105
        revtree0, revtree1 = self.assertChanges(branch, 1,
1106
            expected_added=[('d1',), (old_path,)])
1107
        # Note: the delta doesn't show the modification?
1108
        # The actual new content is validated in the assertions following.
1109
        revtree1, revtree2 = self.assertChanges(branch, 2,
1110
            expected_renamed=[(old_path, new_path)],
1111
            expected_added=[('d2',)],
1112
            expected_removed=[('d1',)])
1113
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1114
        self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1115
1116
0.99.19 by Ian Clatworthy
Handle rename then modification of the new path
1117
class TestImportToPackRenameThenModify(TestCaseForGenericProcessor):
1118
    """Test rename of a path then modfy the new-path in the same commit."""
1119
1120
    def get_command_iter(self, old_path, new_path, kind='file'):
1121
        # Revno 1: create a file or symlink
1122
        # Revno 2: rename it then modify the newly created path
1123
        def command_list():
1124
            author = ['', 'bugs@a.com', time.time(), time.timezone]
1125
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
1126
            def files_one():
1127
                yield commands.FileModifyCommand(old_path, kind, False,
1128
                        None, "aaa")
1129
            yield commands.CommitCommand('head', '1', author,
1130
                committer, "commit 1", None, [], files_one)
1131
            def files_two():
1132
                yield commands.FileRenameCommand(old_path, new_path)
1133
                yield commands.FileModifyCommand(new_path, kind, False,
1134
                        None, "bbb")
1135
            yield commands.CommitCommand('head', '2', author,
1136
                committer, "commit 2", ":1", [], files_two)
1137
        return command_list
1138
1139
    def test_rename_then_modify_file_in_root(self):
1140
        handler, branch = self.get_handler()
1141
        old_path = 'a'
1142
        new_path = 'b'
1143
        handler.process(self.get_command_iter(old_path, new_path))
1144
        revtree0, revtree1 = self.assertChanges(branch, 1,
1145
            expected_added=[(old_path,)])
1146
        # Note: the delta doesn't show the modification?
1147
        # The actual new content is validated in the assertions following.
1148
        revtree1, revtree2 = self.assertChanges(branch, 2,
1149
            expected_renamed=[(old_path, new_path)])
1150
        self.assertContent(branch, revtree1, old_path, "aaa")
1151
        self.assertContent(branch, revtree2, new_path, "bbb")
1152
        self.assertRevisionRoot(revtree1, old_path)
1153
        self.assertRevisionRoot(revtree2, new_path)
1154
1155
    def test_rename_then_modify_file_in_subdir(self):
1156
        handler, branch = self.get_handler()
1157
        old_path = 'd/a'
1158
        new_path = 'd/b'
1159
        handler.process(self.get_command_iter(old_path, new_path))
1160
        revtree0, revtree1 = self.assertChanges(branch, 1,
1161
            expected_added=[('d',), (old_path,)])
1162
        # Note: the delta doesn't show the modification?
1163
        # The actual new content is validated in the assertions following.
1164
        revtree1, revtree2 = self.assertChanges(branch, 2,
1165
            expected_renamed=[(old_path, new_path)])
1166
        self.assertContent(branch, revtree1, old_path, "aaa")
1167
        self.assertContent(branch, revtree2, new_path, "bbb")
1168
1169
    def test_rename_then_modify_file_in_new_dir(self):
1170
        handler, branch = self.get_handler()
1171
        old_path = 'd1/a'
1172
        new_path = 'd2/b'
1173
        handler.process(self.get_command_iter(old_path, new_path))
1174
        revtree0, revtree1 = self.assertChanges(branch, 1,
1175
            expected_added=[('d1',), (old_path,)])
1176
        # Note: the delta doesn't show the modification?
1177
        # The actual new content is validated in the assertions following.
1178
        revtree1, revtree2 = self.assertChanges(branch, 2,
1179
            expected_renamed=[(old_path, new_path)],
1180
            expected_added=[('d2',)],
1181
            expected_removed=[('d1',)])
1182
        self.assertContent(branch, revtree1, old_path, "aaa")
1183
        self.assertContent(branch, revtree2, new_path, "bbb")
1184
1185
    def test_rename_then_modify_symlink_in_root(self):
1186
        handler, branch = self.get_handler()
1187
        old_path = 'a'
1188
        new_path = 'b'
1189
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1190
        revtree0, revtree1 = self.assertChanges(branch, 1,
1191
            expected_added=[(old_path,)])
1192
        # Note: the delta doesn't show the modification?
1193
        # The actual new content is validated in the assertions following.
1194
        revtree1, revtree2 = self.assertChanges(branch, 2,
1195
            expected_renamed=[(old_path, new_path)])
1196
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1197
        self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1198
        self.assertRevisionRoot(revtree1, old_path)
1199
        self.assertRevisionRoot(revtree2, new_path)
1200
1201
    def test_rename_then_modify_symlink_in_subdir(self):
1202
        handler, branch = self.get_handler()
1203
        old_path = 'd/a'
1204
        new_path = 'd/b'
1205
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1206
        revtree0, revtree1 = self.assertChanges(branch, 1,
1207
            expected_added=[('d',), (old_path,)])
1208
        # Note: the delta doesn't show the modification?
1209
        # The actual new content is validated in the assertions following.
1210
        revtree1, revtree2 = self.assertChanges(branch, 2,
1211
            expected_renamed=[(old_path, new_path)])
1212
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1213
        self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1214
1215
    def test_rename_then_modify_symlink_in_new_dir(self):
1216
        handler, branch = self.get_handler()
1217
        old_path = 'd1/a'
1218
        new_path = 'd2/b'
1219
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1220
        revtree0, revtree1 = self.assertChanges(branch, 1,
1221
            expected_added=[('d1',), (old_path,)])
1222
        # Note: the delta doesn't show the modification?
1223
        # The actual new content is validated in the assertions following.
1224
        revtree1, revtree2 = self.assertChanges(branch, 2,
1225
            expected_renamed=[(old_path, new_path)],
1226
            expected_added=[('d2',)],
1227
            expected_removed=[('d1',)])
1228
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1229
        self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1230
1231
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1232
class TestImportToPackRenameTricky(TestCaseForGenericProcessor):
0.80.6 by Ian Clatworthy
file/symlink <-> directory rename tests
1233
1234
    def file_command_iter(self, path1, old_path2, new_path2, kind='file'):
1235
        # Revno 1: create two files or symlinks in a directory
1236
        # Revno 2: rename the second file so that it implicitly deletes the
1237
        # first one because either:
1238
        # * the new file is a in directory with the old file name
1239
        # * the new file has the same name as the directory of the first
1240
        def command_list():
1241
            author = ['', 'bugs@a.com', time.time(), time.timezone]
1242
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
1243
            def files_one():
1244
                yield commands.FileModifyCommand(path1, kind, False,
1245
                        None, "aaa")
1246
                yield commands.FileModifyCommand(old_path2, kind, False,
1247
                        None, "bbb")
1248
            yield commands.CommitCommand('head', '1', author,
1249
                committer, "commit 1", None, [], files_one)
1250
            def files_two():
1251
                yield commands.FileRenameCommand(old_path2, new_path2)
1252
            yield commands.CommitCommand('head', '2', author,
1253
                committer, "commit 2", ":1", [], files_two)
1254
        return command_list
1255
1256
    def test_rename_file_becomes_directory(self):
1257
        handler, branch = self.get_handler()
1258
        old_path2 = 'foo'
1259
        path1     = 'a/b'
1260
        new_path2 = 'a/b/c'
1261
        handler.process(self.file_command_iter(path1, old_path2, new_path2))
1262
        revtree0, revtree1 = self.assertChanges(branch, 1,
1263
            expected_added=[('a',), (path1,), (old_path2,)])
1264
        revtree1, revtree2 = self.assertChanges(branch, 2,
1265
            expected_renamed=[(old_path2, new_path2)],
1266
            expected_kind_changed=[(path1, 'file', 'directory')])
1267
        self.assertContent(branch, revtree1, path1, "aaa")
1268
        self.assertContent(branch, revtree2, new_path2, "bbb")
1269
1270
    def test_rename_directory_becomes_file(self):
1271
        handler, branch = self.get_handler()
1272
        old_path2 = 'foo'
1273
        path1     = 'a/b/c'
1274
        new_path2 = 'a/b'
1275
        handler.process(self.file_command_iter(path1, old_path2, new_path2))
1276
        revtree0, revtree1 = self.assertChanges(branch, 1,
1277
            expected_added=[('a',), ('a/b',), (path1,), (old_path2,)])
1278
        revtree1, revtree2 = self.assertChanges(branch, 2,
1279
            expected_renamed=[(old_path2, new_path2)],
1280
            expected_removed=[(path1,), (new_path2,)])
1281
        self.assertContent(branch, revtree1, path1, "aaa")
1282
        self.assertContent(branch, revtree2, new_path2, "bbb")
1283
1284
    def test_rename_symlink_becomes_directory(self):
1285
        handler, branch = self.get_handler()
1286
        old_path2 = 'foo'
1287
        path1     = 'a/b'
1288
        new_path2 = 'a/b/c'
1289
        handler.process(self.file_command_iter(path1, old_path2, new_path2,
1290
            'symlink'))
1291
        revtree0, revtree1 = self.assertChanges(branch, 1,
1292
            expected_added=[('a',), (path1,), (old_path2,)])
1293
        revtree1, revtree2 = self.assertChanges(branch, 2,
1294
            expected_renamed=[(old_path2, new_path2)],
1295
            expected_kind_changed=[(path1, 'symlink', 'directory')])
1296
        self.assertSymlinkTarget(branch, revtree1, path1, "aaa")
1297
        self.assertSymlinkTarget(branch, revtree2, new_path2, "bbb")
1298
1299
    def test_rename_directory_becomes_symlink(self):
1300
        handler, branch = self.get_handler()
1301
        old_path2 = 'foo'
1302
        path1     = 'a/b/c'
1303
        new_path2 = 'a/b'
1304
        handler.process(self.file_command_iter(path1, old_path2, new_path2,
1305
            'symlink'))
1306
        revtree0, revtree1 = self.assertChanges(branch, 1,
1307
            expected_added=[('a',), ('a/b',), (path1,), (old_path2,)])
1308
        revtree1, revtree2 = self.assertChanges(branch, 2,
1309
            expected_renamed=[(old_path2, new_path2)],
1310
            expected_removed=[(path1,), (new_path2,)])
1311
        self.assertSymlinkTarget(branch, revtree1, path1, "aaa")
1312
        self.assertSymlinkTarget(branch, revtree2, new_path2, "bbb")
1313
1314
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1315
class TestImportToPackCopy(TestCaseForGenericProcessor):
0.76.2 by Ian Clatworthy
code & tests for file copying
1316
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1317
    def file_command_iter(self, src_path, dest_path, kind='file'):
0.80.4 by Ian Clatworthy
file executable off <-> on tests
1318
        # Revno 1: create a file or symlink
1319
        # Revno 2: copy it
0.76.2 by Ian Clatworthy
code & tests for file copying
1320
        def command_list():
1321
            author = ['', 'bugs@a.com', time.time(), time.timezone]
1322
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
1323
            def files_one():
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1324
                yield commands.FileModifyCommand(src_path, kind, False,
0.76.2 by Ian Clatworthy
code & tests for file copying
1325
                        None, "aaa")
1326
            yield commands.CommitCommand('head', '1', author,
1327
                committer, "commit 1", None, [], files_one)
1328
            def files_two():
1329
                yield commands.FileCopyCommand(src_path, dest_path)
1330
            yield commands.CommitCommand('head', '2', author,
1331
                committer, "commit 2", ":1", [], files_two)
1332
        return command_list
1333
1334
    def test_copy_file_in_root(self):
1335
        handler, branch = self.get_handler()
1336
        src_path = 'a'
1337
        dest_path = 'b'
1338
        handler.process(self.file_command_iter(src_path, dest_path))
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1339
        revtree1, revtree2 = self.assertChanges(branch, 2,
0.76.2 by Ian Clatworthy
code & tests for file copying
1340
            expected_added=[(dest_path,)])
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1341
        self.assertContent(branch, revtree1, src_path, "aaa")
1342
        self.assertContent(branch, revtree2, src_path, "aaa")
0.76.2 by Ian Clatworthy
code & tests for file copying
1343
        self.assertContent(branch, revtree2, dest_path, "aaa")
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1344
        self.assertRevisionRoot(revtree1, src_path)
1345
        self.assertRevisionRoot(revtree2, dest_path)
0.76.2 by Ian Clatworthy
code & tests for file copying
1346
1347
    def test_copy_file_in_subdir(self):
1348
        handler, branch = self.get_handler()
1349
        src_path = 'a/a'
1350
        dest_path = 'a/b'
1351
        handler.process(self.file_command_iter(src_path, dest_path))
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1352
        revtree1, revtree2 = self.assertChanges(branch, 2,
0.76.2 by Ian Clatworthy
code & tests for file copying
1353
            expected_added=[(dest_path,)])
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1354
        self.assertContent(branch, revtree1, src_path, "aaa")
1355
        self.assertContent(branch, revtree2, src_path, "aaa")
0.76.2 by Ian Clatworthy
code & tests for file copying
1356
        self.assertContent(branch, revtree2, dest_path, "aaa")
1357
1358
    def test_copy_file_to_new_dir(self):
1359
        handler, branch = self.get_handler()
1360
        src_path = 'a/a'
1361
        dest_path = 'b/a'
1362
        handler.process(self.file_command_iter(src_path, dest_path))
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1363
        revtree1, revtree2 = self.assertChanges(branch, 2,
0.76.2 by Ian Clatworthy
code & tests for file copying
1364
            expected_added=[('b',), (dest_path,)])
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1365
        self.assertContent(branch, revtree1, src_path, "aaa")
1366
        self.assertContent(branch, revtree2, src_path, "aaa")
0.76.2 by Ian Clatworthy
code & tests for file copying
1367
        self.assertContent(branch, revtree2, dest_path, "aaa")
1368
0.76.3 by Ian Clatworthy
symlink copying tests
1369
    def test_copy_symlink_in_root(self):
1370
        handler, branch = self.get_handler()
1371
        src_path = 'a'
1372
        dest_path = 'b'
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1373
        handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1374
        revtree1, revtree2 = self.assertChanges(branch, 2,
0.76.3 by Ian Clatworthy
symlink copying tests
1375
            expected_added=[(dest_path,)])
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1376
        self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1377
        self.assertSymlinkTarget(branch, revtree2, src_path, "aaa")
0.76.3 by Ian Clatworthy
symlink copying tests
1378
        self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1379
        self.assertRevisionRoot(revtree1, src_path)
1380
        self.assertRevisionRoot(revtree2, dest_path)
0.76.3 by Ian Clatworthy
symlink copying tests
1381
1382
    def test_copy_symlink_in_subdir(self):
1383
        handler, branch = self.get_handler()
1384
        src_path = 'a/a'
1385
        dest_path = 'a/b'
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1386
        handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1387
        revtree1, revtree2 = self.assertChanges(branch, 2,
0.76.3 by Ian Clatworthy
symlink copying tests
1388
            expected_added=[(dest_path,)])
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1389
        self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1390
        self.assertSymlinkTarget(branch, revtree2, src_path, "aaa")
0.76.3 by Ian Clatworthy
symlink copying tests
1391
        self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
1392
1393
    def test_copy_symlink_to_new_dir(self):
1394
        handler, branch = self.get_handler()
1395
        src_path = 'a/a'
1396
        dest_path = 'b/a'
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1397
        handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1398
        revtree1, revtree2 = self.assertChanges(branch, 2,
0.76.3 by Ian Clatworthy
symlink copying tests
1399
            expected_added=[('b',), (dest_path,)])
0.80.1 by Ian Clatworthy
basic units tests for filemodify
1400
        self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1401
        self.assertSymlinkTarget(branch, revtree2, src_path, "aaa")
0.76.3 by Ian Clatworthy
symlink copying tests
1402
        self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
1403
0.76.2 by Ian Clatworthy
code & tests for file copying
1404
0.99.8 by Ian Clatworthy
handle copy of a newly added file
1405
class TestImportToPackCopyNew(TestCaseForGenericProcessor):
1406
    """Test copy of a newly added file."""
1407
1408
    def file_command_iter(self, src_path, dest_path, kind='file'):
1409
        # Revno 1: create a file or symlink and copy it
1410
        def command_list():
1411
            author = ['', 'bugs@a.com', time.time(), time.timezone]
1412
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
1413
            def files_one():
1414
                yield commands.FileModifyCommand(src_path, kind, False,
1415
                        None, "aaa")
1416
                yield commands.FileCopyCommand(src_path, dest_path)
1417
            yield commands.CommitCommand('head', '1', author,
1418
                committer, "commit 1", None, [], files_one)
1419
        return command_list
1420
1421
    def test_copy_new_file_in_root(self):
1422
        handler, branch = self.get_handler()
1423
        src_path = 'a'
1424
        dest_path = 'b'
1425
        handler.process(self.file_command_iter(src_path, dest_path))
1426
        revtree0, revtree1 = self.assertChanges(branch, 1,
1427
            expected_added=[(src_path,), (dest_path,)])
1428
        self.assertContent(branch, revtree1, src_path, "aaa")
1429
        self.assertContent(branch, revtree1, dest_path, "aaa")
1430
        self.assertRevisionRoot(revtree1, src_path)
1431
        self.assertRevisionRoot(revtree1, dest_path)
1432
1433
    def test_copy_new_file_in_subdir(self):
1434
        handler, branch = self.get_handler()
1435
        src_path = 'a/a'
1436
        dest_path = 'a/b'
1437
        handler.process(self.file_command_iter(src_path, dest_path))
1438
        revtree0, revtree1 = self.assertChanges(branch, 1,
1439
            expected_added=[('a',), (src_path,), (dest_path,)])
1440
        self.assertContent(branch, revtree1, src_path, "aaa")
1441
        self.assertContent(branch, revtree1, dest_path, "aaa")
1442
1443
    def test_copy_new_file_to_new_dir(self):
1444
        handler, branch = self.get_handler()
1445
        src_path = 'a/a'
1446
        dest_path = 'b/a'
1447
        handler.process(self.file_command_iter(src_path, dest_path))
1448
        revtree0, revtree1 = self.assertChanges(branch, 1,
1449
            expected_added=[('a',), (src_path,), ('b',), (dest_path,)])
1450
        self.assertContent(branch, revtree1, src_path, "aaa")
1451
        self.assertContent(branch, revtree1, dest_path, "aaa")
1452
1453
    def test_copy_new_symlink_in_root(self):
1454
        handler, branch = self.get_handler()
1455
        src_path = 'a'
1456
        dest_path = 'b'
1457
        handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1458
        revtree0, revtree1 = self.assertChanges(branch, 1,
1459
            expected_added=[(src_path,), (dest_path,)])
1460
        self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1461
        self.assertSymlinkTarget(branch, revtree1, dest_path, "aaa")
1462
        self.assertRevisionRoot(revtree1, src_path)
1463
        self.assertRevisionRoot(revtree1, dest_path)
1464
1465
    def test_copy_new_symlink_in_subdir(self):
1466
        handler, branch = self.get_handler()
1467
        src_path = 'a/a'
1468
        dest_path = 'a/b'
1469
        handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1470
        revtree0, revtree1 = self.assertChanges(branch, 1,
1471
            expected_added=[('a',), (src_path,), (dest_path,)])
1472
        self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1473
        self.assertSymlinkTarget(branch, revtree1, dest_path, "aaa")
1474
1475
    def test_copy_new_symlink_to_new_dir(self):
1476
        handler, branch = self.get_handler()
1477
        src_path = 'a/a'
1478
        dest_path = 'b/a'
1479
        handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1480
        revtree0, revtree1 = self.assertChanges(branch, 1,
1481
            expected_added=[('a',), (src_path,), ('b',), (dest_path,)])
1482
        self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1483
        self.assertSymlinkTarget(branch, revtree1, dest_path, "aaa")
1484
1485
0.99.15 by Ian Clatworthy
Add tests for copying to a path deleted in the same commit
1486
class TestImportToPackCopyToDeleted(TestCaseForGenericProcessor):
1487
1488
    def file_command_iter(self, src_path, dest_path, kind='file'):
1489
        # Revno 1: create two files or symlinks
1490
        # Revno 2: delete one and copy the other one to its path
1491
        def command_list():
1492
            author = ['', 'bugs@a.com', time.time(), time.timezone]
1493
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
1494
            def files_one():
1495
                yield commands.FileModifyCommand(src_path, kind, False,
1496
                        None, "aaa")
1497
                yield commands.FileModifyCommand(dest_path, kind, False,
1498
                        None, "bbb")
1499
            yield commands.CommitCommand('head', '1', author,
1500
                committer, "commit 1", None, [], files_one)
1501
            def files_two():
1502
                yield commands.FileDeleteCommand(dest_path)
1503
                yield commands.FileCopyCommand(src_path, dest_path)
1504
            yield commands.CommitCommand('head', '2', author,
1505
                committer, "commit 2", ":1", [], files_two)
1506
        return command_list
1507
1508
    def test_copy_to_deleted_file_in_root(self):
1509
        handler, branch = self.get_handler()
1510
        src_path = 'a'
1511
        dest_path = 'b'
1512
        handler.process(self.file_command_iter(src_path, dest_path))
1513
        revtree0, revtree1 = self.assertChanges(branch, 1,
1514
            expected_added=[(src_path,), (dest_path,)])
1515
        revtree1, revtree2 = self.assertChanges(branch, 2,
1516
            expected_removed=[(dest_path,)],
1517
            expected_added=[(dest_path,)])
1518
        self.assertContent(branch, revtree1, src_path, "aaa")
1519
        self.assertContent(branch, revtree1, dest_path, "bbb")
1520
        self.assertContent(branch, revtree2, src_path, "aaa")
1521
        self.assertContent(branch, revtree2, dest_path, "aaa")
1522
        self.assertRevisionRoot(revtree1, src_path)
1523
        self.assertRevisionRoot(revtree1, dest_path)
1524
1525
    def test_copy_to_deleted_symlink_in_root(self):
1526
        handler, branch = self.get_handler()
1527
        src_path = 'a'
1528
        dest_path = 'b'
1529
        handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1530
        revtree0, revtree1 = self.assertChanges(branch, 1,
1531
            expected_added=[(src_path,), (dest_path,)])
1532
        revtree1, revtree2 = self.assertChanges(branch, 2,
1533
            expected_removed=[(dest_path,)],
1534
            expected_added=[(dest_path,)])
1535
        self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1536
        self.assertSymlinkTarget(branch, revtree1, dest_path, "bbb")
1537
        self.assertSymlinkTarget(branch, revtree2, src_path, "aaa")
1538
        self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
1539
        self.assertRevisionRoot(revtree1, src_path)
1540
        self.assertRevisionRoot(revtree1, dest_path)
1541
1542
    def test_copy_to_deleted_file_in_subdir(self):
1543
        handler, branch = self.get_handler()
1544
        src_path = 'd/a'
1545
        dest_path = 'd/b'
1546
        handler.process(self.file_command_iter(src_path, dest_path))
1547
        revtree0, revtree1 = self.assertChanges(branch, 1,
1548
            expected_added=[('d',), (src_path,), (dest_path,)])
1549
        revtree1, revtree2 = self.assertChanges(branch, 2,
1550
            expected_removed=[(dest_path,)],
1551
            expected_added=[(dest_path,)])
1552
        self.assertContent(branch, revtree1, src_path, "aaa")
1553
        self.assertContent(branch, revtree1, dest_path, "bbb")
1554
        self.assertContent(branch, revtree2, src_path, "aaa")
1555
        self.assertContent(branch, revtree2, dest_path, "aaa")
1556
1557
    def test_copy_to_deleted_symlink_in_subdir(self):
1558
        handler, branch = self.get_handler()
1559
        src_path = 'd/a'
1560
        dest_path = 'd/b'
1561
        handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1562
        revtree0, revtree1 = self.assertChanges(branch, 1,
1563
            expected_added=[('d',), (src_path,), (dest_path,)])
1564
        revtree1, revtree2 = self.assertChanges(branch, 2,
1565
            expected_removed=[(dest_path,)],
1566
            expected_added=[(dest_path,)])
1567
        self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1568
        self.assertSymlinkTarget(branch, revtree1, dest_path, "bbb")
1569
        self.assertSymlinkTarget(branch, revtree2, src_path, "aaa")
1570
        self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
1571
1572
0.99.18 by Ian Clatworthy
Handle copy of a file/symlink already modified in this commit
1573
class TestImportToPackCopyModified(TestCaseForGenericProcessor):
1574
    """Test copy of file/symlink already modified in this commit."""
1575
1576
    def file_command_iter(self, src_path, dest_path, kind='file'):
1577
        # Revno 1: create a file or symlink
1578
        # Revno 2: modify and copy it
1579
        def command_list():
1580
            author = ['', 'bugs@a.com', time.time(), time.timezone]
1581
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
1582
            def files_one():
1583
                yield commands.FileModifyCommand(src_path, kind, False,
1584
                        None, "aaa")
1585
            yield commands.CommitCommand('head', '1', author,
1586
                committer, "commit 1", None, [], files_one)
1587
            def files_two():
1588
                yield commands.FileModifyCommand(src_path, kind, False,
1589
                        None, "bbb")
1590
                yield commands.FileCopyCommand(src_path, dest_path)
1591
            yield commands.CommitCommand('head', '2', author,
1592
                committer, "commit 2", ":1", [], files_two)
1593
        return command_list
1594
1595
    def test_copy_of_modified_file_in_root(self):
1596
        handler, branch = self.get_handler()
1597
        src_path = 'a'
1598
        dest_path = 'b'
1599
        handler.process(self.file_command_iter(src_path, dest_path))
1600
        revtree1, revtree2 = self.assertChanges(branch, 2,
1601
            expected_modified=[(src_path,)],
1602
            expected_added=[(dest_path,)])
1603
        self.assertContent(branch, revtree1, src_path, "aaa")
1604
        self.assertContent(branch, revtree2, src_path, "bbb")
1605
        self.assertContent(branch, revtree2, dest_path, "bbb")
1606
        self.assertRevisionRoot(revtree1, src_path)
1607
        self.assertRevisionRoot(revtree2, dest_path)
1608
1609
    def test_copy_of_modified_file_in_subdir(self):
1610
        handler, branch = self.get_handler()
1611
        src_path = 'd/a'
1612
        dest_path = 'd/b'
1613
        handler.process(self.file_command_iter(src_path, dest_path))
1614
        revtree1, revtree2 = self.assertChanges(branch, 2,
1615
            expected_modified=[(src_path,)],
1616
            expected_added=[(dest_path,)])
1617
        self.assertContent(branch, revtree1, src_path, "aaa")
1618
        self.assertContent(branch, revtree2, src_path, "bbb")
1619
        self.assertContent(branch, revtree2, dest_path, "bbb")
1620
1621
    def test_copy_of_modified_file_to_new_dir(self):
1622
        handler, branch = self.get_handler()
1623
        src_path = 'd1/a'
1624
        dest_path = 'd2/a'
1625
        handler.process(self.file_command_iter(src_path, dest_path))
1626
        revtree1, revtree2 = self.assertChanges(branch, 2,
1627
            expected_modified=[(src_path,)],
1628
            expected_added=[('d2',), (dest_path,)])
1629
        self.assertContent(branch, revtree1, src_path, "aaa")
1630
        self.assertContent(branch, revtree2, src_path, "bbb")
1631
        self.assertContent(branch, revtree2, dest_path, "bbb")
1632
1633
    def test_copy_of_modified_symlink_in_root(self):
1634
        handler, branch = self.get_handler()
1635
        src_path = 'a'
1636
        dest_path = 'b'
1637
        handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1638
        revtree1, revtree2 = self.assertChanges(branch, 2,
1639
            expected_modified=[(src_path,)],
1640
            expected_added=[(dest_path,)])
1641
        self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1642
        self.assertSymlinkTarget(branch, revtree2, src_path, "bbb")
1643
        self.assertSymlinkTarget(branch, revtree2, dest_path, "bbb")
1644
        self.assertRevisionRoot(revtree1, src_path)
1645
        self.assertRevisionRoot(revtree2, dest_path)
1646
1647
    def test_copy_of_modified_symlink_in_subdir(self):
1648
        handler, branch = self.get_handler()
1649
        src_path = 'd/a'
1650
        dest_path = 'd/b'
1651
        handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1652
        revtree1, revtree2 = self.assertChanges(branch, 2,
1653
            expected_modified=[(src_path,)],
1654
            expected_added=[(dest_path,)])
1655
        self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1656
        self.assertSymlinkTarget(branch, revtree2, src_path, "bbb")
1657
        self.assertSymlinkTarget(branch, revtree2, dest_path, "bbb")
1658
1659
    def test_copy_of_modified_symlink_to_new_dir(self):
1660
        handler, branch = self.get_handler()
1661
        src_path = 'd1/a'
1662
        dest_path = 'd2/a'
1663
        handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1664
        revtree1, revtree2 = self.assertChanges(branch, 2,
1665
            expected_modified=[(src_path,)],
1666
            expected_added=[('d2',), (dest_path,)])
1667
        self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1668
        self.assertSymlinkTarget(branch, revtree2, src_path, "bbb")
1669
        self.assertSymlinkTarget(branch, revtree2, dest_path, "bbb")
0.99.10 by Ian Clatworthy
commented out draft of CopyModified tests
1670
1671
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1672
class TestImportToPackFileKinds(TestCaseForGenericProcessor):
0.64.74 by Ian Clatworthy
fix symlink importing
1673
1674
    def get_command_iter(self, path, kind, content):
1675
        def command_list():
1676
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
1677
            def files_one():
1678
                yield commands.FileModifyCommand(path, kind, False,
1679
                        None, content)
1680
            yield commands.CommitCommand('head', '1', None,
1681
                committer, "commit 1", None, [], files_one)
1682
        return command_list
1683
1684
    def test_import_plainfile(self):
0.76.1 by Ian Clatworthy
clean-up tests for GenericProcessor
1685
        handler, branch = self.get_handler()
1686
        handler.process(self.get_command_iter('foo', 'file', 'aaa'))
0.64.74 by Ian Clatworthy
fix symlink importing
1687
1688
    def test_import_symlink(self):
0.76.1 by Ian Clatworthy
clean-up tests for GenericProcessor
1689
        handler, branch = self.get_handler()
1690
        handler.process(self.get_command_iter('foo', 'symlink', 'bar'))
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1691
1692
1693
### TODO: Parameterise tests rather than below hack
1694
0.85.2 by Ian Clatworthy
improve per-file graph generation
1695
class TestImportToRichRootModify(TestImportToPackModify):
1696
    branch_format = "1.9-rich-root"
1697
0.99.5 by Ian Clatworthy
handle adding the same file twice in the one commit
1698
class TestImportToRichRootModifyTwice(TestImportToPackModifyTwice):
1699
    branch_format = "1.9-rich-root"
1700
0.85.2 by Ian Clatworthy
improve per-file graph generation
1701
class TestImportToRichRootModifyTricky(TestImportToPackModifyTricky):
1702
    branch_format = "1.9-rich-root"
1703
1704
class TestImportToRichRootDelete(TestImportToPackDelete):
1705
    branch_format = "1.9-rich-root"
1706
0.99.7 by Ian Clatworthy
handle a delete of a newly added file
1707
class TestImportToRichRootDeleteNew(TestImportToPackDeleteNew):
1708
    branch_format = "1.9-rich-root"
0.101.4 by Tom Widmer
Add missing test cases for multilevel deletes in 2a dn 1.9-rich-root fast imports.
1709
    
1710
class TestImportToRichRootDeleteMultiLevel(TestImportToPackDeleteMultiLevel):
1711
    branch_format = "1.9-rich-root"
0.99.7 by Ian Clatworthy
handle a delete of a newly added file
1712
0.99.13 by Ian Clatworthy
Handle delete then add of a file/symlink in the one commit
1713
class TestImportToRichRootDeleteThenAdd(TestImportToPackDeleteThenAdd):
1714
    branch_format = "1.9-rich-root"
1715
0.85.2 by Ian Clatworthy
improve per-file graph generation
1716
class TestImportToRichRootDeleteDirectory(TestImportToPackDeleteDirectory):
1717
    branch_format = "1.9-rich-root"
1718
0.99.21 by Ian Clatworthy
Handle deleting a directory then adding a file within it in the same commit
1719
class TestImportToRichRootDeleteDirectoryThenAddFile(TestImportToPackDeleteDirectoryThenAddFile):
1720
    branch_format = "1.9-rich-root"
1721
0.85.2 by Ian Clatworthy
improve per-file graph generation
1722
class TestImportToRichRootRename(TestImportToPackRename):
1723
    branch_format = "1.9-rich-root"
1724
0.99.6 by Ian Clatworthy
Handle rename of a just added file
1725
class TestImportToRichRootRenameNew(TestImportToPackRenameNew):
1726
    branch_format = "1.9-rich-root"
1727
0.99.14 by Ian Clatworthy
Add tests for renaming to a deleted destination
1728
class TestImportToRichRootRenameToDeleted(TestImportToPackRenameToDeleted):
1729
    branch_format = "1.9-rich-root"
1730
0.99.17 by Ian Clatworthy
Handle rename of a file/symlink modified already in this commit
1731
class TestImportToRichRootRenameModified(TestImportToPackRenameModified):
1732
    branch_format = "1.9-rich-root"
1733
0.99.19 by Ian Clatworthy
Handle rename then modification of the new path
1734
class TestImportToRichRootRenameThenModify(TestImportToPackRenameThenModify):
1735
    branch_format = "1.9-rich-root"
1736
0.85.2 by Ian Clatworthy
improve per-file graph generation
1737
class TestImportToRichRootRenameTricky(TestImportToPackRenameTricky):
1738
    branch_format = "1.9-rich-root"
1739
1740
class TestImportToRichRootCopy(TestImportToPackCopy):
1741
    branch_format = "1.9-rich-root"
1742
0.99.8 by Ian Clatworthy
handle copy of a newly added file
1743
class TestImportToRichRootCopyNew(TestImportToPackCopyNew):
1744
    branch_format = "1.9-rich-root"
1745
0.99.15 by Ian Clatworthy
Add tests for copying to a path deleted in the same commit
1746
class TestImportToRichRootCopyToDeleted(TestImportToPackCopyToDeleted):
1747
    branch_format = "1.9-rich-root"
1748
0.99.18 by Ian Clatworthy
Handle copy of a file/symlink already modified in this commit
1749
class TestImportToRichRootCopyModified(TestImportToPackCopyModified):
1750
    branch_format = "1.9-rich-root"
1751
0.85.2 by Ian Clatworthy
improve per-file graph generation
1752
class TestImportToRichRootFileKinds(TestImportToPackFileKinds):
1753
    branch_format = "1.9-rich-root"
1754
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1755
try:
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1756
    from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1757
1758
    class TestImportToChkModify(TestImportToPackModify):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1759
        branch_format = "2a"
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1760
0.99.5 by Ian Clatworthy
handle adding the same file twice in the one commit
1761
    class TestImportToChkModifyTwice(TestImportToPackModifyTwice):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1762
        branch_format = "2a"
0.99.5 by Ian Clatworthy
handle adding the same file twice in the one commit
1763
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1764
    class TestImportToChkModifyTricky(TestImportToPackModifyTricky):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1765
        branch_format = "2a"
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1766
1767
    class TestImportToChkDelete(TestImportToPackDelete):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1768
        branch_format = "2a"
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1769
0.99.7 by Ian Clatworthy
handle a delete of a newly added file
1770
    class TestImportToChkDeleteNew(TestImportToPackDeleteNew):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1771
        branch_format = "2a"
0.99.7 by Ian Clatworthy
handle a delete of a newly added file
1772
0.101.4 by Tom Widmer
Add missing test cases for multilevel deletes in 2a dn 1.9-rich-root fast imports.
1773
    class TestImportToChkDeleteMultiLevel(TestImportToPackDeleteMultiLevel):
1774
        branch_format = "2a"
1775
0.99.13 by Ian Clatworthy
Handle delete then add of a file/symlink in the one commit
1776
    class TestImportToChkDeleteThenAdd(TestImportToPackDeleteThenAdd):
1777
        branch_format = "2a"
1778
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1779
    class TestImportToChkDeleteDirectory(TestImportToPackDeleteDirectory):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1780
        branch_format = "2a"
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1781
0.99.21 by Ian Clatworthy
Handle deleting a directory then adding a file within it in the same commit
1782
    class TestImportToChkDeleteDirectoryThenAddFile(TestImportToPackDeleteDirectoryThenAddFile):
1783
        branch_format = "2a"
1784
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1785
    class TestImportToChkRename(TestImportToPackRename):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1786
        branch_format = "2a"
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1787
0.99.6 by Ian Clatworthy
Handle rename of a just added file
1788
    class TestImportToChkRenameNew(TestImportToPackRenameNew):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1789
        branch_format = "2a"
0.99.6 by Ian Clatworthy
Handle rename of a just added file
1790
0.99.14 by Ian Clatworthy
Add tests for renaming to a deleted destination
1791
    class TestImportToChkRenameToDeleted(TestImportToPackRenameToDeleted):
1792
        branch_format = "2a"
1793
0.99.17 by Ian Clatworthy
Handle rename of a file/symlink modified already in this commit
1794
    class TestImportToChkRenameModified(TestImportToPackRenameModified):
1795
        branch_format = "2a"
1796
0.99.19 by Ian Clatworthy
Handle rename then modification of the new path
1797
    class TestImportToChkRenameThenModify(TestImportToPackRenameThenModify):
1798
        branch_format = "2a"
1799
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1800
    class TestImportToChkRenameTricky(TestImportToPackRenameTricky):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1801
        branch_format = "2a"
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1802
1803
    class TestImportToChkCopy(TestImportToPackCopy):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1804
        branch_format = "2a"
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1805
0.99.8 by Ian Clatworthy
handle copy of a newly added file
1806
    class TestImportToChkCopyNew(TestImportToPackCopyNew):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1807
        branch_format = "2a"
0.99.8 by Ian Clatworthy
handle copy of a newly added file
1808
0.99.15 by Ian Clatworthy
Add tests for copying to a path deleted in the same commit
1809
    class TestImportToChkCopyToDeleted(TestImportToPackCopyToDeleted):
1810
        branch_format = "2a"
1811
0.99.18 by Ian Clatworthy
Handle copy of a file/symlink already modified in this commit
1812
    class TestImportToChkCopyModified(TestImportToPackCopyModified):
1813
        branch_format = "2a"
1814
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1815
    class TestImportToChkFileKinds(TestImportToPackFileKinds):
0.99.11 by Ian Clatworthy
Change tests to use 2a instead of development6-rich-root
1816
        branch_format = "2a"
0.85.1 by Ian Clatworthy
extend tests to test the chk code path
1817
1818
except ImportError:
1819
    pass