1725
1725
self.assertEqual(0, conflicts)
1726
1726
self.assertTrue(wt.is_executable('foo-id'))
1728
def test_create_symlink(self):
1729
self.requireFeature(tests.SymlinkFeature)
1738
# F Add a symlink 'foo' => 'bar'
1739
# Have to use a real WT, because BranchBuilder and MemoryTree don't
1740
# have symlink support
1741
builder = self.get_builder()
1742
builder.build_snapshot('A-id', None,
1743
[('add', (u'', 'a-root-id', 'directory', None))])
1744
builder.build_snapshot('C-id', ['A-id'], [])
1745
builder.build_snapshot('B-id', ['A-id'], [])
1746
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1747
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1748
# Have to use a real WT, because BranchBuilder doesn't support exec bit
1749
wt = self.get_wt_from_builder(builder)
1750
os.symlink('bar', 'path/foo')
1751
wt.add(['foo'], ['foo-id'])
1752
self.assertEqual('bar', wt.get_symlink_target('foo-id'))
1753
wt.commit('add symlink', rev_id='F-id')
1754
# Reset to D, so that we can merge F
1755
wt.set_parent_ids(['D-id'])
1756
wt.branch.set_last_revision_info(3, 'D-id')
1758
self.assertIs(None, wt.path2id('foo'))
1759
conflicts = wt.merge_from_branch(wt.branch, to_revision='F-id')
1760
self.assertEqual(0, conflicts)
1761
self.assertEqual('foo-id', wt.path2id('foo'))
1762
self.assertEqual('bar', wt.get_symlink_target('foo-id'))
1764
def test_unmodified_symlink(self):
1765
self.requireFeature(tests.SymlinkFeature)
1766
# A Create symlink foo => bar
1768
# B C B relinks foo => baz
1772
# D E D & E have foo => baz
1774
# F F changes it to bing
1776
# Merging D & F should result in F cleanly overriding D, because D's
1777
# value actually comes from F
1779
# Have to use a real WT, because BranchBuilder and MemoryTree don't
1780
# have symlink support
1781
wt = self.make_branch_and_tree('path')
1783
self.addCleanup(wt.unlock)
1784
os.symlink('bar', 'path/foo')
1785
wt.add(['foo'], ['foo-id'])
1786
wt.commit('add symlink', rev_id='A-id')
1787
os.remove('path/foo')
1788
os.symlink('baz', 'path/foo')
1789
wt.commit('foo => baz', rev_id='B-id')
1790
wt.set_last_revision('A-id')
1791
wt.branch.set_last_revision_info(1, 'A-id')
1793
wt.commit('C', rev_id='C-id')
1794
wt.merge_from_branch(wt.branch, 'B-id')
1795
self.assertEqual('baz', wt.get_symlink_target('foo-id'))
1796
wt.commit('E merges C & B', rev_id='E-id')
1797
os.remove('path/foo')
1798
os.symlink('bing', 'path/foo')
1799
wt.commit('F foo => bing', rev_id='F-id')
1800
wt.set_last_revision('B-id')
1801
wt.branch.set_last_revision_info(2, 'B-id')
1803
wt.merge_from_branch(wt.branch, 'C-id')
1804
wt.commit('D merges B & C', rev_id='D-id')
1805
conflicts = wt.merge_from_branch(wt.branch, to_revision='F-id')
1806
self.expectFailure("Merge3Merger doesn't use lcas for symlink content",
1807
self.assertEqual, 0, conflicts)
1808
self.assertEqual('bing', wt.get_symlink_target('foo-id'))
1728
1810
def test_other_reverted_path_to_base(self):
1729
1811
# A Path at 'foo'