1696
1696
def test_text_merge(self):
1697
1697
root_id = generate_ids.gen_root_id()
1698
1698
base = TransformGroup("base", root_id)
1699
base.tt.new_file('a', base.root, 'a\nb\nc\nd\be\n', 'a')
1700
base.tt.new_file('b', base.root, 'b1', 'b')
1701
base.tt.new_file('c', base.root, 'c', 'c')
1702
base.tt.new_file('d', base.root, 'd', 'd')
1703
base.tt.new_file('e', base.root, 'e', 'e')
1704
base.tt.new_file('f', base.root, 'f', 'f')
1705
base.tt.new_directory('g', base.root, 'g')
1706
base.tt.new_directory('h', base.root, 'h')
1699
base.tt.new_file('a', base.root, b'a\nb\nc\nd\be\n', b'a')
1700
base.tt.new_file('b', base.root, b'b1', b'b')
1701
base.tt.new_file('c', base.root, b'c', b'c')
1702
base.tt.new_file('d', base.root, b'd', b'd')
1703
base.tt.new_file('e', base.root, b'e', b'e')
1704
base.tt.new_file('f', base.root, b'f', b'f')
1705
base.tt.new_directory('g', base.root, b'g')
1706
base.tt.new_directory('h', base.root, b'h')
1707
1707
base.tt.apply()
1708
1708
other = TransformGroup("other", root_id)
1709
other.tt.new_file('a', other.root, 'y\nb\nc\nd\be\n', 'a')
1710
other.tt.new_file('b', other.root, 'b2', 'b')
1711
other.tt.new_file('c', other.root, 'c2', 'c')
1712
other.tt.new_file('d', other.root, 'd', 'd')
1713
other.tt.new_file('e', other.root, 'e2', 'e')
1714
other.tt.new_file('f', other.root, 'f', 'f')
1715
other.tt.new_file('g', other.root, 'g', 'g')
1716
other.tt.new_file('h', other.root, 'h\ni\nj\nk\n', 'h')
1717
other.tt.new_file('i', other.root, 'h\ni\nj\nk\n', 'i')
1709
other.tt.new_file('a', other.root, b'y\nb\nc\nd\be\n', b'a')
1710
other.tt.new_file('b', other.root, b'b2', b'b')
1711
other.tt.new_file('c', other.root, b'c2', b'c')
1712
other.tt.new_file('d', other.root, b'd', b'd')
1713
other.tt.new_file('e', other.root, b'e2', b'e')
1714
other.tt.new_file('f', other.root, b'f', b'f')
1715
other.tt.new_file('g', other.root, b'g', b'g')
1716
other.tt.new_file('h', other.root, b'h\ni\nj\nk\n', b'h')
1717
other.tt.new_file('i', other.root, b'h\ni\nj\nk\n', b'i')
1718
1718
other.tt.apply()
1719
1719
this = TransformGroup("this", root_id)
1720
this.tt.new_file('a', this.root, 'a\nb\nc\nd\bz\n', 'a')
1721
this.tt.new_file('b', this.root, 'b', 'b')
1722
this.tt.new_file('c', this.root, 'c', 'c')
1723
this.tt.new_file('d', this.root, 'd2', 'd')
1724
this.tt.new_file('e', this.root, 'e2', 'e')
1725
this.tt.new_file('f', this.root, 'f', 'f')
1726
this.tt.new_file('g', this.root, 'g', 'g')
1727
this.tt.new_file('h', this.root, '1\n2\n3\n4\n', 'h')
1728
this.tt.new_file('i', this.root, '1\n2\n3\n4\n', 'i')
1720
this.tt.new_file('a', this.root, b'a\nb\nc\nd\bz\n', b'a')
1721
this.tt.new_file('b', this.root, b'b', b'b')
1722
this.tt.new_file('c', this.root, b'c', b'c')
1723
this.tt.new_file('d', this.root, b'd2', b'd')
1724
this.tt.new_file('e', this.root, b'e2', b'e')
1725
this.tt.new_file('f', this.root, b'f', b'f')
1726
this.tt.new_file('g', this.root, b'g', b'g')
1727
this.tt.new_file('h', this.root, b'1\n2\n3\n4\n', b'h')
1728
this.tt.new_file('i', this.root, b'1\n2\n3\n4\n', b'i')
1729
1729
this.tt.apply()
1730
1730
Merge3Merger(this.wt, this.wt, base.wt, other.wt)
1732
1732
# textual merge
1733
self.assertEqual(this.wt.get_file(this.wt.id2path(b'a')).read(), 'y\nb\nc\nd\bz\n')
1733
self.assertEqual(this.wt.get_file(this.wt.id2path(b'a')).read(), b'y\nb\nc\nd\bz\n')
1734
1734
# three-way text conflict
1735
1735
self.assertEqual(this.wt.get_file(this.wt.id2path(b'b')).read(),
1736
1736
conflict_text('b', 'b2'))
1738
self.assertEqual(this.wt.get_file(this.wt.id2path(b'c')).read(), 'c2')
1738
self.assertEqual(this.wt.get_file(this.wt.id2path(b'c')).read(), b'c2')
1740
self.assertEqual(this.wt.get_file(this.wt.id2path(b'd')).read(), 'd2')
1740
self.assertEqual(this.wt.get_file(this.wt.id2path(b'd')).read(), b'd2')
1741
1741
# Ambigious clean merge
1742
self.assertEqual(this.wt.get_file(this.wt.id2path(b'e')).read(), 'e2')
1742
self.assertEqual(this.wt.get_file(this.wt.id2path(b'e')).read(), b'e2')
1744
self.assertEqual(this.wt.get_file(this.wt.id2path(b'f')).read(), 'f')
1744
self.assertEqual(this.wt.get_file(this.wt.id2path(b'f')).read(), b'f')
1745
1745
# Correct correct results when THIS == OTHER
1746
self.assertEqual(this.wt.get_file(this.wt.id2path(b'g')).read(), 'g')
1746
self.assertEqual(this.wt.get_file(this.wt.id2path(b'g')).read(), b'g')
1747
1747
# Text conflict when THIS & OTHER are text and BASE is dir
1748
1748
self.assertEqual(this.wt.get_file(this.wt.id2path(b'h')).read(),
1749
1749
conflict_text('1\n2\n3\n4\n', 'h\ni\nj\nk\n'))
1750
1750
self.assertEqual(this.wt.get_file('h.THIS').read(),
1752
1752
self.assertEqual(this.wt.get_file('h.OTHER').read(),
1754
1754
self.assertEqual(file_kind(this.wt.abspath('h.BASE')), 'directory')
1755
1755
self.assertEqual(this.wt.get_file(this.wt.id2path(b'i')).read(),
1756
conflict_text('1\n2\n3\n4\n', 'h\ni\nj\nk\n'))
1756
conflict_text(b'1\n2\n3\n4\n', b'h\ni\nj\nk\n'))
1757
1757
self.assertEqual(this.wt.get_file('i.THIS').read(),
1759
1759
self.assertEqual(this.wt.get_file('i.OTHER').read(),
1761
1761
self.assertEqual(os.path.exists(this.wt.abspath('i.BASE')), False)
1762
1762
modified = ['a', 'b', 'c', 'h', 'i']
1763
1763
merge_modified = this.wt.merge_modified()