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