131
131
kind_changed = changes.kind_changed
132
132
if expected_renamed is not None:
133
133
self.assertEquals(len(renamed), len(expected_renamed),
134
"%s is renamed, expected %s" % (renamed, expected_renamed))
134
"%s is renamed, expected %s" % (renamed, expected_renamed))
135
135
renamed_files = [(item[0], item[1]) for item in renamed]
136
136
for expected_renamed_entry in expected_renamed:
137
137
expected_renamed_entry = (
138
expected_renamed_entry[0].decode('utf-8'),
139
expected_renamed_entry[1].decode('utf-8'))
138
expected_renamed_entry[0].decode('utf-8'),
139
expected_renamed_entry[1].decode('utf-8'))
140
140
self.assertTrue(expected_renamed_entry in renamed_files,
141
"%s is not renamed, %s are" % (expected_renamed_entry,
141
"%s is not renamed, %s are" % (expected_renamed_entry,
143
143
if expected_added is not None:
144
144
self.assertEquals(len(added), len(expected_added),
145
"%s is added" % str(added))
145
"%s is added" % str(added))
146
146
added_files = [(item[0],) for item in added]
147
147
for expected_added_entry in expected_added:
148
expected_added_entry = (expected_added_entry[0].decode('utf-8'), )
148
expected_added_entry = (
149
expected_added_entry[0].decode('utf-8'), )
149
150
self.assertTrue(expected_added_entry in added_files,
150
"%s is not added, %s are" % (expected_added_entry,
151
"%s is not added, %s are" % (expected_added_entry,
152
153
if expected_removed is not None:
153
154
self.assertEquals(len(removed), len(expected_removed),
154
"%s is removed" % str(removed))
155
"%s is removed" % str(removed))
155
156
removed_files = [(item[0],) for item in removed]
156
157
for expected_removed_entry in expected_removed:
157
expected_removed_entry = (expected_removed_entry[0].decode('utf-8'), )
158
expected_removed_entry = (
159
expected_removed_entry[0].decode('utf-8'), )
158
160
self.assertTrue(expected_removed_entry in removed_files,
159
"%s is not removed, %s are" % (expected_removed_entry,
161
"%s is not removed, %s are" % (expected_removed_entry,
161
163
if expected_modified is not None:
162
164
self.assertEquals(len(modified), len(expected_modified),
163
"%s is modified" % str(modified))
165
"%s is modified" % str(modified))
164
166
modified_files = [(item[0],) for item in modified]
165
167
for expected_modified_entry in expected_modified:
166
expected_modified_entry = (expected_modified_entry[0].decode('utf-8'), )
168
expected_modified_entry = (
169
expected_modified_entry[0].decode('utf-8'), )
167
170
self.assertTrue(expected_modified_entry in modified_files,
168
"%s is not modified, %s are" % (
169
expected_modified_entry, modified_files))
171
"%s is not modified, %s are" % (
172
expected_modified_entry, modified_files))
170
173
if expected_kind_changed is not None:
171
174
self.assertEquals(len(kind_changed), len(expected_kind_changed),
172
"%s is kind-changed, expected %s" % (kind_changed,
173
expected_kind_changed))
175
"%s is kind-changed, expected %s" % (kind_changed,
176
expected_kind_changed))
174
177
kind_changed_files = [(item[0], item[2], item[3])
175
for item in kind_changed]
178
for item in kind_changed]
176
179
for expected_kind_changed_entry in expected_kind_changed:
177
expected_kind_changed_entry = (
178
expected_kind_changed_entry[0].decode('utf-8'), ) + expected_kind_changed_entry[1:]
179
self.assertTrue(expected_kind_changed_entry in
180
kind_changed_files, "%s is not kind-changed, %s are" % (
181
expected_kind_changed_entry, kind_changed_files))
180
expected_kind_changed_entry = (
181
expected_kind_changed_entry[0].decode('utf-8'), ) + expected_kind_changed_entry[1:]
182
self.assertTrue(expected_kind_changed_entry in
183
kind_changed_files, "%s is not kind-changed, %s are" % (
184
expected_kind_changed_entry, kind_changed_files))
183
186
def assertContent(self, branch, tree, path, content):
184
187
with branch.lock_read():
200
205
class TestImportToPackTag(TestCaseForGenericProcessor):
202
207
def file_command_iter(self, path, kind='file', content=b'aaa',
203
executable=False, to_kind=None, to_content=b'bbb', to_executable=None):
208
executable=False, to_kind=None, to_content=b'bbb', to_executable=None):
204
209
# Revno 1: create a file or symlink
205
210
# Revno 2: modify it
206
211
if to_kind is None:
208
213
if to_executable is None:
209
214
to_executable = executable
210
216
def command_list():
211
217
author = [b'', b'bugs@a.com', time.time(), time.timezone]
212
218
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
214
221
yield commands.FileModifyCommand(path,
215
kind_to_mode(kind, executable), None, content)
222
kind_to_mode(kind, executable), None, content)
216
223
yield commands.CommitCommand(b'head', b'1', author,
217
committer, b"commit 1", None, [], files_one)
224
committer, b"commit 1", None, [], files_one)
219
227
yield commands.FileModifyCommand(path,
220
kind_to_mode(to_kind, to_executable), None, to_content)
228
kind_to_mode(to_kind, to_executable), None, to_content)
222
230
# pass "head" for from_ to show that #401249 is worse than I knew
223
231
yield commands.CommitCommand(b'head', b'2', author,
224
committer, b"commit 2", b"head", [], files_two)
232
committer, b"commit 2", b"head", [], files_two)
226
234
yield commands.TagCommand(b'tag1', b':1', committer, b"tag 1")
260
269
to_executable = executable
261
270
mode = kind_to_mode(kind, executable)
262
271
to_mode = kind_to_mode(to_kind, to_executable)
263
273
def command_list():
264
274
author = [b'', b'bugs@a.com', time.time(), time.timezone]
265
275
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
267
278
yield commands.FileModifyCommand(path, mode, None, content)
268
279
yield commands.CommitCommand(b'head', b'1', author,
269
committer, b"commit 1", None, [], files_one)
280
committer, b"commit 1", None, [], files_one)
271
283
yield commands.FileModifyCommand(path, to_mode, None, to_content)
272
284
yield commands.CommitCommand(b'head', b'2', author,
273
committer, b"commit 2", b":1", [], files_two)
285
committer, b"commit 2", b":1", [], files_two)
274
286
return command_list
276
288
def test_modify_file_in_root(self):
377
389
def file_command_iter(self, path, kind='file', content=b'aaa',
378
executable=False, to_kind=None, to_content=b'bbb', to_executable=None):
390
executable=False, to_kind=None, to_content=b'bbb', to_executable=None):
380
392
# Revno 1: create a file twice
381
393
if to_kind is None:
383
395
if to_executable is None:
384
396
to_executable = executable
385
398
def command_list():
386
399
author = [b'', b'bugs@a.com', time.time(), time.timezone]
387
400
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
389
403
yield commands.FileModifyCommand(path, kind_to_mode(kind, executable),
391
405
yield commands.FileModifyCommand(path, kind_to_mode(to_kind, to_executable),
393
407
yield commands.CommitCommand(b'head', b'1', author,
394
committer, b"commit 1", None, [], files_one)
408
committer, b"commit 1", None, [], files_one)
395
409
return command_list
397
411
def test_modify_file_twice_in_root(self):
416
430
def command_list():
417
431
author = [b'', b'bugs@a.com', time.time(), time.timezone]
418
432
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
420
435
yield commands.FileModifyCommand(path1, kind_to_mode(kind, False),
422
437
yield commands.CommitCommand(b'head', b'1', author,
423
committer, b"commit 1", None, [], files_one)
438
committer, b"commit 1", None, [], files_one)
425
441
yield commands.FileModifyCommand(path2, kind_to_mode(kind, False),
427
443
yield commands.CommitCommand(b'head', b'2', author,
428
committer, b"commit 2", b":1", [], files_two)
444
committer, b"commit 2", b":1", [], files_two)
429
445
return command_list
431
447
def test_modify_file_becomes_directory(self):
448
464
handler.process(self.file_command_iter(path1, path2))
449
465
revtree0, revtree1 = self.assertChanges(branch, 1,
450
expected_added=[(b'a',), (b'a/b',), (path1,)])
466
expected_added=[(b'a',), (b'a/b',), (path1,)])
451
467
revtree1, revtree2 = self.assertChanges(branch, 2,
452
expected_removed=[(path1,),],
453
expected_kind_changed=[(path2, 'directory', 'file')])
468
expected_removed=[(path1,), ],
469
expected_kind_changed=[(path2, 'directory', 'file')])
454
470
self.assertContent(branch, revtree1, path1, b"aaa")
455
471
self.assertContent(branch, revtree2, path2, b"bbb")
474
490
handler.process(self.file_command_iter(path1, path2, 'symlink'))
475
491
revtree0, revtree1 = self.assertChanges(branch, 1,
476
expected_added=[(b'a',), (b'a/b',), (path1,)])
492
expected_added=[(b'a',), (b'a/b',), (path1,)])
477
493
revtree1, revtree2 = self.assertChanges(branch, 2,
478
expected_removed=[(path1,),],
479
expected_kind_changed=[(path2, 'directory', 'symlink')])
494
expected_removed=[(path1,), ],
495
expected_kind_changed=[(path2, 'directory', 'symlink')])
480
496
self.assertSymlinkTarget(branch, revtree1, path1, "aaa")
481
497
self.assertSymlinkTarget(branch, revtree2, path2, "bbb")
490
506
def command_list():
491
507
author = [b'', b'bugs@a.com', time.time(), time.timezone]
492
508
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
494
511
yield commands.FileModifyCommand(path, kind_to_mode(kind, False),
496
513
yield commands.CommitCommand(b'head', b'1', author,
497
committer, b"commit 1", None, [], files_one)
514
committer, b"commit 1", None, [], files_one)
499
517
yield commands.FileDeleteCommand(path)
500
518
yield commands.CommitCommand(b'head', b'2', author,
501
committer, b"commit 2", b":1", [], files_two)
519
committer, b"commit 2", b":1", [], files_two)
502
520
return command_list
504
522
def test_delete_file_in_root(self):
546
564
path = b'a/b/c/d'
547
565
handler.process(self.file_command_iter(path))
548
566
revtree0, revtree1 = self.assertChanges(branch, 1,
549
expected_added=[(b'a',), (b'a/b',), (b'a/b/c',), (path,)])
567
expected_added=[(b'a',), (b'a/b',), (b'a/b/c',), (path,)])
550
568
revtree1, revtree2 = self.assertChanges(branch, 2,
551
expected_removed=[(b'a',), (b'a/b',), (b'a/b/c',), (path,)])
569
expected_removed=[(b'a',), (b'a/b',), (b'a/b/c',), (path,)])
552
570
self.assertContent(branch, revtree1, path, b"aaa")
609
628
def command_list():
610
629
author = [b'', b'bugs@a.com', time.time(), time.timezone]
611
630
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
613
633
for i, path in enumerate(paths):
614
634
yield commands.FileModifyCommand(path, kind_to_mode('file', False),
616
636
yield commands.CommitCommand(b'head', b'1', author,
617
committer, b"commit 1", None, [], files_one)
637
committer, b"commit 1", None, [], files_one)
619
640
for path in paths_to_delete:
620
641
yield commands.FileDeleteCommand(path)
621
642
yield commands.CommitCommand(b'head', b'2', author,
622
committer, b"commit 2", b":1", [], files_two)
643
committer, b"commit 2", b":1", [], files_two)
623
644
return command_list
625
646
def test_delete_files_in_multiple_levels(self):
628
649
paths_to_delete = [b'a/b/c', b'a/b/d/e']
629
650
handler.process(self.file_command_iter(paths, paths_to_delete))
630
651
revtree0, revtree1 = self.assertChanges(branch, 1,
632
(b'a',), (b'a/b',), (b'a/b/c',),
633
(b'a/b/d',), (b'a/b/d/e',),
655
(b'a/b/d',), (b'a/b/d/e',),
635
657
revtree1, revtree2 = self.assertChanges(branch, 2,
637
(b'a',), (b'a/b',), (b'a/b/c',),
638
(b'a/b/d',), (b'a/b/d/e',),
661
(b'a/b/d',), (b'a/b/d/e',),
641
664
def test_delete_file_single_level(self):
642
665
handler, branch = self.get_handler()
659
683
paths_to_delete = [b'a/b/c', b'a/b/d/e', b'a/f/g', b'a/b/d/i/j']
660
684
handler.process(self.file_command_iter(paths, paths_to_delete))
661
685
revtree0, revtree1 = self.assertChanges(branch, 1,
663
(b'a',), (b'a/b',), (b'a/b/c',),
664
(b'a/b/d',), (b'a/b/d/e',),
665
(b'a/f',), (b'a/f/g',),
667
(b'a/b/d/i',), (b'a/b/d/i/j',),
689
(b'a/b/d',), (b'a/b/d/e',),
690
(b'a/f',), (b'a/f/g',),
692
(b'a/b/d/i',), (b'a/b/d/i/j',),
669
694
revtree1, revtree2 = self.assertChanges(branch, 2,
671
(b'a/b',), (b'a/b/c',),
672
(b'a/b/d',), (b'a/b/d/e',),
673
(b'a/f',), (b'a/f/g',),
674
(b'a/b/d/i',), (b'a/b/d/i/j',),
696
(b'a/b',), (b'a/b/c',),
697
(b'a/b/d',), (b'a/b/d/e',),
698
(b'a/f',), (b'a/f/g',),
699
(b'a/b/d/i',), (b'a/b/d/i/j',),
677
703
class TestImportToPackDeleteThenAdd(TestCaseForGenericProcessor):
678
704
"""Test delete followed by an add. Merges can cause this."""
680
706
def file_command_iter(self, path, kind='file', content=b'aaa',
681
executable=False, to_kind=None, to_content=b'bbb', to_executable=None):
707
executable=False, to_kind=None, to_content=b'bbb', to_executable=None):
683
709
# Revno 1: create a file or symlink
684
710
# Revno 2: delete it and add it
687
713
if to_executable is None:
688
714
to_executable = executable
689
716
def command_list():
690
717
author = [b'', b'bugs@a.com', time.time(), time.timezone]
691
718
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
693
721
yield commands.FileModifyCommand(path, kind_to_mode(kind, executable),
695
723
yield commands.CommitCommand(b'head', b'1', author,
696
committer, b"commit 1", None, [], files_one)
724
committer, b"commit 1", None, [], files_one)
698
727
yield commands.FileDeleteCommand(path)
699
728
yield commands.FileModifyCommand(path, kind_to_mode(to_kind, to_executable),
701
730
yield commands.CommitCommand(b'head', b'2', author,
702
committer, b"commit 2", b":1", [], files_two)
731
committer, b"commit 2", b":1", [], files_two)
703
732
return command_list
705
734
def test_delete_then_add_file_in_root(self):
762
791
def command_list():
763
792
author = [b'', b'bugs@a.com', time.time(), time.timezone]
764
793
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
766
796
for i, path in enumerate(paths):
767
797
yield commands.FileModifyCommand(path, kind_to_mode('file', False),
769
799
yield commands.CommitCommand(b'head', b'1', author,
770
committer, b"commit 1", None, [], files_one)
800
committer, b"commit 1", None, [], files_one)
772
803
yield commands.FileDeleteCommand(dir)
773
804
yield commands.CommitCommand(b'head', b'2', author,
774
committer, b"commit 2", b":1", [], files_two)
805
committer, b"commit 2", b":1", [], files_two)
775
806
return command_list
777
808
def test_delete_dir(self):
804
836
def command_list():
805
837
author = [b'', b'bugs@a.com', time.time(), time.timezone]
806
838
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
808
841
for i, path in enumerate(paths):
809
842
yield commands.FileModifyCommand(path, kind_to_mode(kind, False),
811
844
yield commands.CommitCommand(b'head', b'1', author,
812
committer, b"commit 1", None, [], files_one)
845
committer, b"commit 1", None, [], files_one)
814
848
yield commands.FileDeleteCommand(dir)
815
849
yield commands.FileModifyCommand(new_path, kind_to_mode(kind, False),
817
851
yield commands.CommitCommand(b'head', b'2', author,
818
committer, b"commit 2", b":1", [], files_two)
852
committer, b"commit 2", b":1", [], files_two)
819
853
return command_list
821
855
def test_delete_dir_then_add_file(self):
825
859
new_path = b'a/b/z'
826
860
handler.process(self.file_command_iter(paths, dir, new_path))
827
861
revtree0, revtree1 = self.assertChanges(branch, 1,
828
expected_added=[(b'a',), (b'a/b',), (b'a/b/c',), (b'a/b/d',),])
862
expected_added=[(b'a',), (b'a/b',), (b'a/b/c',), (b'a/b/d',), ])
829
863
revtree1, revtree2 = self.assertChanges(branch, 2,
830
expected_removed=[(b'a/b',), (b'a/b/c',), (b'a/b/d',)],
831
expected_added=[(b'a/b',), (b'a/b/z',)])
865
(b'a/b',), (b'a/b/c',), (b'a/b/d',)],
866
expected_added=[(b'a/b',), (b'a/b/z',)])
832
867
self.assertContent(branch, revtree2, new_path, b"bbb")
834
869
def test_delete_dir_then_add_symlink(self):
836
871
paths = [b'a/b/c', b'a/b/d']
838
873
new_path = b'a/b/z'
839
handler.process(self.file_command_iter(paths, dir, new_path, 'symlink'))
874
handler.process(self.file_command_iter(
875
paths, dir, new_path, 'symlink'))
840
876
revtree0, revtree1 = self.assertChanges(branch, 1,
841
expected_added=[(b'a',), (b'a/b',), (b'a/b/c',), (b'a/b/d',),])
877
expected_added=[(b'a',), (b'a/b',), (b'a/b/c',), (b'a/b/d',), ])
842
878
revtree1, revtree2 = self.assertChanges(branch, 2,
843
expected_removed=[(b'a/b',), (b'a/b/c',), (b'a/b/d',)],
844
expected_added=[(b'a/b',), (b'a/b/z',)])
880
(b'a/b',), (b'a/b/c',), (b'a/b/d',)],
881
expected_added=[(b'a/b',), (b'a/b/z',)])
845
882
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
854
891
def command_list():
855
892
author = [b'', b'bugs@a.com', time.time(), time.timezone]
856
893
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
858
896
yield commands.FileModifyCommand(old_path, kind_to_mode(kind, False),
860
898
yield commands.CommitCommand(b'head', b'1', author,
861
committer, b"commit 1", None, [], files_one)
899
committer, b"commit 1", None, [], files_one)
863
902
yield commands.FileRenameCommand(old_path, new_path)
864
903
yield commands.CommitCommand(b'head', b'2', author,
865
committer, b"commit 2", b":1", [], files_two)
904
committer, b"commit 2", b":1", [], files_two)
866
905
return command_list
868
907
def test_rename_file_in_root(self):
982
1022
def command_list():
983
1023
author = [b'', b'bugs@a.com', time.time(), time.timezone]
984
1024
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
985
1026
def files_one():
986
1027
yield commands.FileModifyCommand(old_path, kind_to_mode(kind, False),
988
1029
yield commands.FileModifyCommand(new_path, kind_to_mode(kind, False),
990
1031
yield commands.CommitCommand(b'head', b'1', author,
991
committer, b"commit 1", None, [], files_one)
1032
committer, b"commit 1", None, [], files_one)
992
1034
def files_two():
993
1035
yield commands.FileDeleteCommand(new_path)
994
1036
yield commands.FileRenameCommand(old_path, new_path)
995
1037
yield commands.CommitCommand(b'head', b'2', author,
996
committer, b"commit 2", b":1", [], files_two)
1038
committer, b"commit 2", b":1", [], files_two)
997
1039
return command_list
999
1041
def test_rename_to_deleted_file_in_root(self):
1002
1044
new_path = b'b'
1003
1045
handler.process(self.get_command_iter(old_path, new_path))
1004
1046
revtree0, revtree1 = self.assertChanges(branch, 1,
1005
expected_added=[(old_path,), (new_path,)])
1047
expected_added=[(old_path,), (new_path,)])
1006
1048
revtree1, revtree2 = self.assertChanges(branch, 2,
1007
expected_removed=[(new_path,)],
1008
expected_renamed=[(old_path, new_path)])
1049
expected_removed=[(new_path,)],
1050
expected_renamed=[(old_path, new_path)])
1009
1051
self.assertContent(branch, revtree1, old_path, b"aaa")
1010
1052
self.assertContent(branch, revtree1, new_path, b"bbb")
1011
1053
self.assertContent(branch, revtree2, new_path, b"aaa")
1018
1060
new_path = b'b'
1019
1061
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1020
1062
revtree0, revtree1 = self.assertChanges(branch, 1,
1021
expected_added=[(old_path,), (new_path,)])
1063
expected_added=[(old_path,), (new_path,)])
1022
1064
revtree1, revtree2 = self.assertChanges(branch, 2,
1023
expected_removed=[(new_path,)],
1024
expected_renamed=[(old_path, new_path)])
1065
expected_removed=[(new_path,)],
1066
expected_renamed=[(old_path, new_path)])
1025
1067
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1026
1068
self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
1027
1069
self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
1034
1076
new_path = b'd/b'
1035
1077
handler.process(self.get_command_iter(old_path, new_path))
1036
1078
revtree0, revtree1 = self.assertChanges(branch, 1,
1037
expected_added=[(b'd',), (old_path,), (new_path,)])
1079
expected_added=[(b'd',), (old_path,), (new_path,)])
1038
1080
revtree1, revtree2 = self.assertChanges(branch, 2,
1039
expected_removed=[(new_path,)],
1040
expected_renamed=[(old_path, new_path)])
1081
expected_removed=[(new_path,)],
1082
expected_renamed=[(old_path, new_path)])
1041
1083
self.assertContent(branch, revtree1, old_path, b"aaa")
1042
1084
self.assertContent(branch, revtree1, new_path, b"bbb")
1043
1085
self.assertContent(branch, revtree2, new_path, b"aaa")
1048
1090
new_path = b'd/b'
1049
1091
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1050
1092
revtree0, revtree1 = self.assertChanges(branch, 1,
1051
expected_added=[(b'd',), (old_path,), (new_path,)])
1093
expected_added=[(b'd',), (old_path,), (new_path,)])
1052
1094
revtree1, revtree2 = self.assertChanges(branch, 2,
1053
expected_removed=[(new_path,)],
1054
expected_renamed=[(old_path, new_path)])
1095
expected_removed=[(new_path,)],
1096
expected_renamed=[(old_path, new_path)])
1055
1097
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1056
1098
self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
1057
1099
self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
1062
1104
new_path = b'd2/b'
1063
1105
handler.process(self.get_command_iter(old_path, new_path))
1064
1106
revtree0, revtree1 = self.assertChanges(branch, 1,
1065
expected_added=[(b'd1',), (old_path,), (b'd2',), (new_path,)])
1107
expected_added=[(b'd1',), (old_path,), (b'd2',), (new_path,)])
1066
1108
revtree1, revtree2 = self.assertChanges(branch, 2,
1067
expected_removed=[(b'd1',), (new_path,)],
1068
expected_renamed=[(old_path, new_path)])
1110
(b'd1',), (new_path,)],
1111
expected_renamed=[(old_path, new_path)])
1069
1112
self.assertContent(branch, revtree1, old_path, b"aaa")
1070
1113
self.assertContent(branch, revtree1, new_path, b"bbb")
1071
1114
self.assertContent(branch, revtree2, new_path, b"aaa")
1076
1119
new_path = b'd2/b'
1077
1120
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1078
1121
revtree0, revtree1 = self.assertChanges(branch, 1,
1079
expected_added=[(b'd1',), (old_path,), (b'd2',), (new_path,)])
1122
expected_added=[(b'd1',), (old_path,), (b'd2',), (new_path,)])
1080
1123
revtree1, revtree2 = self.assertChanges(branch, 2,
1081
expected_removed=[(b'd1',), (new_path,)],
1082
expected_renamed=[(old_path, new_path)])
1125
(b'd1',), (new_path,)],
1126
expected_renamed=[(old_path, new_path)])
1083
1127
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1084
1128
self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
1085
1129
self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
1095
1139
def command_list():
1096
1140
author = [b'', b'bugs@a.com', time.time(), time.timezone]
1097
1141
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
1098
1143
def files_one():
1099
1144
yield commands.FileModifyCommand(old_path, kind_to_mode(kind, False),
1101
1146
yield commands.CommitCommand(b'head', b'1', author,
1102
committer, b"commit 1", None, [], files_one)
1147
committer, b"commit 1", None, [], files_one)
1103
1149
def files_two():
1104
1150
yield commands.FileModifyCommand(old_path, kind_to_mode(kind, False),
1106
1152
yield commands.FileRenameCommand(old_path, new_path)
1107
1153
yield commands.CommitCommand(b'head', b'2', author,
1108
committer, b"commit 2", b":1", [], files_two)
1154
committer, b"commit 2", b":1", [], files_two)
1109
1155
return command_list
1111
1157
def test_rename_of_modified_file_in_root(self):
1174
1220
new_path = b'd2/b'
1175
1221
handler.process(self.get_command_iter(old_path, new_path))
1176
1222
revtree0, revtree1 = self.assertChanges(branch, 1,
1177
expected_added=[(b'd1',), (old_path,)])
1223
expected_added=[(b'd1',), (old_path,)])
1178
1224
# Note: the delta doesn't show the modification?
1179
1225
# The actual new content is validated in the assertions following.
1180
1226
revtree1, revtree2 = self.assertChanges(branch, 2,
1181
expected_renamed=[(old_path, new_path)],
1182
expected_added=[(b'd2',)],
1183
expected_removed=[(b'd1',)])
1228
(old_path, new_path)],
1229
expected_added=[(b'd2',)],
1230
expected_removed=[(b'd1',)])
1184
1231
self.assertContent(branch, revtree1, old_path, b"aaa")
1185
1232
self.assertContent(branch, revtree2, new_path, b"bbb")
1190
1237
new_path = b'd2/b'
1191
1238
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1192
1239
revtree0, revtree1 = self.assertChanges(branch, 1,
1193
expected_added=[(b'd1',), (old_path,)])
1240
expected_added=[(b'd1',), (old_path,)])
1194
1241
# Note: the delta doesn't show the modification?
1195
1242
# The actual new content is validated in the assertions following.
1196
1243
revtree1, revtree2 = self.assertChanges(branch, 2,
1197
expected_renamed=[(old_path, new_path)],
1198
expected_added=[(b'd2',)],
1199
expected_removed=[(b'd1',)])
1245
(old_path, new_path)],
1246
expected_added=[(b'd2',)],
1247
expected_removed=[(b'd1',)])
1200
1248
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1201
1249
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1211
1259
def command_list():
1212
1260
author = [b'', b'bugs@a.com', time.time(), time.timezone]
1213
1261
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
1214
1263
def files_one():
1215
1264
yield commands.FileModifyCommand(old_path, kind_to_mode(kind, False),
1217
1266
yield commands.CommitCommand(b'head', b'1', author,
1218
committer, b"commit 1", None, [], files_one)
1267
committer, b"commit 1", None, [], files_one)
1219
1269
def files_two():
1220
1270
yield commands.FileRenameCommand(old_path, new_path)
1221
1271
yield commands.FileModifyCommand(new_path, kind_to_mode(kind, False),
1223
1273
yield commands.CommitCommand(b'head', b'2', author,
1224
committer, b"commit 2", b":1", [], files_two)
1274
committer, b"commit 2", b":1", [], files_two)
1225
1275
return command_list
1227
1277
def test_rename_then_modify_file_in_root(self):
1260
1310
new_path = b'd2/b'
1261
1311
handler.process(self.get_command_iter(old_path, new_path))
1262
1312
revtree0, revtree1 = self.assertChanges(branch, 1,
1263
expected_added=[(b'd1',), (old_path,)])
1313
expected_added=[(b'd1',), (old_path,)])
1264
1314
# Note: the delta doesn't show the modification?
1265
1315
# The actual new content is validated in the assertions following.
1266
1316
revtree1, revtree2 = self.assertChanges(branch, 2,
1267
expected_renamed=[(old_path, new_path)],
1268
expected_added=[(b'd2',)],
1269
expected_removed=[(b'd1',)])
1318
(old_path, new_path)],
1319
expected_added=[(b'd2',)],
1320
expected_removed=[(b'd1',)])
1270
1321
self.assertContent(branch, revtree1, old_path, b"aaa")
1271
1322
self.assertContent(branch, revtree2, new_path, b"bbb")
1306
1357
new_path = b'd2/b'
1307
1358
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1308
1359
revtree0, revtree1 = self.assertChanges(branch, 1,
1309
expected_added=[(b'd1',), (old_path,)])
1360
expected_added=[(b'd1',), (old_path,)])
1310
1361
# Note: the delta doesn't show the modification?
1311
1362
# The actual new content is validated in the assertions following.
1312
1363
revtree1, revtree2 = self.assertChanges(branch, 2,
1313
expected_renamed=[(old_path, new_path)],
1314
expected_added=[(b'd2',)],
1315
expected_removed=[(b'd1',)])
1365
(old_path, new_path)],
1366
expected_added=[(b'd2',)],
1367
expected_removed=[(b'd1',)])
1316
1368
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1317
1369
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1327
1379
def command_list():
1328
1380
author = [b'', b'bugs@a.com', time.time(), time.timezone]
1329
1381
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
1330
1383
def files_one():
1331
1384
yield commands.FileModifyCommand(old_path, kind_to_mode(kind, False),
1333
1386
yield commands.FileModifyCommand(new_path, kind_to_mode(kind, False),
1335
1388
yield commands.CommitCommand(b'head', b'1', author,
1336
committer, b"commit 1", None, [], files_one)
1389
committer, b"commit 1", None, [], files_one)
1337
1391
def files_two():
1338
1392
yield commands.FileDeleteCommand(new_path)
1339
1393
yield commands.FileRenameCommand(old_path, new_path)
1340
1394
yield commands.FileModifyCommand(new_path, kind_to_mode(kind, False),
1342
1396
yield commands.CommitCommand(b'head', b'2', author,
1343
committer, b"commit 2", b":1", [], files_two)
1397
committer, b"commit 2", b":1", [], files_two)
1344
1398
return command_list
1346
1400
def test_delete_rename_then_modify_file_in_root(self):
1349
1403
new_path = b'b'
1350
1404
handler.process(self.get_command_iter(old_path, new_path))
1351
1405
revtree0, revtree1 = self.assertChanges(branch, 1,
1352
expected_added=[(old_path,), (new_path,)])
1406
expected_added=[(old_path,), (new_path,)])
1353
1407
# Note: the delta doesn't show the modification?
1354
1408
# The actual new content is validated in the assertions following.
1355
1409
revtree1, revtree2 = self.assertChanges(branch, 2,
1356
expected_removed=[(new_path,)],
1357
expected_renamed=[(old_path, new_path)])
1410
expected_removed=[(new_path,)],
1411
expected_renamed=[(old_path, new_path)])
1358
1412
self.assertContent(branch, revtree1, old_path, b"aaa")
1359
1413
self.assertContent(branch, revtree1, new_path, b"zzz")
1360
1414
self.assertContent(branch, revtree2, new_path, b"bbb")
1368
1422
new_path = b'd/b'
1369
1423
handler.process(self.get_command_iter(old_path, new_path))
1370
1424
revtree0, revtree1 = self.assertChanges(branch, 1,
1371
expected_added=[(b'd',), (old_path,), (new_path,)])
1425
expected_added=[(b'd',), (old_path,), (new_path,)])
1372
1426
# Note: the delta doesn't show the modification?
1373
1427
# The actual new content is validated in the assertions following.
1374
1428
revtree1, revtree2 = self.assertChanges(branch, 2,
1375
expected_removed=[(new_path,)],
1376
expected_renamed=[(old_path, new_path)])
1429
expected_removed=[(new_path,)],
1430
expected_renamed=[(old_path, new_path)])
1377
1431
self.assertContent(branch, revtree1, old_path, b"aaa")
1378
1432
self.assertContent(branch, revtree1, new_path, b"zzz")
1379
1433
self.assertContent(branch, revtree2, new_path, b"bbb")
1384
1438
new_path = b'd2/b'
1385
1439
handler.process(self.get_command_iter(old_path, new_path))
1386
1440
revtree0, revtree1 = self.assertChanges(branch, 1,
1387
expected_added=[(b'd1',), (b'd2',), (old_path,), (new_path,)])
1441
expected_added=[(b'd1',), (b'd2',), (old_path,), (new_path,)])
1388
1442
# Note: the delta doesn't show the modification?
1389
1443
# The actual new content is validated in the assertions following.
1390
1444
revtree1, revtree2 = self.assertChanges(branch, 2,
1391
expected_removed=[(b'd1',), (new_path,)],
1392
expected_renamed=[(old_path, new_path)])
1446
(b'd1',), (new_path,)],
1447
expected_renamed=[(old_path, new_path)])
1393
1448
self.assertContent(branch, revtree1, old_path, b"aaa")
1394
1449
self.assertContent(branch, revtree1, new_path, b"zzz")
1395
1450
self.assertContent(branch, revtree2, new_path, b"bbb")
1400
1455
new_path = b'b'
1401
1456
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1402
1457
revtree0, revtree1 = self.assertChanges(branch, 1,
1403
expected_added=[(old_path,), (new_path,)])
1458
expected_added=[(old_path,), (new_path,)])
1404
1459
# Note: the delta doesn't show the modification?
1405
1460
# The actual new content is validated in the assertions following.
1406
1461
revtree1, revtree2 = self.assertChanges(branch, 2,
1407
expected_removed=[(new_path,)],
1408
expected_renamed=[(old_path, new_path)])
1462
expected_removed=[(new_path,)],
1463
expected_renamed=[(old_path, new_path)])
1409
1464
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1410
1465
self.assertSymlinkTarget(branch, revtree1, new_path, "zzz")
1411
1466
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1419
1474
new_path = b'd/b'
1420
1475
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1421
1476
revtree0, revtree1 = self.assertChanges(branch, 1,
1422
expected_added=[(b'd',), (old_path,), (new_path,)])
1477
expected_added=[(b'd',), (old_path,), (new_path,)])
1423
1478
# Note: the delta doesn't show the modification?
1424
1479
# The actual new content is validated in the assertions following.
1425
1480
revtree1, revtree2 = self.assertChanges(branch, 2,
1426
expected_removed=[(new_path,)],
1427
expected_renamed=[(old_path, new_path)])
1481
expected_removed=[(new_path,)],
1482
expected_renamed=[(old_path, new_path)])
1428
1483
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1429
1484
self.assertSymlinkTarget(branch, revtree1, new_path, "zzz")
1430
1485
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1435
1490
new_path = b'd2/b'
1436
1491
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
1437
1492
revtree0, revtree1 = self.assertChanges(branch, 1,
1438
expected_added=[(b'd1',), (b'd2',), (old_path,), (new_path,)])
1493
expected_added=[(b'd1',), (b'd2',), (old_path,), (new_path,)])
1439
1494
# Note: the delta doesn't show the modification?
1440
1495
# The actual new content is validated in the assertions following.
1441
1496
revtree1, revtree2 = self.assertChanges(branch, 2,
1442
expected_removed=[(b'd1',), (new_path,)],
1443
expected_renamed=[(old_path, new_path)])
1498
(b'd1',), (new_path,)],
1499
expected_renamed=[(old_path, new_path)])
1444
1500
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
1445
1501
self.assertSymlinkTarget(branch, revtree1, new_path, "zzz")
1446
1502
self.assertSymlinkTarget(branch, revtree2, new_path, "bbb")
1458
1514
def command_list():
1459
1515
author = [b'', b'bugs@a.com', time.time(), time.timezone]
1460
1516
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
1461
1518
def files_one():
1462
1519
yield commands.FileModifyCommand(path1, kind_to_mode(kind, False),
1464
1521
yield commands.FileModifyCommand(old_path2, kind_to_mode(kind, False),
1466
1523
yield commands.CommitCommand(b'head', b'1', author,
1467
committer, b"commit 1", None, [], files_one)
1524
committer, b"commit 1", None, [], files_one)
1468
1526
def files_two():
1469
1527
yield commands.FileRenameCommand(old_path2, new_path2)
1470
1528
yield commands.CommitCommand(b'head', b'2', author,
1471
committer, b"commit 2", b":1", [], files_two)
1529
committer, b"commit 2", b":1", [], files_two)
1472
1530
return command_list
1474
1532
def test_rename_file_becomes_directory(self):
1475
1533
handler, branch = self.get_handler()
1476
1534
old_path2 = b'foo'
1478
1536
new_path2 = b'a/b/c'
1479
1537
handler.process(self.file_command_iter(path1, old_path2, new_path2))
1480
1538
revtree0, revtree1 = self.assertChanges(branch, 1,
1481
expected_added=[(b'a',), (path1,), (old_path2,)])
1539
expected_added=[(b'a',), (path1,), (old_path2,)])
1482
1540
revtree1, revtree2 = self.assertChanges(branch, 2,
1483
expected_renamed=[(old_path2, new_path2)],
1484
expected_kind_changed=[(path1, 'file', 'directory')])
1542
(old_path2, new_path2)],
1543
expected_kind_changed=[(path1, 'file', 'directory')])
1485
1544
self.assertContent(branch, revtree1, path1, b"aaa")
1486
1545
self.assertContent(branch, revtree2, new_path2, b"bbb")
1488
1547
def test_rename_directory_becomes_file(self):
1489
1548
handler, branch = self.get_handler()
1490
1549
old_path2 = b'foo'
1492
1551
new_path2 = b'a/b'
1493
1552
handler.process(self.file_command_iter(path1, old_path2, new_path2))
1494
1553
revtree0, revtree1 = self.assertChanges(branch, 1,
1495
expected_added=[(b'a',), (b'a/b',), (path1,), (old_path2,)])
1554
expected_added=[(b'a',), (b'a/b',), (path1,), (old_path2,)])
1496
1555
revtree1, revtree2 = self.assertChanges(branch, 2,
1497
expected_renamed=[(old_path2, new_path2)],
1498
expected_removed=[(path1,), (new_path2,)])
1557
(old_path2, new_path2)],
1558
expected_removed=[(path1,), (new_path2,)])
1499
1559
self.assertContent(branch, revtree1, path1, b"aaa")
1500
1560
self.assertContent(branch, revtree2, new_path2, b"bbb")
1502
1562
def test_rename_symlink_becomes_directory(self):
1503
1563
handler, branch = self.get_handler()
1504
1564
old_path2 = b'foo'
1506
1566
new_path2 = b'a/b/c'
1507
1567
handler.process(self.file_command_iter(path1, old_path2, new_path2,
1509
1569
revtree0, revtree1 = self.assertChanges(branch, 1,
1510
expected_added=[(b'a',), (path1,), (old_path2,)])
1570
expected_added=[(b'a',), (path1,), (old_path2,)])
1511
1571
revtree1, revtree2 = self.assertChanges(branch, 2,
1512
expected_renamed=[(old_path2, new_path2)],
1513
expected_kind_changed=[(path1, 'symlink', 'directory')])
1573
(old_path2, new_path2)],
1574
expected_kind_changed=[(path1, 'symlink', 'directory')])
1514
1575
self.assertSymlinkTarget(branch, revtree1, path1, "aaa")
1515
1576
self.assertSymlinkTarget(branch, revtree2, new_path2, "bbb")
1517
1578
def test_rename_directory_becomes_symlink(self):
1518
1579
handler, branch = self.get_handler()
1519
1580
old_path2 = b'foo'
1521
1582
new_path2 = b'a/b'
1522
1583
handler.process(self.file_command_iter(path1, old_path2, new_path2,
1524
1585
revtree0, revtree1 = self.assertChanges(branch, 1,
1525
expected_added=[(b'a',), (b'a/b',), (path1,), (old_path2,)])
1586
expected_added=[(b'a',), (b'a/b',), (path1,), (old_path2,)])
1526
1587
revtree1, revtree2 = self.assertChanges(branch, 2,
1527
expected_renamed=[(old_path2, new_path2)],
1528
expected_removed=[(path1,), (new_path2,)])
1589
(old_path2, new_path2)],
1590
expected_removed=[(path1,), (new_path2,)])
1529
1591
self.assertSymlinkTarget(branch, revtree1, path1, "aaa")
1530
1592
self.assertSymlinkTarget(branch, revtree2, new_path2, "bbb")
1539
1601
def command_list():
1540
1602
author = [b'', b'bugs@a.com', time.time(), time.timezone]
1541
1603
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
1542
1605
def files_one():
1543
1606
yield commands.FileModifyCommand(src_path, kind_to_mode(kind, False),
1545
1608
yield commands.CommitCommand(b'head', b'1', author,
1546
committer, b"commit 1", None, [], files_one)
1609
committer, b"commit 1", None, [], files_one)
1547
1611
def files_two():
1548
1612
yield commands.FileCopyCommand(src_path, dest_path)
1549
1613
yield commands.CommitCommand(b'head', b'2', author,
1550
committer, b"commit 2", b":1", [], files_two)
1614
committer, b"commit 2", b":1", [], files_two)
1551
1615
return command_list
1553
1617
def test_copy_file_in_root(self):
1712
1777
def command_list():
1713
1778
author = [b'', b'bugs@a.com', time.time(), time.timezone]
1714
1779
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
1715
1781
def files_one():
1716
1782
yield commands.FileModifyCommand(src_path, kind_to_mode(kind, False),
1718
1784
yield commands.FileModifyCommand(dest_path, kind_to_mode(kind, False),
1720
1786
yield commands.CommitCommand(b'head', b'1', author,
1721
committer, b"commit 1", None, [], files_one)
1787
committer, b"commit 1", None, [], files_one)
1722
1789
def files_two():
1723
1790
yield commands.FileDeleteCommand(dest_path)
1724
1791
yield commands.FileCopyCommand(src_path, dest_path)
1725
1792
yield commands.CommitCommand(b'head', b'2', author,
1726
committer, b"commit 2", b":1", [], files_two)
1793
committer, b"commit 2", b":1", [], files_two)
1727
1794
return command_list
1729
1796
def test_copy_to_deleted_file_in_root(self):
1766
1835
dest_path = b'd/b'
1767
1836
handler.process(self.file_command_iter(src_path, dest_path))
1768
1837
revtree0, revtree1 = self.assertChanges(branch, 1,
1769
expected_added=[(b'd',), (src_path,), (dest_path,)])
1838
expected_added=[(b'd',), (src_path,), (dest_path,)])
1770
1839
revtree1, revtree2 = self.assertChanges(branch, 2,
1771
expected_removed=[(dest_path,)],
1772
expected_added=[(dest_path,)])
1842
expected_added=[(dest_path,)])
1773
1843
self.assertContent(branch, revtree1, src_path, b"aaa")
1774
1844
self.assertContent(branch, revtree1, dest_path, b"bbb")
1775
1845
self.assertContent(branch, revtree2, src_path, b"aaa")
1781
1851
dest_path = b'd/b'
1782
1852
handler.process(self.file_command_iter(src_path, dest_path, 'symlink'))
1783
1853
revtree0, revtree1 = self.assertChanges(branch, 1,
1784
expected_added=[(b'd',), (src_path,), (dest_path,)])
1854
expected_added=[(b'd',), (src_path,), (dest_path,)])
1785
1855
revtree1, revtree2 = self.assertChanges(branch, 2,
1786
expected_removed=[(dest_path,)],
1787
expected_added=[(dest_path,)])
1858
expected_added=[(dest_path,)])
1788
1859
self.assertSymlinkTarget(branch, revtree1, src_path, "aaa")
1789
1860
self.assertSymlinkTarget(branch, revtree1, dest_path, "bbb")
1790
1861
self.assertSymlinkTarget(branch, revtree2, src_path, "aaa")
1801
1872
def command_list():
1802
1873
author = [b'', b'bugs@a.com', time.time(), time.timezone]
1803
1874
committer = [b'', b'elmer@a.com', time.time(), time.timezone]
1804
1876
def files_one():
1805
1877
yield commands.FileModifyCommand(src_path, kind_to_mode(kind, False),
1807
1879
yield commands.CommitCommand(b'head', b'1', author,
1808
committer, b"commit 1", None, [], files_one)
1880
committer, b"commit 1", None, [], files_one)
1809
1882
def files_two():
1810
1883
yield commands.FileModifyCommand(src_path, kind_to_mode(kind, False),
1812
1885
yield commands.FileCopyCommand(src_path, dest_path)
1813
1886
yield commands.CommitCommand(b'head', b'2', author,
1814
committer, b"commit 2", b":1", [], files_two)
1887
committer, b"commit 2", b":1", [], files_two)
1815
1888
return command_list
1817
1890
def test_copy_of_modified_file_in_root(self):
1928
2008
committer_b = [b'', b'b@elmer.com', time.time(), time.timezone]
1929
2009
committer_c = [b'', b'c@elmer.com', time.time(), time.timezone]
1930
2010
committer_d = [b'', b'd@elmer.com', time.time(), time.timezone]
1931
2012
def files_one():
1932
2013
yield commands.FileModifyCommand(b'foo', kind_to_mode('file', False),
1933
None, b"content A\n")
2014
None, b"content A\n")
1934
2015
yield commands.CommitCommand(b'head', b'1', None,
1935
committer_a, b"commit 1", None, [], files_one)
2016
committer_a, b"commit 1", None, [], files_one)
1936
2018
def files_two():
1937
2019
yield commands.FileModifyCommand(b'foo', kind_to_mode('file', False),
1938
None, b"content B\n")
2020
None, b"content B\n")
1939
2021
yield commands.CommitCommand(b'head', b'2', None,
1940
committer_b, b"commit 2", b":1", [], files_two)
2022
committer_b, b"commit 2", b":1", [], files_two)
1941
2024
def files_three():
1942
2025
yield commands.FileModifyCommand(b'foo', kind_to_mode('file', False),
1943
None, b"content A\n")
2026
None, b"content A\n")
1944
2027
yield commands.CommitCommand(b'head', b'3', None,
1945
committer_c, b"commit 3", b":2", [], files_three)
2028
committer_c, b"commit 3", b":2", [], files_three)
1946
2029
yield commands.CommitCommand(b'head', b'4', None,
1947
committer_d, b"commit 4", b":1", [b':3'], lambda: [])
2030
committer_d, b"commit 4", b":1", [b':3'], lambda: [])
1948
2031
return command_list
1950
2033
def test_modify_revert(self):