1
# Copyright (C) 2008 Canonical Ltd
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.
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.
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
24
from bzrlib.plugins.fastimport import (
29
from bzrlib.plugins.fastimport.processors import (
34
class TestCaseForGenericProcessor(tests.TestCaseWithTransport):
36
branch_format = "pack-0.92"
38
def get_handler(self):
39
branch = self.make_branch('.', format=self.branch_format)
40
handler = generic_processor.GenericProcessor(branch.bzrdir)
41
return handler, branch
43
# FIXME: [] as a default is bad, as it is mutable, but I want
44
# to use None to mean "don't check this".
45
def assertChanges(self, branch, revno, expected_added=[],
46
expected_removed=[], expected_modified=[],
47
expected_renamed=[], expected_kind_changed=[]):
48
"""Check the changes introduced in a revision of a branch.
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.
54
If you do not wish to assert anything about a particular
55
category then pass None instead.
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.
67
expected_kind_changed: a list of (path, old_kind, new_kind) tuples
68
that must have been changed in the delta.
69
:return: revtree1, revtree2
71
repo = branch.repository
72
revtree1 = repo.revision_tree(branch.get_rev_id(revno - 1))
73
revtree2 = repo.revision_tree(branch.get_rev_id(revno))
74
changes = revtree2.changes_from(revtree1)
75
self._check_changes(changes, expected_added, expected_removed,
76
expected_modified, expected_renamed, expected_kind_changed)
77
return revtree1, revtree2
79
def _check_changes(self, changes, expected_added=[],
80
expected_removed=[], expected_modified=[],
81
expected_renamed=[], expected_kind_changed=[]):
82
"""Check the changes in a TreeDelta
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.
89
If you do not wish to assert anything about a particular
90
category then pass None instead.
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.
101
expected_kind_changed: a list of (path, old_kind, new_kind) tuples
102
that must have been changed in the delta.
104
renamed = changes.renamed
105
added = changes.added
106
removed = changes.removed
107
modified = changes.modified
108
kind_changed = changes.kind_changed
109
if expected_renamed is not None:
110
self.assertEquals(len(renamed), len(expected_renamed),
111
"%s is renamed, expected %s" % (renamed, expected_renamed))
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),
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),
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),
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,
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))
152
def assertContent(self, branch, tree, path, content):
153
file_id = tree.inventory.path2id(path)
155
self.addCleanup(branch.unlock)
156
self.assertEqual(tree.get_file_text(file_id), content)
158
def assertSymlinkTarget(self, branch, tree, path, target):
159
file_id = tree.inventory.path2id(path)
161
self.addCleanup(branch.unlock)
162
self.assertEqual(tree.get_symlink_target(file_id), target)
164
def assertExecutable(self, branch, tree, path, executable):
165
file_id = tree.inventory.path2id(path)
167
self.addCleanup(branch.unlock)
168
self.assertEqual(tree.is_executable(file_id), executable)
170
def assertRevisionRoot(self, revtree, path):
171
self.assertEqual(revtree.get_revision_id(),
172
revtree.inventory.root.children[path].revision)
175
class TestImportToPackModify(TestCaseForGenericProcessor):
177
def file_command_iter(self, path, kind='file', content='aaa',
178
executable=False, to_kind=None, to_content='bbb', to_executable=None):
179
# Revno 1: create a file or symlink
183
if to_executable is None:
184
to_executable = executable
186
author = ['', 'bugs@a.com', time.time(), time.timezone]
187
committer = ['', 'elmer@a.com', time.time(), time.timezone]
189
yield commands.FileModifyCommand(path, kind, executable,
191
yield commands.CommitCommand('head', '1', author,
192
committer, "commit 1", None, [], files_one)
194
yield commands.FileModifyCommand(path, to_kind, to_executable,
196
yield commands.CommitCommand('head', '2', author,
197
committer, "commit 2", ":1", [], files_two)
200
def test_modify_file_in_root(self):
201
handler, branch = self.get_handler()
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)
213
def test_modify_file_in_subdir(self):
214
handler, branch = self.get_handler()
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")
224
def test_modify_symlink_in_root(self):
225
handler, branch = self.get_handler()
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)
235
def test_modify_symlink_in_subdir(self):
236
handler, branch = self.get_handler()
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")
246
def test_modify_file_becomes_symlink(self):
247
handler, branch = self.get_handler()
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")
258
def test_modify_symlink_becomes_file(self):
259
handler, branch = self.get_handler()
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")
270
def test_modify_file_now_executable(self):
271
handler, branch = self.get_handler()
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)
282
def test_modify_file_no_longer_executable(self):
283
handler, branch = self.get_handler()
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)
295
class TestImportToPackModifyTwice(TestCaseForGenericProcessor):
296
"""This tests when the same file is modified twice in the one commit.
298
Note: hg-fast-export produces data like this on occasions.
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
306
if to_executable is None:
307
to_executable = executable
309
author = ['', 'bugs@a.com', time.time(), time.timezone]
310
committer = ['', 'elmer@a.com', time.time(), time.timezone]
312
yield commands.FileModifyCommand(path, kind, executable,
314
yield commands.FileModifyCommand(path, to_kind, to_executable,
316
yield commands.CommitCommand('head', '1', author,
317
committer, "commit 1", None, [], files_one)
320
def test_modify_file_twice_in_root(self):
321
handler, branch = self.get_handler()
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)
330
class TestImportToPackModifyTricky(TestCaseForGenericProcessor):
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
339
author = ['', 'bugs@a.com', time.time(), time.timezone]
340
committer = ['', 'elmer@a.com', time.time(), time.timezone]
342
yield commands.FileModifyCommand(path1, kind, False,
344
yield commands.CommitCommand('head', '1', author,
345
committer, "commit 1", None, [], files_one)
347
yield commands.FileModifyCommand(path2, kind, False,
349
yield commands.CommitCommand('head', '2', author,
350
committer, "commit 2", ":1", [], files_two)
354
def test_modify_file_becomes_directory(self):
355
handler, branch = self.get_handler()
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")
367
def test_modify_directory_becomes_file(self):
368
handler, branch = self.get_handler()
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")
380
def test_modify_symlink_becomes_directory(self):
381
handler, branch = self.get_handler()
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")
393
def test_modify_directory_becomes_symlink(self):
394
handler, branch = self.get_handler()
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")
407
class TestImportToPackDelete(TestCaseForGenericProcessor):
409
def file_command_iter(self, path, kind='file'):
410
# Revno 1: create a file or symlink
413
author = ['', 'bugs@a.com', time.time(), time.timezone]
414
committer = ['', 'elmer@a.com', time.time(), time.timezone]
416
yield commands.FileModifyCommand(path, kind, False,
418
yield commands.CommitCommand('head', '1', author,
419
committer, "commit 1", None, [], files_one)
421
yield commands.FileDeleteCommand(path)
422
yield commands.CommitCommand('head', '2', author,
423
committer, "commit 2", ":1", [], files_two)
426
def test_delete_file_in_root(self):
427
handler, branch = self.get_handler()
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)
437
def test_delete_file_in_subdir(self):
438
handler, branch = self.get_handler()
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,
444
expected_removed=[('a',), (path,)])
445
self.assertContent(branch, revtree1, path, "aaa")
447
def test_delete_symlink_in_root(self):
448
handler, branch = self.get_handler()
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)
456
def test_delete_symlink_in_subdir(self):
457
handler, branch = self.get_handler()
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,
463
expected_removed=[('a',), (path,)])
464
self.assertSymlinkTarget(branch, revtree1, path, "aaa")
466
def test_delete_file_in_deep_subdir(self):
467
handler, branch = self.get_handler()
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")
477
class TestImportToPackDeleteNew(TestCaseForGenericProcessor):
478
"""Test deletion of a newly added file."""
480
def file_command_iter(self, path, kind='file'):
481
# Revno 1: create a file or symlink then delete it
483
author = ['', 'bugs@a.com', time.time(), time.timezone]
484
committer = ['', 'elmer@a.com', time.time(), time.timezone]
486
yield commands.FileModifyCommand(path, kind, False,
488
yield commands.FileDeleteCommand(path)
489
yield commands.CommitCommand('head', '1', author,
490
committer, "commit 1", None, [], files_one)
493
def test_delete_new_file_in_root(self):
494
handler, branch = self.get_handler()
496
handler.process(self.file_command_iter(path))
497
revtree0, revtree1 = self.assertChanges(branch, 1,)
499
def test_delete_new_file_in_subdir(self):
500
handler, branch = self.get_handler()
502
handler.process(self.file_command_iter(path))
503
revtree0, revtree1 = self.assertChanges(branch, 1,)
505
def test_delete_new_symlink_in_root(self):
506
handler, branch = self.get_handler()
508
handler.process(self.file_command_iter(path, kind='symlink'))
509
revtree0, revtree1 = self.assertChanges(branch, 1,)
511
def test_delete_new_symlink_in_subdir(self):
512
handler, branch = self.get_handler()
514
handler.process(self.file_command_iter(path, kind='symlink'))
515
revtree0, revtree1 = self.assertChanges(branch, 1,)
517
def test_delete_new_file_in_deep_subdir(self):
518
handler, branch = self.get_handler()
520
handler.process(self.file_command_iter(path))
521
revtree0, revtree1 = self.assertChanges(branch, 1,)
524
class TestImportToPackDeleteMultiLevel(TestCaseForGenericProcessor):
526
def file_command_iter(self, paths, paths_to_delete):
527
# Revno 1: create multiple files
528
# Revno 2: delete multiple files
530
author = ['', 'bugs@a.com', time.time(), time.timezone]
531
committer = ['', 'elmer@a.com', time.time(), time.timezone]
533
for i, path in enumerate(paths):
534
yield commands.FileModifyCommand(path, 'file', False,
536
yield commands.CommitCommand('head', '1', author,
537
committer, "commit 1", None, [], files_one)
539
for path in paths_to_delete:
540
yield commands.FileDeleteCommand(path)
541
yield commands.CommitCommand('head', '2', author,
542
committer, "commit 2", ":1", [], files_two)
545
def test_delete_files_in_multiple_levels(self):
546
handler, branch = self.get_handler()
547
paths = ['a/b/c', 'a/b/d/e']
548
paths_to_delete = ['a/b/c', 'a/b/d/e']
549
handler.process(self.file_command_iter(paths, paths_to_delete))
550
revtree0, revtree1 = self.assertChanges(branch, 1,
552
('a',), ('a/b',), ('a/b/c',),
553
('a/b/d',), ('a/b/d/e',),
555
revtree1, revtree2 = self.assertChanges(branch, 2,
557
('a',), ('a/b',), ('a/b/c',),
558
('a/b/d',), ('a/b/d/e',),
561
def test_delete_file_single_level(self):
562
handler, branch = self.get_handler()
563
paths = ['a/b/c', 'a/b/d/e']
564
paths_to_delete = ['a/b/d/e']
565
handler.process(self.file_command_iter(paths, paths_to_delete))
566
revtree0, revtree1 = self.assertChanges(branch, 1,
568
('a',), ('a/b',), ('a/b/c',),
569
('a/b/d',), ('a/b/d/e',),
571
revtree1, revtree2 = self.assertChanges(branch, 2,
573
('a/b/d',), ('a/b/d/e',),
576
def test_delete_file_complex_level(self):
577
handler, branch = self.get_handler()
578
paths = ['a/b/c', 'a/b/d/e', 'a/f/g', 'a/h', 'a/b/d/i/j']
579
paths_to_delete = ['a/b/c', 'a/b/d/e', 'a/f/g', 'a/b/d/i/j']
580
handler.process(self.file_command_iter(paths, paths_to_delete))
581
revtree0, revtree1 = self.assertChanges(branch, 1,
583
('a',), ('a/b',), ('a/b/c',),
584
('a/b/d',), ('a/b/d/e',),
585
('a/f',), ('a/f/g',),
587
('a/b/d/i',), ('a/b/d/i/j',),
589
revtree1, revtree2 = self.assertChanges(branch, 2,
591
('a/b',), ('a/b/c',),
592
('a/b/d',), ('a/b/d/e',),
593
('a/f',), ('a/f/g',),
594
('a/b/d/i',), ('a/b/d/i/j',),
597
class TestImportToPackDeleteThenAdd(TestCaseForGenericProcessor):
598
"""Test delete followed by an add. Merges can cause this."""
600
def file_command_iter(self, path, kind='file', content='aaa',
601
executable=False, to_kind=None, to_content='bbb', to_executable=None):
602
# Revno 1: create a file or symlink
603
# Revno 2: delete it and add it
606
if to_executable is None:
607
to_executable = executable
609
author = ['', 'bugs@a.com', time.time(), time.timezone]
610
committer = ['', 'elmer@a.com', time.time(), time.timezone]
612
yield commands.FileModifyCommand(path, kind, executable,
614
yield commands.CommitCommand('head', '1', author,
615
committer, "commit 1", None, [], files_one)
617
yield commands.FileDeleteCommand(path)
618
yield commands.FileModifyCommand(path, to_kind, to_executable,
620
yield commands.CommitCommand('head', '2', author,
621
committer, "commit 2", ":1", [], files_two)
624
def test_delete_then_add_file_in_root(self):
625
handler, branch = self.get_handler()
627
handler.process(self.file_command_iter(path))
628
revtree0, revtree1 = self.assertChanges(branch, 1,
629
expected_added=[(path,)])
630
revtree1, revtree2 = self.assertChanges(branch, 2,
631
expected_removed=[(path,)],
632
expected_added=[(path,)])
633
self.assertContent(branch, revtree1, path, "aaa")
634
self.assertContent(branch, revtree2, path, "bbb")
635
self.assertRevisionRoot(revtree1, path)
636
self.assertRevisionRoot(revtree2, path)
638
def test_delete_then_add_file_in_subdir(self):
639
handler, branch = self.get_handler()
641
handler.process(self.file_command_iter(path))
642
revtree0, revtree1 = self.assertChanges(branch, 1,
643
expected_added=[('a',), (path,)])
644
revtree1, revtree2 = self.assertChanges(branch, 2,
645
expected_removed=[(path,)],
646
expected_added=[(path,)])
647
self.assertContent(branch, revtree1, path, "aaa")
648
self.assertContent(branch, revtree2, path, "bbb")
650
def test_delete_then_add_symlink_in_root(self):
651
handler, branch = self.get_handler()
653
handler.process(self.file_command_iter(path, kind='symlink'))
654
revtree1, revtree2 = self.assertChanges(branch, 2,
655
expected_removed=[(path,)],
656
expected_added=[(path,)])
657
self.assertSymlinkTarget(branch, revtree1, path, "aaa")
658
self.assertSymlinkTarget(branch, revtree2, path, "bbb")
659
self.assertRevisionRoot(revtree1, path)
660
self.assertRevisionRoot(revtree2, path)
662
def test_delete_then_add_symlink_in_subdir(self):
663
handler, branch = self.get_handler()
665
handler.process(self.file_command_iter(path, kind='symlink'))
666
revtree0, revtree1 = self.assertChanges(branch, 1,
667
expected_added=[('a',), (path,)])
668
revtree1, revtree2 = self.assertChanges(branch, 2,
669
expected_removed=[(path,)],
670
expected_added=[(path,)])
671
self.assertSymlinkTarget(branch, revtree1, path, "aaa")
672
self.assertSymlinkTarget(branch, revtree2, path, "bbb")
675
class TestImportToPackDeleteDirectory(TestCaseForGenericProcessor):
677
def file_command_iter(self, paths, dir):
678
# Revno 1: create multiple files
679
# Revno 2: delete a directory holding those files
681
author = ['', 'bugs@a.com', time.time(), time.timezone]
682
committer = ['', 'elmer@a.com', time.time(), time.timezone]
684
for i, path in enumerate(paths):
685
yield commands.FileModifyCommand(path, 'file', False,
687
yield commands.CommitCommand('head', '1', author,
688
committer, "commit 1", None, [], files_one)
690
yield commands.FileDeleteCommand(dir)
691
yield commands.CommitCommand('head', '2', author,
692
committer, "commit 2", ":1", [], files_two)
695
def test_delete_dir(self):
696
handler, branch = self.get_handler()
697
paths = ['a/b/c', 'a/b/d', 'a/b/e/f', 'a/g']
699
handler.process(self.file_command_iter(paths, dir))
700
revtree0, revtree1 = self.assertChanges(branch, 1,
702
('a',), ('a/b',), ('a/b/c',),
704
('a/b/e',), ('a/b/e/f',),
707
revtree1, revtree2 = self.assertChanges(branch, 2,
709
('a/b',), ('a/b/c',),
711
('a/b/e',), ('a/b/e/f',),
715
class TestImportToPackDeleteDirectoryThenAddFile(TestCaseForGenericProcessor):
716
"""Test deleting a directory then adding a file in the same commit."""
718
def file_command_iter(self, paths, dir, new_path, kind='file'):
719
# Revno 1: create files in a directory
720
# Revno 2: delete the directory then add a file into it
722
author = ['', 'bugs@a.com', time.time(), time.timezone]
723
committer = ['', 'elmer@a.com', time.time(), time.timezone]
725
for i, path in enumerate(paths):
726
yield commands.FileModifyCommand(path, kind, False,
728
yield commands.CommitCommand('head', '1', author,
729
committer, "commit 1", None, [], files_one)
731
yield commands.FileDeleteCommand(dir)
732
yield commands.FileModifyCommand(new_path, kind, False,
734
yield commands.CommitCommand('head', '2', author,
735
committer, "commit 2", ":1", [], files_two)
738
def test_delete_dir_then_add_file(self):
739
handler, branch = self.get_handler()
740
paths = ['a/b/c', 'a/b/d']
743
handler.process(self.file_command_iter(paths, dir, new_path))
744
revtree0, revtree1 = self.assertChanges(branch, 1,
745
expected_added=[('a',), ('a/b',), ('a/b/c',), ('a/b/d',),])
746
revtree1, revtree2 = self.assertChanges(branch, 2,
747
expected_removed=[('a/b',), ('a/b/c',), ('a/b/d',)],
748
expected_added=[('a/b',), ('a/b/z',)])
749
self.assertContent(branch, revtree2, new_path, "bbb")
751
def test_delete_dir_then_add_symlink(self):
752
handler, branch = self.get_handler()
753
paths = ['a/b/c', 'a/b/d']
756
handler.process(self.file_command_iter(paths, dir, new_path, 'symlink'))
757
revtree0, revtree1 = self.assertChanges(branch, 1,
758
expected_added=[('a',), ('a/b',), ('a/b/c',), ('a/b/d',),])
759
revtree1, revtree2 = self.assertChanges(branch, 2,
760
expected_removed=[('a/b',), ('a/b/c',), ('a/b/d',)],
761
expected_added=[('a/b',), ('a/b/z',)])
762
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
765
class TestImportToPackRename(TestCaseForGenericProcessor):
767
def get_command_iter(self, old_path, new_path, kind='file'):
768
# Revno 1: create a file or symlink
771
author = ['', 'bugs@a.com', time.time(), time.timezone]
772
committer = ['', 'elmer@a.com', time.time(), time.timezone]
774
yield commands.FileModifyCommand(old_path, kind, False,
776
yield commands.CommitCommand('head', '1', author,
777
committer, "commit 1", None, [], files_one)
779
yield commands.FileRenameCommand(old_path, new_path)
780
yield commands.CommitCommand('head', '2', author,
781
committer, "commit 2", ":1", [], files_two)
784
def test_rename_file_in_root(self):
785
handler, branch = self.get_handler()
788
handler.process(self.get_command_iter(old_path, new_path))
789
revtree1, revtree2 = self.assertChanges(branch, 2,
790
expected_renamed=[(old_path, new_path)])
791
self.assertRevisionRoot(revtree1, old_path)
792
self.assertRevisionRoot(revtree2, new_path)
794
def test_rename_symlink_in_root(self):
795
handler, branch = self.get_handler()
798
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
799
revtree1, revtree2 = self.assertChanges(branch, 2,
800
expected_renamed=[(old_path, new_path)])
801
self.assertRevisionRoot(revtree1, old_path)
802
self.assertRevisionRoot(revtree2, new_path)
804
def test_rename_file_in_subdir(self):
805
handler, branch = self.get_handler()
808
handler.process(self.get_command_iter(old_path, new_path))
809
self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)])
811
def test_rename_symlink_in_subdir(self):
812
handler, branch = self.get_handler()
815
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
816
self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)])
818
def test_rename_file_to_new_dir(self):
819
handler, branch = self.get_handler()
822
handler.process(self.get_command_iter(old_path, new_path))
823
self.assertChanges(branch, 2,
824
expected_renamed=[(old_path, new_path)],
825
expected_added=[('b',)],
826
expected_removed=[('a',)])
828
def test_rename_symlink_to_new_dir(self):
829
handler, branch = self.get_handler()
832
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
833
self.assertChanges(branch, 2,
834
expected_renamed=[(old_path, new_path)],
835
expected_added=[('b',)],
836
expected_removed=[('a',)])
839
class TestImportToPackRenameNew(TestCaseForGenericProcessor):
840
"""Test rename of a newly added file."""
842
def get_command_iter(self, old_path, new_path, kind='file'):
843
# Revno 1: create a file and rename it
845
author = ['', 'bugs@a.com', time.time(), time.timezone]
846
committer = ['', 'elmer@a.com', time.time(), time.timezone]
848
yield commands.FileModifyCommand(old_path, kind, False,
850
yield commands.FileRenameCommand(old_path, new_path)
851
yield commands.CommitCommand('head', '1', author,
852
committer, "commit 1", None, [], files_one)
855
def test_rename_new_file_in_root(self):
856
handler, branch = self.get_handler()
859
handler.process(self.get_command_iter(old_path, new_path))
860
revtree0, revtree1 = self.assertChanges(branch, 1,
861
expected_added=[(new_path,)])
862
self.assertRevisionRoot(revtree1, new_path)
864
def test_rename_new_symlink_in_root(self):
865
handler, branch = self.get_handler()
868
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
869
revtree0, revtree1 = self.assertChanges(branch, 1,
870
expected_added=[(new_path,)])
871
self.assertRevisionRoot(revtree1, new_path)
873
def test_rename_new_file_in_subdir(self):
874
handler, branch = self.get_handler()
877
handler.process(self.get_command_iter(old_path, new_path))
878
revtree0, revtree1 = self.assertChanges(branch, 1,
879
expected_added=[('a',), (new_path,)])
881
def test_rename_new_symlink_in_subdir(self):
882
handler, branch = self.get_handler()
885
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
886
revtree0, revtree1 = self.assertChanges(branch, 1,
887
expected_added=[('a',), (new_path,)])
890
class TestImportToPackRenameToDeleted(TestCaseForGenericProcessor):
891
"""Test rename to a destination path deleted in this commit."""
893
def get_command_iter(self, old_path, new_path, kind='file'):
894
# Revno 1: create two files
895
# Revno 2: delete one, rename the other one to that path
897
author = ['', 'bugs@a.com', time.time(), time.timezone]
898
committer = ['', 'elmer@a.com', time.time(), time.timezone]
900
yield commands.FileModifyCommand(old_path, kind, False,
902
yield commands.FileModifyCommand(new_path, kind, False,
904
yield commands.CommitCommand('head', '1', author,
905
committer, "commit 1", None, [], files_one)
907
yield commands.FileDeleteCommand(new_path)
908
yield commands.FileRenameCommand(old_path, new_path)
909
yield commands.CommitCommand('head', '2', author,
910
committer, "commit 2", ":1", [], files_two)
913
def test_rename_to_deleted_file_in_root(self):
914
handler, branch = self.get_handler()
917
handler.process(self.get_command_iter(old_path, new_path))
918
revtree0, revtree1 = self.assertChanges(branch, 1,
919
expected_added=[(old_path,), (new_path,)])
920
revtree1, revtree2 = self.assertChanges(branch, 2,
921
expected_removed=[(new_path,)],
922
expected_renamed=[(old_path, new_path)])
923
self.assertContent(branch, revtree1, old_path, "aaa")
924
self.assertContent(branch, revtree1, new_path, "bbb")
925
self.assertContent(branch, revtree2, new_path, "aaa")
926
self.assertRevisionRoot(revtree1, old_path)
927
self.assertRevisionRoot(revtree1, new_path)
929
def test_rename_to_deleted_symlink_in_root(self):
930
handler, branch = self.get_handler()
933
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
934
revtree0, revtree1 = self.assertChanges(branch, 1,
935
expected_added=[(old_path,), (new_path,)])
936
revtree1, revtree2 = self.assertChanges(branch, 2,
937
expected_removed=[(new_path,)],
938
expected_renamed=[(old_path, new_path)])
939
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
940
self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
941
self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
942
self.assertRevisionRoot(revtree1, old_path)
943
self.assertRevisionRoot(revtree1, new_path)
945
def test_rename_to_deleted_file_in_subdir(self):
946
handler, branch = self.get_handler()
949
handler.process(self.get_command_iter(old_path, new_path))
950
revtree0, revtree1 = self.assertChanges(branch, 1,
951
expected_added=[('d',), (old_path,), (new_path,)])
952
revtree1, revtree2 = self.assertChanges(branch, 2,
953
expected_removed=[(new_path,)],
954
expected_renamed=[(old_path, new_path)])
955
self.assertContent(branch, revtree1, old_path, "aaa")
956
self.assertContent(branch, revtree1, new_path, "bbb")
957
self.assertContent(branch, revtree2, new_path, "aaa")
959
def test_rename_to_deleted_symlink_in_subdir(self):
960
handler, branch = self.get_handler()
963
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
964
revtree0, revtree1 = self.assertChanges(branch, 1,
965
expected_added=[('d',), (old_path,), (new_path,)])
966
revtree1, revtree2 = self.assertChanges(branch, 2,
967
expected_removed=[(new_path,)],
968
expected_renamed=[(old_path, new_path)])
969
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
970
self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
971
self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
973
def test_rename_to_deleted_file_in_new_dir(self):
974
handler, branch = self.get_handler()
977
handler.process(self.get_command_iter(old_path, new_path))
978
revtree0, revtree1 = self.assertChanges(branch, 1,
979
expected_added=[('d1',), (old_path,), ('d2',), (new_path,)])
980
revtree1, revtree2 = self.assertChanges(branch, 2,
981
expected_removed=[('d1',), (new_path,)],
982
expected_renamed=[(old_path, new_path)])
983
self.assertContent(branch, revtree1, old_path, "aaa")
984
self.assertContent(branch, revtree1, new_path, "bbb")
985
self.assertContent(branch, revtree2, new_path, "aaa")
987
def test_rename_to_deleted_symlink_in_new_dir(self):
988
handler, branch = self.get_handler()
991
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
992
revtree0, revtree1 = self.assertChanges(branch, 1,
993
expected_added=[('d1',), (old_path,), ('d2',), (new_path,)])
994
revtree1, revtree2 = self.assertChanges(branch, 2,
995
expected_removed=[('d1',), (new_path,)],
996
expected_renamed=[(old_path, new_path)])
997
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
998
self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
999
self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
1002
class TestImportToPackRenameModified(TestCaseForGenericProcessor):
1003
"""Test rename of a path previously modified in this commit."""
1005
def get_command_iter(self, old_path, new_path, kind='file'):
1006
# Revno 1: create a file or symlink
1007
# Revno 2: modify then rename it
1009
author = ['', 'bugs@a.com', time.time(), time.timezone]
1010
committer = ['', 'elmer@a.com', time.time(), time.timezone]
1012
yield commands.FileModifyCommand(old_path, kind, False,
1014
yield commands.CommitCommand('head', '1', author,
1015
committer, "commit 1", None, [], files_one)
1017
yield commands.FileModifyCommand(old_path, kind, False,
1019
yield commands.FileRenameCommand(old_path, new_path)
1020
yield commands.CommitCommand('head', '2', author,
1021
committer, "commit 2", ":1", [], files_two)
1024
def test_rename_of_modified_file_in_root(self):
1025
handler, branch = self.get_handler()
1028
handler.process(self.get_command_iter(old_path, new_path))
1029
revtree0, revtree1 = self.assertChanges(branch, 1,
1030
expected_added=[(old_path,)])
1031
# Note: the delta doesn't show the modification?
1032
# The actual new content is validated in the assertions following.
1033
revtree1, revtree2 = self.assertChanges(branch, 2,
1034
expected_renamed=[(old_path, new_path)])
1035
self.assertContent(branch, revtree1, old_path, "aaa")
1036
self.assertContent(branch, revtree2, new_path, "bbb")
1037
self.assertRevisionRoot(revtree1, old_path)
1038
self.assertRevisionRoot(revtree2, new_path)
1040
def test_rename_of_modified_symlink_in_root(self):
1041
handler, branch = self.get_handler()
1044
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1045
revtree0, revtree1 = self.assertChanges(branch, 1,
1046
expected_added=[(old_path,)])
1047
# Note: the delta doesn't show the modification?
1048
# The actual new content is validated in the assertions following.
1049
revtree1, revtree2 = self.assertChanges(branch, 2,
1050
expected_renamed=[(old_path, new_path)])
1051
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1052
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1053
self.assertRevisionRoot(revtree1, old_path)
1054
self.assertRevisionRoot(revtree2, new_path)
1056
def test_rename_of_modified_file_in_subdir(self):
1057
handler, branch = self.get_handler()
1060
handler.process(self.get_command_iter(old_path, new_path))
1061
revtree0, revtree1 = self.assertChanges(branch, 1,
1062
expected_added=[('d',), (old_path,)])
1063
# Note: the delta doesn't show the modification?
1064
# The actual new content is validated in the assertions following.
1065
revtree1, revtree2 = self.assertChanges(branch, 2,
1066
expected_renamed=[(old_path, new_path)])
1067
self.assertContent(branch, revtree1, old_path, "aaa")
1068
self.assertContent(branch, revtree2, new_path, "bbb")
1070
def test_rename_of_modified_symlink_in_subdir(self):
1071
handler, branch = self.get_handler()
1074
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1075
revtree0, revtree1 = self.assertChanges(branch, 1,
1076
expected_added=[('d',), (old_path,)])
1077
# Note: the delta doesn't show the modification?
1078
# The actual new content is validated in the assertions following.
1079
revtree1, revtree2 = self.assertChanges(branch, 2,
1080
expected_renamed=[(old_path, new_path)])
1081
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1082
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1084
def test_rename_of_modified_file_to_new_dir(self):
1085
handler, branch = self.get_handler()
1088
handler.process(self.get_command_iter(old_path, new_path))
1089
revtree0, revtree1 = self.assertChanges(branch, 1,
1090
expected_added=[('d1',), (old_path,)])
1091
# Note: the delta doesn't show the modification?
1092
# The actual new content is validated in the assertions following.
1093
revtree1, revtree2 = self.assertChanges(branch, 2,
1094
expected_renamed=[(old_path, new_path)],
1095
expected_added=[('d2',)],
1096
expected_removed=[('d1',)])
1097
self.assertContent(branch, revtree1, old_path, "aaa")
1098
self.assertContent(branch, revtree2, new_path, "bbb")
1100
def test_rename_of_modified_symlink_to_new_dir(self):
1101
handler, branch = self.get_handler()
1104
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1105
revtree0, revtree1 = self.assertChanges(branch, 1,
1106
expected_added=[('d1',), (old_path,)])
1107
# Note: the delta doesn't show the modification?
1108
# The actual new content is validated in the assertions following.
1109
revtree1, revtree2 = self.assertChanges(branch, 2,
1110
expected_renamed=[(old_path, new_path)],
1111
expected_added=[('d2',)],
1112
expected_removed=[('d1',)])
1113
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1114
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1117
class TestImportToPackRenameThenModify(TestCaseForGenericProcessor):
1118
"""Test rename of a path then modfy the new-path in the same commit."""
1120
def get_command_iter(self, old_path, new_path, kind='file'):
1121
# Revno 1: create a file or symlink
1122
# Revno 2: rename it then modify the newly created path
1124
author = ['', 'bugs@a.com', time.time(), time.timezone]
1125
committer = ['', 'elmer@a.com', time.time(), time.timezone]
1127
yield commands.FileModifyCommand(old_path, kind, False,
1129
yield commands.CommitCommand('head', '1', author,
1130
committer, "commit 1", None, [], files_one)
1132
yield commands.FileRenameCommand(old_path, new_path)
1133
yield commands.FileModifyCommand(new_path, kind, False,
1135
yield commands.CommitCommand('head', '2', author,
1136
committer, "commit 2", ":1", [], files_two)
1139
def test_rename_then_modify_file_in_root(self):
1140
handler, branch = self.get_handler()
1143
handler.process(self.get_command_iter(old_path, new_path))
1144
revtree0, revtree1 = self.assertChanges(branch, 1,
1145
expected_added=[(old_path,)])
1146
# Note: the delta doesn't show the modification?
1147
# The actual new content is validated in the assertions following.
1148
revtree1, revtree2 = self.assertChanges(branch, 2,
1149
expected_renamed=[(old_path, new_path)])
1150
self.assertContent(branch, revtree1, old_path, "aaa")
1151
self.assertContent(branch, revtree2, new_path, "bbb")
1152
self.assertRevisionRoot(revtree1, old_path)
1153
self.assertRevisionRoot(revtree2, new_path)
1155
def test_rename_then_modify_file_in_subdir(self):
1156
handler, branch = self.get_handler()
1159
handler.process(self.get_command_iter(old_path, new_path))
1160
revtree0, revtree1 = self.assertChanges(branch, 1,
1161
expected_added=[('d',), (old_path,)])
1162
# Note: the delta doesn't show the modification?
1163
# The actual new content is validated in the assertions following.
1164
revtree1, revtree2 = self.assertChanges(branch, 2,
1165
expected_renamed=[(old_path, new_path)])
1166
self.assertContent(branch, revtree1, old_path, "aaa")
1167
self.assertContent(branch, revtree2, new_path, "bbb")
1169
def test_rename_then_modify_file_in_new_dir(self):
1170
handler, branch = self.get_handler()
1173
handler.process(self.get_command_iter(old_path, new_path))
1174
revtree0, revtree1 = self.assertChanges(branch, 1,
1175
expected_added=[('d1',), (old_path,)])
1176
# Note: the delta doesn't show the modification?
1177
# The actual new content is validated in the assertions following.
1178
revtree1, revtree2 = self.assertChanges(branch, 2,
1179
expected_renamed=[(old_path, new_path)],
1180
expected_added=[('d2',)],
1181
expected_removed=[('d1',)])
1182
self.assertContent(branch, revtree1, old_path, "aaa")
1183
self.assertContent(branch, revtree2, new_path, "bbb")
1185
def test_rename_then_modify_symlink_in_root(self):
1186
handler, branch = self.get_handler()
1189
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1190
revtree0, revtree1 = self.assertChanges(branch, 1,
1191
expected_added=[(old_path,)])
1192
# Note: the delta doesn't show the modification?
1193
# The actual new content is validated in the assertions following.
1194
revtree1, revtree2 = self.assertChanges(branch, 2,
1195
expected_renamed=[(old_path, new_path)])
1196
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1197
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1198
self.assertRevisionRoot(revtree1, old_path)
1199
self.assertRevisionRoot(revtree2, new_path)
1201
def test_rename_then_modify_symlink_in_subdir(self):
1202
handler, branch = self.get_handler()
1205
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1206
revtree0, revtree1 = self.assertChanges(branch, 1,
1207
expected_added=[('d',), (old_path,)])
1208
# Note: the delta doesn't show the modification?
1209
# The actual new content is validated in the assertions following.
1210
revtree1, revtree2 = self.assertChanges(branch, 2,
1211
expected_renamed=[(old_path, new_path)])
1212
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1213
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1215
def test_rename_then_modify_symlink_in_new_dir(self):
1216
handler, branch = self.get_handler()
1219
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1220
revtree0, revtree1 = self.assertChanges(branch, 1,
1221
expected_added=[('d1',), (old_path,)])
1222
# Note: the delta doesn't show the modification?
1223
# The actual new content is validated in the assertions following.
1224
revtree1, revtree2 = self.assertChanges(branch, 2,
1225
expected_renamed=[(old_path, new_path)],
1226
expected_added=[('d2',)],
1227
expected_removed=[('d1',)])
1228
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1229
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1232
class TestImportToPackDeleteRenameThenModify(TestCaseForGenericProcessor):
1233
"""Test rename of to a deleted path then modfy the new-path in the same commit."""
1235
def get_command_iter(self, old_path, new_path, kind='file'):
1236
# Revno 1: create two files or symlinks
1237
# Revno 2: delete one, rename the other to it then modify the newly created path
1239
author = ['', 'bugs@a.com', time.time(), time.timezone]
1240
committer = ['', 'elmer@a.com', time.time(), time.timezone]
1242
yield commands.FileModifyCommand(old_path, kind, False,
1244
yield commands.FileModifyCommand(new_path, kind, False,
1246
yield commands.CommitCommand('head', '1', author,
1247
committer, "commit 1", None, [], files_one)
1249
yield commands.FileDeleteCommand(new_path)
1250
yield commands.FileRenameCommand(old_path, new_path)
1251
yield commands.FileModifyCommand(new_path, kind, False,
1253
yield commands.CommitCommand('head', '2', author,
1254
committer, "commit 2", ":1", [], files_two)
1257
def test_delete_rename_then_modify_file_in_root(self):
1258
handler, branch = self.get_handler()
1261
handler.process(self.get_command_iter(old_path, new_path))
1262
revtree0, revtree1 = self.assertChanges(branch, 1,
1263
expected_added=[(old_path,), (new_path,)])
1264
# Note: the delta doesn't show the modification?
1265
# The actual new content is validated in the assertions following.
1266
revtree1, revtree2 = self.assertChanges(branch, 2,
1267
expected_removed=[(new_path,)],
1268
expected_renamed=[(old_path, new_path)])
1269
self.assertContent(branch, revtree1, old_path, "aaa")
1270
self.assertContent(branch, revtree1, new_path, "zzz")
1271
self.assertContent(branch, revtree2, new_path, "bbb")
1272
self.assertRevisionRoot(revtree1, old_path)
1273
self.assertRevisionRoot(revtree1, new_path)
1274
self.assertRevisionRoot(revtree2, new_path)
1276
def test_delete_rename_then_modify_file_in_subdir(self):
1277
handler, branch = self.get_handler()
1280
handler.process(self.get_command_iter(old_path, new_path))
1281
revtree0, revtree1 = self.assertChanges(branch, 1,
1282
expected_added=[('d',), (old_path,), (new_path,)])
1283
# Note: the delta doesn't show the modification?
1284
# The actual new content is validated in the assertions following.
1285
revtree1, revtree2 = self.assertChanges(branch, 2,
1286
expected_removed=[(new_path,)],
1287
expected_renamed=[(old_path, new_path)])
1288
self.assertContent(branch, revtree1, old_path, "aaa")
1289
self.assertContent(branch, revtree1, new_path, "zzz")
1290
self.assertContent(branch, revtree2, new_path, "bbb")
1292
def test_delete_rename_then_modify_file_in_new_dir(self):
1293
handler, branch = self.get_handler()
1296
handler.process(self.get_command_iter(old_path, new_path))
1297
revtree0, revtree1 = self.assertChanges(branch, 1,
1298
expected_added=[('d1',), ('d2',), (old_path,), (new_path,)])
1299
# Note: the delta doesn't show the modification?
1300
# The actual new content is validated in the assertions following.
1301
revtree1, revtree2 = self.assertChanges(branch, 2,
1302
expected_removed=[('d1',), (new_path,)],
1303
expected_renamed=[(old_path, new_path)])
1304
self.assertContent(branch, revtree1, old_path, "aaa")
1305
self.assertContent(branch, revtree1, new_path, "zzz")
1306
self.assertContent(branch, revtree2, new_path, "bbb")
1308
def test_delete_rename_then_modify_symlink_in_root(self):
1309
handler, branch = self.get_handler()
1312
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1313
revtree0, revtree1 = self.assertChanges(branch, 1,
1314
expected_added=[(old_path,), (new_path,)])
1315
# Note: the delta doesn't show the modification?
1316
# The actual new content is validated in the assertions following.
1317
revtree1, revtree2 = self.assertChanges(branch, 2,
1318
expected_removed=[(new_path,)],
1319
expected_renamed=[(old_path, new_path)])
1320
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1321
self.assertSymlinkTarget(branch, revtree1, new_path, "zzz")
1322
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1323
self.assertRevisionRoot(revtree1, old_path)
1324
self.assertRevisionRoot(revtree1, new_path)
1325
self.assertRevisionRoot(revtree2, new_path)
1327
def test_delete_rename_then_modify_symlink_in_subdir(self):
1328
handler, branch = self.get_handler()
1331
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1332
revtree0, revtree1 = self.assertChanges(branch, 1,
1333
expected_added=[('d',), (old_path,), (new_path,)])
1334
# Note: the delta doesn't show the modification?
1335
# The actual new content is validated in the assertions following.
1336
revtree1, revtree2 = self.assertChanges(branch, 2,
1337
expected_removed=[(new_path,)],
1338
expected_renamed=[(old_path, new_path)])
1339
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1340
self.assertSymlinkTarget(branch, revtree1, new_path, "zzz")
1341
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1343
def test_delete_rename_then_modify_symlink_in_new_dir(self):
1344
handler, branch = self.get_handler()
1347
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1348
revtree0, revtree1 = self.assertChanges(branch, 1,
1349
expected_added=[('d1',), ('d2',), (old_path,), (new_path,)])
1350
# Note: the delta doesn't show the modification?
1351
# The actual new content is validated in the assertions following.
1352
revtree1, revtree2 = self.assertChanges(branch, 2,
1353
expected_removed=[('d1',), (new_path,)],
1354
expected_renamed=[(old_path, new_path)])
1355
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1356
self.assertSymlinkTarget(branch, revtree1, new_path, "zzz")
1357
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1360
class TestImportToPackRenameTricky(TestCaseForGenericProcessor):
1362
def file_command_iter(self, path1, old_path2, new_path2, kind='file'):
1363
# Revno 1: create two files or symlinks in a directory
1364
# Revno 2: rename the second file so that it implicitly deletes the
1365
# first one because either:
1366
# * the new file is a in directory with the old file name
1367
# * the new file has the same name as the directory of the first
1369
author = ['', 'bugs@a.com', time.time(), time.timezone]
1370
committer = ['', 'elmer@a.com', time.time(), time.timezone]
1372
yield commands.FileModifyCommand(path1, kind, False,
1374
yield commands.FileModifyCommand(old_path2, kind, False,
1376
yield commands.CommitCommand('head', '1', author,
1377
committer, "commit 1", None, [], files_one)
1379
yield commands.FileRenameCommand(old_path2, new_path2)
1380
yield commands.CommitCommand('head', '2', author,
1381
committer, "commit 2", ":1", [], files_two)
1384
def test_rename_file_becomes_directory(self):
1385
handler, branch = self.get_handler()
1389
handler.process(self.file_command_iter(path1, old_path2, new_path2))
1390
revtree0, revtree1 = self.assertChanges(branch, 1,
1391
expected_added=[('a',), (path1,), (old_path2,)])
1392
revtree1, revtree2 = self.assertChanges(branch, 2,
1393
expected_renamed=[(old_path2, new_path2)],
1394
expected_kind_changed=[(path1, 'file', 'directory')])
1395
self.assertContent(branch, revtree1, path1, "aaa")
1396
self.assertContent(branch, revtree2, new_path2, "bbb")
1398
def test_rename_directory_becomes_file(self):
1399
handler, branch = self.get_handler()
1403
handler.process(self.file_command_iter(path1, old_path2, new_path2))
1404
revtree0, revtree1 = self.assertChanges(branch, 1,
1405
expected_added=[('a',), ('a/b',), (path1,), (old_path2,)])
1406
revtree1, revtree2 = self.assertChanges(branch, 2,
1407
expected_renamed=[(old_path2, new_path2)],
1408
expected_removed=[(path1,), (new_path2,)])
1409
self.assertContent(branch, revtree1, path1, "aaa")
1410
self.assertContent(branch, revtree2, new_path2, "bbb")
1412
def test_rename_symlink_becomes_directory(self):
1413
handler, branch = self.get_handler()
1417
handler.process(self.file_command_iter(path1, old_path2, new_path2,
1419
revtree0, revtree1 = self.assertChanges(branch, 1,
1420
expected_added=[('a',), (path1,), (old_path2,)])
1421
revtree1, revtree2 = self.assertChanges(branch, 2,
1422
expected_renamed=[(old_path2, new_path2)],
1423
expected_kind_changed=[(path1, 'symlink', 'directory')])
1424
self.assertSymlinkTarget(branch, revtree1, path1, "aaa")
1425
self.assertSymlinkTarget(branch, revtree2, new_path2, "bbb")
1427
def test_rename_directory_becomes_symlink(self):
1428
handler, branch = self.get_handler()
1432
handler.process(self.file_command_iter(path1, old_path2, new_path2,
1434
revtree0, revtree1 = self.assertChanges(branch, 1,
1435
expected_added=[('a',), ('a/b',), (path1,), (old_path2,)])
1436
revtree1, revtree2 = self.assertChanges(branch, 2,
1437
expected_renamed=[(old_path2, new_path2)],
1438
expected_removed=[(path1,), (new_path2,)])
1439
self.assertSymlinkTarget(branch, revtree1, path1, "aaa")
1440
self.assertSymlinkTarget(branch, revtree2, new_path2, "bbb")
1443
class TestImportToPackCopy(TestCaseForGenericProcessor):
1445
def file_command_iter(self, src_path, dest_path, kind='file'):
1446
# Revno 1: create a file or symlink
1449
author = ['', 'bugs@a.com', time.time(), time.timezone]
1450
committer = ['', 'elmer@a.com', time.time(), time.timezone]
1452
yield commands.FileModifyCommand(src_path, kind, False,
1454
yield commands.CommitCommand('head', '1', author,
1455
committer, "commit 1", None, [], files_one)
1457
yield commands.FileCopyCommand(src_path, dest_path)
1458
yield commands.CommitCommand('head', '2', author,
1459
committer, "commit 2", ":1", [], files_two)
1462
def test_copy_file_in_root(self):
1463
handler, branch = self.get_handler()
1466
handler.process(self.file_command_iter(src_path, dest_path))
1467
revtree1, revtree2 = self.assertChanges(branch, 2,
1468
expected_added=[(dest_path,)])
1469
self.assertContent(branch, revtree1, src_path, "aaa")
1470
self.assertContent(branch, revtree2, src_path, "aaa")
1471
self.assertContent(branch, revtree2, dest_path, "aaa")
1472
self.assertRevisionRoot(revtree1, src_path)
1473
self.assertRevisionRoot(revtree2, dest_path)
1475
def test_copy_file_in_subdir(self):
1476
handler, branch = self.get_handler()
1479
handler.process(self.file_command_iter(src_path, dest_path))
1480
revtree1, revtree2 = self.assertChanges(branch, 2,
1481
expected_added=[(dest_path,)])
1482
self.assertContent(branch, revtree1, src_path, "aaa")
1483
self.assertContent(branch, revtree2, src_path, "aaa")
1484
self.assertContent(branch, revtree2, dest_path, "aaa")
1486
def test_copy_file_to_new_dir(self):
1487
handler, branch = self.get_handler()
1490
handler.process(self.file_command_iter(src_path, dest_path))
1491
revtree1, revtree2 = self.assertChanges(branch, 2,
1492
expected_added=[('b',), (dest_path,)])
1493
self.assertContent(branch, revtree1, src_path, "aaa")
1494
self.assertContent(branch, revtree2, src_path, "aaa")
1495
self.assertContent(branch, revtree2, dest_path, "aaa")
1497
def test_copy_symlink_in_root(self):
1498
handler, branch = self.get_handler()
1501
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1502
revtree1, revtree2 = self.assertChanges(branch, 2,
1503
expected_added=[(dest_path,)])
1504
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1505
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa")
1506
self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
1507
self.assertRevisionRoot(revtree1, src_path)
1508
self.assertRevisionRoot(revtree2, dest_path)
1510
def test_copy_symlink_in_subdir(self):
1511
handler, branch = self.get_handler()
1514
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1515
revtree1, revtree2 = self.assertChanges(branch, 2,
1516
expected_added=[(dest_path,)])
1517
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1518
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa")
1519
self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
1521
def test_copy_symlink_to_new_dir(self):
1522
handler, branch = self.get_handler()
1525
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1526
revtree1, revtree2 = self.assertChanges(branch, 2,
1527
expected_added=[('b',), (dest_path,)])
1528
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1529
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa")
1530
self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
1533
class TestImportToPackCopyNew(TestCaseForGenericProcessor):
1534
"""Test copy of a newly added file."""
1536
def file_command_iter(self, src_path, dest_path, kind='file'):
1537
# Revno 1: create a file or symlink and copy it
1539
author = ['', 'bugs@a.com', time.time(), time.timezone]
1540
committer = ['', 'elmer@a.com', time.time(), time.timezone]
1542
yield commands.FileModifyCommand(src_path, kind, False,
1544
yield commands.FileCopyCommand(src_path, dest_path)
1545
yield commands.CommitCommand('head', '1', author,
1546
committer, "commit 1", None, [], files_one)
1549
def test_copy_new_file_in_root(self):
1550
handler, branch = self.get_handler()
1553
handler.process(self.file_command_iter(src_path, dest_path))
1554
revtree0, revtree1 = self.assertChanges(branch, 1,
1555
expected_added=[(src_path,), (dest_path,)])
1556
self.assertContent(branch, revtree1, src_path, "aaa")
1557
self.assertContent(branch, revtree1, dest_path, "aaa")
1558
self.assertRevisionRoot(revtree1, src_path)
1559
self.assertRevisionRoot(revtree1, dest_path)
1561
def test_copy_new_file_in_subdir(self):
1562
handler, branch = self.get_handler()
1565
handler.process(self.file_command_iter(src_path, dest_path))
1566
revtree0, revtree1 = self.assertChanges(branch, 1,
1567
expected_added=[('a',), (src_path,), (dest_path,)])
1568
self.assertContent(branch, revtree1, src_path, "aaa")
1569
self.assertContent(branch, revtree1, dest_path, "aaa")
1571
def test_copy_new_file_to_new_dir(self):
1572
handler, branch = self.get_handler()
1575
handler.process(self.file_command_iter(src_path, dest_path))
1576
revtree0, revtree1 = self.assertChanges(branch, 1,
1577
expected_added=[('a',), (src_path,), ('b',), (dest_path,)])
1578
self.assertContent(branch, revtree1, src_path, "aaa")
1579
self.assertContent(branch, revtree1, dest_path, "aaa")
1581
def test_copy_new_symlink_in_root(self):
1582
handler, branch = self.get_handler()
1585
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1586
revtree0, revtree1 = self.assertChanges(branch, 1,
1587
expected_added=[(src_path,), (dest_path,)])
1588
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1589
self.assertSymlinkTarget(branch, revtree1, dest_path, "aaa")
1590
self.assertRevisionRoot(revtree1, src_path)
1591
self.assertRevisionRoot(revtree1, dest_path)
1593
def test_copy_new_symlink_in_subdir(self):
1594
handler, branch = self.get_handler()
1597
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1598
revtree0, revtree1 = self.assertChanges(branch, 1,
1599
expected_added=[('a',), (src_path,), (dest_path,)])
1600
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1601
self.assertSymlinkTarget(branch, revtree1, dest_path, "aaa")
1603
def test_copy_new_symlink_to_new_dir(self):
1604
handler, branch = self.get_handler()
1607
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1608
revtree0, revtree1 = self.assertChanges(branch, 1,
1609
expected_added=[('a',), (src_path,), ('b',), (dest_path,)])
1610
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1611
self.assertSymlinkTarget(branch, revtree1, dest_path, "aaa")
1614
class TestImportToPackCopyToDeleted(TestCaseForGenericProcessor):
1616
def file_command_iter(self, src_path, dest_path, kind='file'):
1617
# Revno 1: create two files or symlinks
1618
# Revno 2: delete one and copy the other one to its path
1620
author = ['', 'bugs@a.com', time.time(), time.timezone]
1621
committer = ['', 'elmer@a.com', time.time(), time.timezone]
1623
yield commands.FileModifyCommand(src_path, kind, False,
1625
yield commands.FileModifyCommand(dest_path, kind, False,
1627
yield commands.CommitCommand('head', '1', author,
1628
committer, "commit 1", None, [], files_one)
1630
yield commands.FileDeleteCommand(dest_path)
1631
yield commands.FileCopyCommand(src_path, dest_path)
1632
yield commands.CommitCommand('head', '2', author,
1633
committer, "commit 2", ":1", [], files_two)
1636
def test_copy_to_deleted_file_in_root(self):
1637
handler, branch = self.get_handler()
1640
handler.process(self.file_command_iter(src_path, dest_path))
1641
revtree0, revtree1 = self.assertChanges(branch, 1,
1642
expected_added=[(src_path,), (dest_path,)])
1643
revtree1, revtree2 = self.assertChanges(branch, 2,
1644
expected_removed=[(dest_path,)],
1645
expected_added=[(dest_path,)])
1646
self.assertContent(branch, revtree1, src_path, "aaa")
1647
self.assertContent(branch, revtree1, dest_path, "bbb")
1648
self.assertContent(branch, revtree2, src_path, "aaa")
1649
self.assertContent(branch, revtree2, dest_path, "aaa")
1650
self.assertRevisionRoot(revtree1, src_path)
1651
self.assertRevisionRoot(revtree1, dest_path)
1653
def test_copy_to_deleted_symlink_in_root(self):
1654
handler, branch = self.get_handler()
1657
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1658
revtree0, revtree1 = self.assertChanges(branch, 1,
1659
expected_added=[(src_path,), (dest_path,)])
1660
revtree1, revtree2 = self.assertChanges(branch, 2,
1661
expected_removed=[(dest_path,)],
1662
expected_added=[(dest_path,)])
1663
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1664
self.assertSymlinkTarget(branch, revtree1, dest_path, "bbb")
1665
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa")
1666
self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
1667
self.assertRevisionRoot(revtree1, src_path)
1668
self.assertRevisionRoot(revtree1, dest_path)
1670
def test_copy_to_deleted_file_in_subdir(self):
1671
handler, branch = self.get_handler()
1674
handler.process(self.file_command_iter(src_path, dest_path))
1675
revtree0, revtree1 = self.assertChanges(branch, 1,
1676
expected_added=[('d',), (src_path,), (dest_path,)])
1677
revtree1, revtree2 = self.assertChanges(branch, 2,
1678
expected_removed=[(dest_path,)],
1679
expected_added=[(dest_path,)])
1680
self.assertContent(branch, revtree1, src_path, "aaa")
1681
self.assertContent(branch, revtree1, dest_path, "bbb")
1682
self.assertContent(branch, revtree2, src_path, "aaa")
1683
self.assertContent(branch, revtree2, dest_path, "aaa")
1685
def test_copy_to_deleted_symlink_in_subdir(self):
1686
handler, branch = self.get_handler()
1689
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1690
revtree0, revtree1 = self.assertChanges(branch, 1,
1691
expected_added=[('d',), (src_path,), (dest_path,)])
1692
revtree1, revtree2 = self.assertChanges(branch, 2,
1693
expected_removed=[(dest_path,)],
1694
expected_added=[(dest_path,)])
1695
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1696
self.assertSymlinkTarget(branch, revtree1, dest_path, "bbb")
1697
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa")
1698
self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
1701
class TestImportToPackCopyModified(TestCaseForGenericProcessor):
1702
"""Test copy of file/symlink already modified in this commit."""
1704
def file_command_iter(self, src_path, dest_path, kind='file'):
1705
# Revno 1: create a file or symlink
1706
# Revno 2: modify and copy it
1708
author = ['', 'bugs@a.com', time.time(), time.timezone]
1709
committer = ['', 'elmer@a.com', time.time(), time.timezone]
1711
yield commands.FileModifyCommand(src_path, kind, False,
1713
yield commands.CommitCommand('head', '1', author,
1714
committer, "commit 1", None, [], files_one)
1716
yield commands.FileModifyCommand(src_path, kind, False,
1718
yield commands.FileCopyCommand(src_path, dest_path)
1719
yield commands.CommitCommand('head', '2', author,
1720
committer, "commit 2", ":1", [], files_two)
1723
def test_copy_of_modified_file_in_root(self):
1724
handler, branch = self.get_handler()
1727
handler.process(self.file_command_iter(src_path, dest_path))
1728
revtree1, revtree2 = self.assertChanges(branch, 2,
1729
expected_modified=[(src_path,)],
1730
expected_added=[(dest_path,)])
1731
self.assertContent(branch, revtree1, src_path, "aaa")
1732
self.assertContent(branch, revtree2, src_path, "bbb")
1733
self.assertContent(branch, revtree2, dest_path, "bbb")
1734
self.assertRevisionRoot(revtree1, src_path)
1735
self.assertRevisionRoot(revtree2, dest_path)
1737
def test_copy_of_modified_file_in_subdir(self):
1738
handler, branch = self.get_handler()
1741
handler.process(self.file_command_iter(src_path, dest_path))
1742
revtree1, revtree2 = self.assertChanges(branch, 2,
1743
expected_modified=[(src_path,)],
1744
expected_added=[(dest_path,)])
1745
self.assertContent(branch, revtree1, src_path, "aaa")
1746
self.assertContent(branch, revtree2, src_path, "bbb")
1747
self.assertContent(branch, revtree2, dest_path, "bbb")
1749
def test_copy_of_modified_file_to_new_dir(self):
1750
handler, branch = self.get_handler()
1753
handler.process(self.file_command_iter(src_path, dest_path))
1754
revtree1, revtree2 = self.assertChanges(branch, 2,
1755
expected_modified=[(src_path,)],
1756
expected_added=[('d2',), (dest_path,)])
1757
self.assertContent(branch, revtree1, src_path, "aaa")
1758
self.assertContent(branch, revtree2, src_path, "bbb")
1759
self.assertContent(branch, revtree2, dest_path, "bbb")
1761
def test_copy_of_modified_symlink_in_root(self):
1762
handler, branch = self.get_handler()
1765
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1766
revtree1, revtree2 = self.assertChanges(branch, 2,
1767
expected_modified=[(src_path,)],
1768
expected_added=[(dest_path,)])
1769
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1770
self.assertSymlinkTarget(branch, revtree2, src_path, "bbb")
1771
self.assertSymlinkTarget(branch, revtree2, dest_path, "bbb")
1772
self.assertRevisionRoot(revtree1, src_path)
1773
self.assertRevisionRoot(revtree2, dest_path)
1775
def test_copy_of_modified_symlink_in_subdir(self):
1776
handler, branch = self.get_handler()
1779
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1780
revtree1, revtree2 = self.assertChanges(branch, 2,
1781
expected_modified=[(src_path,)],
1782
expected_added=[(dest_path,)])
1783
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1784
self.assertSymlinkTarget(branch, revtree2, src_path, "bbb")
1785
self.assertSymlinkTarget(branch, revtree2, dest_path, "bbb")
1787
def test_copy_of_modified_symlink_to_new_dir(self):
1788
handler, branch = self.get_handler()
1791
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1792
revtree1, revtree2 = self.assertChanges(branch, 2,
1793
expected_modified=[(src_path,)],
1794
expected_added=[('d2',), (dest_path,)])
1795
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1796
self.assertSymlinkTarget(branch, revtree2, src_path, "bbb")
1797
self.assertSymlinkTarget(branch, revtree2, dest_path, "bbb")
1800
class TestImportToPackFileKinds(TestCaseForGenericProcessor):
1802
def get_command_iter(self, path, kind, content):
1804
committer = ['', 'elmer@a.com', time.time(), time.timezone]
1806
yield commands.FileModifyCommand(path, kind, False,
1808
yield commands.CommitCommand('head', '1', None,
1809
committer, "commit 1", None, [], files_one)
1812
def test_import_plainfile(self):
1813
handler, branch = self.get_handler()
1814
handler.process(self.get_command_iter('foo', 'file', 'aaa'))
1816
def test_import_symlink(self):
1817
handler, branch = self.get_handler()
1818
handler.process(self.get_command_iter('foo', 'symlink', 'bar'))
1821
### TODO: Parameterise tests rather than below hack
1823
class TestImportToRichRootModify(TestImportToPackModify):
1824
branch_format = "1.9-rich-root"
1826
class TestImportToRichRootModifyTwice(TestImportToPackModifyTwice):
1827
branch_format = "1.9-rich-root"
1829
class TestImportToRichRootModifyTricky(TestImportToPackModifyTricky):
1830
branch_format = "1.9-rich-root"
1832
class TestImportToRichRootDelete(TestImportToPackDelete):
1833
branch_format = "1.9-rich-root"
1835
class TestImportToRichRootDeleteNew(TestImportToPackDeleteNew):
1836
branch_format = "1.9-rich-root"
1838
class TestImportToRichRootDeleteMultiLevel(TestImportToPackDeleteMultiLevel):
1839
branch_format = "1.9-rich-root"
1841
class TestImportToRichRootDeleteThenAdd(TestImportToPackDeleteThenAdd):
1842
branch_format = "1.9-rich-root"
1844
class TestImportToRichRootDeleteDirectory(TestImportToPackDeleteDirectory):
1845
branch_format = "1.9-rich-root"
1847
class TestImportToRichRootDeleteDirectoryThenAddFile(TestImportToPackDeleteDirectoryThenAddFile):
1848
branch_format = "1.9-rich-root"
1850
class TestImportToRichRootRename(TestImportToPackRename):
1851
branch_format = "1.9-rich-root"
1853
class TestImportToRichRootRenameNew(TestImportToPackRenameNew):
1854
branch_format = "1.9-rich-root"
1856
class TestImportToRichRootRenameToDeleted(TestImportToPackRenameToDeleted):
1857
branch_format = "1.9-rich-root"
1859
class TestImportToRichRootRenameModified(TestImportToPackRenameModified):
1860
branch_format = "1.9-rich-root"
1862
class TestImportToRichRootRenameThenModify(TestImportToPackRenameThenModify):
1863
branch_format = "1.9-rich-root"
1865
class TestImportToRichRootDeleteRenameThenModify(TestImportToPackDeleteRenameThenModify):
1866
branch_format = "1.9-rich-root"
1868
class TestImportToRichRootRenameTricky(TestImportToPackRenameTricky):
1869
branch_format = "1.9-rich-root"
1871
class TestImportToRichRootCopy(TestImportToPackCopy):
1872
branch_format = "1.9-rich-root"
1874
class TestImportToRichRootCopyNew(TestImportToPackCopyNew):
1875
branch_format = "1.9-rich-root"
1877
class TestImportToRichRootCopyToDeleted(TestImportToPackCopyToDeleted):
1878
branch_format = "1.9-rich-root"
1880
class TestImportToRichRootCopyModified(TestImportToPackCopyModified):
1881
branch_format = "1.9-rich-root"
1883
class TestImportToRichRootFileKinds(TestImportToPackFileKinds):
1884
branch_format = "1.9-rich-root"
1887
from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
1889
class TestImportToChkModify(TestImportToPackModify):
1890
branch_format = "2a"
1892
class TestImportToChkModifyTwice(TestImportToPackModifyTwice):
1893
branch_format = "2a"
1895
class TestImportToChkModifyTricky(TestImportToPackModifyTricky):
1896
branch_format = "2a"
1898
class TestImportToChkDelete(TestImportToPackDelete):
1899
branch_format = "2a"
1901
class TestImportToChkDeleteNew(TestImportToPackDeleteNew):
1902
branch_format = "2a"
1904
class TestImportToChkDeleteMultiLevel(TestImportToPackDeleteMultiLevel):
1905
branch_format = "2a"
1907
class TestImportToChkDeleteThenAdd(TestImportToPackDeleteThenAdd):
1908
branch_format = "2a"
1910
class TestImportToChkDeleteDirectory(TestImportToPackDeleteDirectory):
1911
branch_format = "2a"
1913
class TestImportToChkDeleteDirectoryThenAddFile(TestImportToPackDeleteDirectoryThenAddFile):
1914
branch_format = "2a"
1916
class TestImportToChkRename(TestImportToPackRename):
1917
branch_format = "2a"
1919
class TestImportToChkRenameNew(TestImportToPackRenameNew):
1920
branch_format = "2a"
1922
class TestImportToChkRenameToDeleted(TestImportToPackRenameToDeleted):
1923
branch_format = "2a"
1925
class TestImportToChkRenameModified(TestImportToPackRenameModified):
1926
branch_format = "2a"
1928
class TestImportToChkRenameThenModify(TestImportToPackRenameThenModify):
1929
branch_format = "2a"
1931
class TestImportToChkDeleteRenameThenModify(TestImportToPackDeleteRenameThenModify):
1932
branch_format = "2a"
1934
class TestImportToChkRenameTricky(TestImportToPackRenameTricky):
1935
branch_format = "2a"
1937
class TestImportToChkCopy(TestImportToPackCopy):
1938
branch_format = "2a"
1940
class TestImportToChkCopyNew(TestImportToPackCopyNew):
1941
branch_format = "2a"
1943
class TestImportToChkCopyToDeleted(TestImportToPackCopyToDeleted):
1944
branch_format = "2a"
1946
class TestImportToChkCopyModified(TestImportToPackCopyModified):
1947
branch_format = "2a"
1949
class TestImportToChkFileKinds(TestImportToPackFileKinds):
1950
branch_format = "2a"