729
731
self.assertIs(os.path.isdir('b/foo'), True)
730
732
self.assertEqual(file('b/foo/bar', 'rb').read(), "contents")
731
733
self.assertEqual(os.readlink('b/foo/baz'), 'a/foo/bar')
735
def test_file_conflict_handling(self):
736
"""Ensure that when building trees, conflict handling is done"""
737
source = self.make_branch_and_tree('source')
738
target = self.make_branch_and_tree('target')
739
self.build_tree(['source/file', 'target/file'])
741
source.commit('added file')
742
build_tree(source.basis_tree(), target)
743
self.assertEqual(1, len(target.conflicts()))
744
target2 = self.make_branch_and_tree('target2')
745
target_file = file('target2/file', 'wb')
747
target_file.write('contents of source/file\n')
750
build_tree(source.basis_tree(), target2)
751
self.assertEqual(len(target2.conflicts()), 0)
753
def test_symlink_conflict_handling(self):
754
"""Ensure that when building trees, conflict handling is done"""
755
if not has_symlinks():
756
raise TestSkipped('Test requires symlink support')
757
source = self.make_branch_and_tree('source')
758
os.symlink('foo', 'source/symlink')
759
source.add('symlink')
760
source.commit('added file')
761
target = self.make_branch_and_tree('target')
762
os.symlink('bar', 'target/symlink')
763
build_tree(source.basis_tree(), target)
764
self.assertEqual(1, len(target.conflicts()))
766
target = self.make_branch_and_tree('target2')
767
os.symlink('foo', 'target2/symlink')
768
build_tree(source.basis_tree(), target)
769
self.assertEqual(0, len(target.conflicts()))
771
def test_directory_conflict_handling(self):
772
"""Ensure that when building trees, conflict handling is done"""
773
source = self.make_branch_and_tree('source')
774
target = self.make_branch_and_tree('target')
775
self.build_tree(['source/dir1/', 'source/dir1/file', 'target/dir1/'])
776
source.add(['dir1', 'dir1/file'])
777
source.commit('added file')
778
build_tree(source.basis_tree(), target)
779
self.assertEqual(0, len(target.conflicts()))
780
self.failUnlessExists('target/dir1/file')
782
# Ensure contents are merged
783
target = self.make_branch_and_tree('target2')
784
self.build_tree(['target2/dir1/', 'target2/dir1/file2'])
785
build_tree(source.basis_tree(), target)
786
self.assertEqual(0, len(target.conflicts()))
787
self.failUnlessExists('target2/dir1/file2')
788
self.failUnlessExists('target2/dir1/file')
790
# Ensure new contents are suppressed for existing branches
791
target = self.make_branch('target3')
792
target = self.make_branch_and_tree('target3/dir1')
793
self.build_tree(['target3/dir1/file2'])
794
build_tree(source.basis_tree(), target)
795
self.assertEqual(0, len(target.conflicts()))
796
self.failIfExists('target3/dir1/file1')
797
self.failUnlessExists('target3/dir1/file2')
799
def test_mixed_conflict_handling(self):
800
"""Ensure that when building trees, conflict handling is done"""
801
source = self.make_branch_and_tree('source')
802
target = self.make_branch_and_tree('target')
803
self.build_tree(['source/name', 'target/name/'])
805
source.commit('added file')
806
build_tree(source.basis_tree(), target)
807
self.assertEqual(1, len(target.conflicts()))
733
810
class MockTransform(object):
735
812
def has_named_child(self, by_parent, parent_id, name):