658
658
committer, "commit 2", ":1", [], files_two)
659
659
return command_list
661
def test_rename_in_root(self):
662
handler, branch = self.get_handler()
665
handler.process(self.get_command_iter(old_path, new_path))
666
revtree1, revtree2 = self.assertChanges(branch, 2,
667
expected_renamed=[(old_path, new_path)])
668
self.assertRevisionRoot(revtree1, old_path)
669
self.assertRevisionRoot(revtree2, new_path)
671
def test_rename_in_subdir(self):
672
handler, branch = self.get_handler()
675
handler.process(self.get_command_iter(old_path, new_path))
676
self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)])
678
def test_rename_to_new_dir(self):
679
handler, branch = self.get_handler()
682
handler.process(self.get_command_iter(old_path, new_path))
661
def test_rename_file_in_root(self):
662
handler, branch = self.get_handler()
665
handler.process(self.get_command_iter(old_path, new_path))
666
revtree1, revtree2 = self.assertChanges(branch, 2,
667
expected_renamed=[(old_path, new_path)])
668
self.assertRevisionRoot(revtree1, old_path)
669
self.assertRevisionRoot(revtree2, new_path)
671
def test_rename_symlink_in_root(self):
672
handler, branch = self.get_handler()
675
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
676
revtree1, revtree2 = self.assertChanges(branch, 2,
677
expected_renamed=[(old_path, new_path)])
678
self.assertRevisionRoot(revtree1, old_path)
679
self.assertRevisionRoot(revtree2, new_path)
681
def test_rename_file_in_subdir(self):
682
handler, branch = self.get_handler()
685
handler.process(self.get_command_iter(old_path, new_path))
686
self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)])
688
def test_rename_symlink_in_subdir(self):
689
handler, branch = self.get_handler()
692
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
693
self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)])
695
def test_rename_file_to_new_dir(self):
696
handler, branch = self.get_handler()
699
handler.process(self.get_command_iter(old_path, new_path))
700
self.assertChanges(branch, 2,
701
expected_renamed=[(old_path, new_path)],
702
expected_added=[('b',)],
703
expected_removed=[('a',)])
705
def test_rename_symlink_to_new_dir(self):
706
handler, branch = self.get_handler()
709
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
683
710
self.assertChanges(branch, 2,
684
711
expected_renamed=[(old_path, new_path)],
685
712
expected_added=[('b',)],
689
716
class TestImportToPackRenameNew(TestCaseForGenericProcessor):
690
717
"""Test rename of a newly added file."""
692
def get_command_iter(self, old_path, new_path):
719
def get_command_iter(self, old_path, new_path, kind='file'):
693
720
# Revno 1: create a file and rename it
694
721
def command_list():
695
722
author = ['', 'bugs@a.com', time.time(), time.timezone]
696
723
committer = ['', 'elmer@a.com', time.time(), time.timezone]
698
yield commands.FileModifyCommand(old_path, 'file', False,
725
yield commands.FileModifyCommand(old_path, kind, False,
700
727
yield commands.FileRenameCommand(old_path, new_path)
701
728
yield commands.CommitCommand('head', '1', author,
702
729
committer, "commit 1", None, [], files_one)
703
730
return command_list
705
def test_rename_new_in_root(self):
706
handler, branch = self.get_handler()
709
handler.process(self.get_command_iter(old_path, new_path))
710
revtree0, revtree1 = self.assertChanges(branch, 1,
711
expected_added=[(new_path,)])
712
self.assertRevisionRoot(revtree1, new_path)
714
def test_rename_new_in_subdir(self):
715
handler, branch = self.get_handler()
718
handler.process(self.get_command_iter(old_path, new_path))
732
def test_rename_new_file_in_root(self):
733
handler, branch = self.get_handler()
736
handler.process(self.get_command_iter(old_path, new_path))
737
revtree0, revtree1 = self.assertChanges(branch, 1,
738
expected_added=[(new_path,)])
739
self.assertRevisionRoot(revtree1, new_path)
741
def test_rename_new_symlink_in_root(self):
742
handler, branch = self.get_handler()
745
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
746
revtree0, revtree1 = self.assertChanges(branch, 1,
747
expected_added=[(new_path,)])
748
self.assertRevisionRoot(revtree1, new_path)
750
def test_rename_new_file_in_subdir(self):
751
handler, branch = self.get_handler()
754
handler.process(self.get_command_iter(old_path, new_path))
755
revtree0, revtree1 = self.assertChanges(branch, 1,
756
expected_added=[('a',), (new_path,)])
758
def test_rename_new_symlink_in_subdir(self):
759
handler, branch = self.get_handler()
762
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
719
763
revtree0, revtree1 = self.assertChanges(branch, 1,
720
764
expected_added=[('a',), (new_path,)])
743
787
committer, "commit 2", ":1", [], files_two)
744
788
return command_list
746
def test_rename_to_deleted_in_root(self):
747
handler, branch = self.get_handler()
750
handler.process(self.get_command_iter(old_path, new_path))
751
revtree0, revtree1 = self.assertChanges(branch, 1,
752
expected_added=[(old_path,), (new_path,)])
753
revtree1, revtree2 = self.assertChanges(branch, 2,
754
expected_removed=[(new_path,)],
755
expected_renamed=[(old_path, new_path)])
756
self.assertContent(branch, revtree1, old_path, "aaa")
757
self.assertContent(branch, revtree1, new_path, "bbb")
758
self.assertContent(branch, revtree2, new_path, "aaa")
759
self.assertRevisionRoot(revtree1, old_path)
760
self.assertRevisionRoot(revtree1, new_path)
762
def test_rename_to_deleted_in_subdir(self):
763
handler, branch = self.get_handler()
766
handler.process(self.get_command_iter(old_path, new_path))
767
revtree0, revtree1 = self.assertChanges(branch, 1,
768
expected_added=[('d',), (old_path,), (new_path,)])
769
revtree1, revtree2 = self.assertChanges(branch, 2,
770
expected_removed=[(new_path,)],
771
expected_renamed=[(old_path, new_path)])
772
self.assertContent(branch, revtree1, old_path, "aaa")
773
self.assertContent(branch, revtree1, new_path, "bbb")
774
self.assertContent(branch, revtree2, new_path, "aaa")
776
def test_rename_to_deleted_new_dir(self):
777
handler, branch = self.get_handler()
780
handler.process(self.get_command_iter(old_path, new_path))
781
revtree0, revtree1 = self.assertChanges(branch, 1,
782
expected_added=[('d1',), (old_path,), ('d2',), (new_path,)])
783
revtree1, revtree2 = self.assertChanges(branch, 2,
784
expected_removed=[('d1',), (new_path,)],
785
expected_renamed=[(old_path, new_path)])
786
self.assertContent(branch, revtree1, old_path, "aaa")
787
self.assertContent(branch, revtree1, new_path, "bbb")
788
self.assertContent(branch, revtree2, new_path, "aaa")
790
def test_rename_to_deleted_file_in_root(self):
791
handler, branch = self.get_handler()
794
handler.process(self.get_command_iter(old_path, new_path))
795
revtree0, revtree1 = self.assertChanges(branch, 1,
796
expected_added=[(old_path,), (new_path,)])
797
revtree1, revtree2 = self.assertChanges(branch, 2,
798
expected_removed=[(new_path,)],
799
expected_renamed=[(old_path, new_path)])
800
self.assertContent(branch, revtree1, old_path, "aaa")
801
self.assertContent(branch, revtree1, new_path, "bbb")
802
self.assertContent(branch, revtree2, new_path, "aaa")
803
self.assertRevisionRoot(revtree1, old_path)
804
self.assertRevisionRoot(revtree1, new_path)
806
def test_rename_to_deleted_symlink_in_root(self):
807
handler, branch = self.get_handler()
810
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
811
revtree0, revtree1 = self.assertChanges(branch, 1,
812
expected_added=[(old_path,), (new_path,)])
813
revtree1, revtree2 = self.assertChanges(branch, 2,
814
expected_removed=[(new_path,)],
815
expected_renamed=[(old_path, new_path)])
816
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
817
self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
818
self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
819
self.assertRevisionRoot(revtree1, old_path)
820
self.assertRevisionRoot(revtree1, new_path)
822
def test_rename_to_deleted_file_in_subdir(self):
823
handler, branch = self.get_handler()
826
handler.process(self.get_command_iter(old_path, new_path))
827
revtree0, revtree1 = self.assertChanges(branch, 1,
828
expected_added=[('d',), (old_path,), (new_path,)])
829
revtree1, revtree2 = self.assertChanges(branch, 2,
830
expected_removed=[(new_path,)],
831
expected_renamed=[(old_path, new_path)])
832
self.assertContent(branch, revtree1, old_path, "aaa")
833
self.assertContent(branch, revtree1, new_path, "bbb")
834
self.assertContent(branch, revtree2, new_path, "aaa")
836
def test_rename_to_deleted_symlink_in_subdir(self):
837
handler, branch = self.get_handler()
840
handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
841
revtree0, revtree1 = self.assertChanges(branch, 1,
842
expected_added=[('d',), (old_path,), (new_path,)])
843
revtree1, revtree2 = self.assertChanges(branch, 2,
844
expected_removed=[(new_path,)],
845
expected_renamed=[(old_path, new_path)])
846
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
847
self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
848
self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
850
def test_rename_to_deleted_file_in_new_dir(self):
851
handler, branch = self.get_handler()
854
handler.process(self.get_command_iter(old_path, new_path))
855
revtree0, revtree1 = self.assertChanges(branch, 1,
856
expected_added=[('d1',), (old_path,), ('d2',), (new_path,)])
857
revtree1, revtree2 = self.assertChanges(branch, 2,
858
expected_removed=[('d1',), (new_path,)],
859
expected_renamed=[(old_path, new_path)])
860
self.assertContent(branch, revtree1, old_path, "aaa")
861
self.assertContent(branch, revtree1, new_path, "bbb")
862
self.assertContent(branch, revtree2, new_path, "aaa")
864
def test_rename_to_deleted_symlink_in_new_dir(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=[('d1',), (old_path,), ('d2',), (new_path,)])
871
revtree1, revtree2 = self.assertChanges(branch, 2,
872
expected_removed=[('d1',), (new_path,)],
873
expected_renamed=[(old_path, new_path)])
874
self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
875
self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
876
self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
791
879
class TestImportToPackRenameTricky(TestCaseForGenericProcessor):