679
738
(False, False))],
680
739
self.do_iter_changes(tree1, tree2))
741
def test_specific_with_rename_under_new_dir_reports_new_dir(self):
742
tree1 = self.make_branch_and_tree('1')
743
tree2 = self.make_to_branch_and_tree('2')
744
tree1 = self.get_tree_no_parents_abc_content(tree1)
745
tree2 = self.get_tree_no_parents_abc_content_7(tree2)
746
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
747
# d(d-id) is new, e is b-id renamed.
748
root_id = tree1.path2id('')
749
self.assertEqualIterChanges(
750
[self.renamed(tree1, tree2, 'b-id', False),
751
self.added(tree2, 'd-id')],
752
self.do_iter_changes(tree1, tree2, specific_files=['d/e']))
754
def test_specific_with_rename_under_dir_under_new_dir_reports_new_dir(self):
755
tree1 = self.make_branch_and_tree('1')
756
tree2 = self.make_to_branch_and_tree('2')
757
tree1 = self.get_tree_no_parents_abc_content(tree1)
758
tree2 = self.get_tree_no_parents_abc_content_7(tree2)
759
tree2.rename_one('a', 'd/e/a')
760
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
761
# d is new, d/e is b-id renamed, d/e/a is a-id renamed
762
root_id = tree1.path2id('')
763
self.assertEqualIterChanges(
764
[self.renamed(tree1, tree2, 'b-id', False),
765
self.added(tree2, 'd-id'),
766
self.renamed(tree1, tree2, 'a-id', False)],
767
self.do_iter_changes(tree1, tree2, specific_files=['d/e/a']))
769
def test_specific_old_parent_same_path_new_parent(self):
770
# when a parent is new at its path, if the path was used in the source
771
# it must be emitted as a change.
772
tree1 = self.make_branch_and_tree('1')
773
tree1.add(['a'], ['a-id'], ['file'])
774
tree1.put_file_bytes_non_atomic('a-id', 'a file')
775
tree2 = self.make_to_branch_and_tree('2')
776
tree2.set_root_id(tree1.get_root_id())
777
tree2.mkdir('a', 'b-id')
778
tree2.add(['a/c'], ['c-id'], ['file'])
779
tree2.put_file_bytes_non_atomic('c-id', 'another file')
780
tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
781
# a-id is gone, b-id and c-id are added.
782
self.assertEqualIterChanges(
783
[self.deleted(tree1, 'a-id'),
784
self.added(tree2, 'b-id'),
785
self.added(tree2, 'c-id')],
786
self.do_iter_changes(tree1, tree2, specific_files=['a/c']))
788
def test_specific_old_parent_becomes_file(self):
789
# When an old parent included because of a path conflict becomes a
790
# non-directory, its children have to be all included in the delta.
791
tree1 = self.make_branch_and_tree('1')
792
tree1.mkdir('a', 'a-old-id')
793
tree1.mkdir('a/reparented', 'reparented-id')
794
tree1.mkdir('a/deleted', 'deleted-id')
795
tree2 = self.make_to_branch_and_tree('2')
796
tree2.set_root_id(tree1.get_root_id())
797
tree2.mkdir('a', 'a-new-id')
798
tree2.mkdir('a/reparented', 'reparented-id')
799
tree2.add(['b'], ['a-old-id'], ['file'])
800
tree2.put_file_bytes_non_atomic('a-old-id', '')
801
tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
802
# a-old-id is kind-changed, a-new-id is added, reparented-id is renamed,
804
self.assertEqualIterChanges(
805
[self.kind_changed(tree1, tree2, 'a-old-id'),
806
self.added(tree2, 'a-new-id'),
807
self.renamed(tree1, tree2, 'reparented-id', False),
808
self.deleted(tree1, 'deleted-id')],
809
self.do_iter_changes(tree1, tree2,
810
specific_files=['a/reparented']))
812
def test_specific_old_parent_is_deleted(self):
813
# When an old parent included because of a path conflict is removed,
814
# its children have to be all included in the delta.
815
tree1 = self.make_branch_and_tree('1')
816
tree1.mkdir('a', 'a-old-id')
817
tree1.mkdir('a/reparented', 'reparented-id')
818
tree1.mkdir('a/deleted', 'deleted-id')
819
tree2 = self.make_to_branch_and_tree('2')
820
tree2.set_root_id(tree1.get_root_id())
821
tree2.mkdir('a', 'a-new-id')
822
tree2.mkdir('a/reparented', 'reparented-id')
823
tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
824
# a-old-id is gone, a-new-id is added, reparented-id is renamed,
826
self.assertEqualIterChanges(
827
[self.deleted(tree1, 'a-old-id'),
828
self.added(tree2, 'a-new-id'),
829
self.renamed(tree1, tree2, 'reparented-id', False),
830
self.deleted(tree1, 'deleted-id')],
831
self.do_iter_changes(tree1, tree2,
832
specific_files=['a/reparented']))
834
def test_specific_old_parent_child_collides_with_unselected_new(self):
835
# When the child of an old parent because of a path conflict becomes a
836
# path conflict with some unselected item in the source, that item also
837
# needs to be included (because otherwise the output of applying the
838
# delta to the source would have two items at that path).
839
tree1 = self.make_branch_and_tree('1')
840
tree1.mkdir('a', 'a-old-id')
841
tree1.mkdir('a/reparented', 'reparented-id')
842
tree1.mkdir('collides', 'collides-id')
843
tree2 = self.make_to_branch_and_tree('2')
844
tree2.set_root_id(tree1.get_root_id())
845
tree2.mkdir('a', 'a-new-id')
846
tree2.mkdir('a/selected', 'selected-id')
847
tree2.mkdir('collides', 'reparented-id')
848
tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
849
# a-old-id is one, a-new-id is added, reparented-id is renamed,
850
# collides-id is gone, selected-id is new.
851
self.assertEqualIterChanges(
852
[self.deleted(tree1, 'a-old-id'),
853
self.added(tree2, 'a-new-id'),
854
self.renamed(tree1, tree2, 'reparented-id', False),
855
self.deleted(tree1, 'collides-id'),
856
self.added(tree2, 'selected-id')],
857
self.do_iter_changes(tree1, tree2,
858
specific_files=['a/selected']))
860
def test_specific_old_parent_child_dir_stops_being_dir(self):
861
# When the child of an old parent also stops being a directory, its
862
# children must also be included. This test checks that downward
863
# recursion is done appropriately by starting at a child of the root of
864
# a deleted subtree (a/reparented), and checking that a sibling
865
# directory (a/deleted) has its children included in the delta.
866
tree1 = self.make_branch_and_tree('1')
867
tree1.mkdir('a', 'a-old-id')
868
tree1.mkdir('a/reparented', 'reparented-id-1')
869
tree1.mkdir('a/deleted', 'deleted-id-1')
870
tree1.mkdir('a/deleted/reparented', 'reparented-id-2')
871
tree1.mkdir('a/deleted/deleted', 'deleted-id-2')
872
tree2 = self.make_to_branch_and_tree('2')
873
tree2.set_root_id(tree1.get_root_id())
874
tree2.mkdir('a', 'a-new-id')
875
tree2.mkdir('a/reparented', 'reparented-id-1')
876
tree2.mkdir('reparented', 'reparented-id-2')
877
tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
878
# a-old-id is gone, a-new-id is added, reparented-id-1, -2 are renamed,
879
# deleted-id-1 and -2 are gone.
880
self.assertEqualIterChanges(
881
[self.deleted(tree1, 'a-old-id'),
882
self.added(tree2, 'a-new-id'),
883
self.renamed(tree1, tree2, 'reparented-id-1', False),
884
self.renamed(tree1, tree2, 'reparented-id-2', False),
885
self.deleted(tree1, 'deleted-id-1'),
886
self.deleted(tree1, 'deleted-id-2')],
887
self.do_iter_changes(tree1, tree2,
888
specific_files=['a/reparented']))
682
890
def test_file_rename_and_meta_modification(self):
683
891
tree1 = self.make_branch_and_tree('1')
684
892
tree2 = self.make_to_branch_and_tree('2')