~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-30 21:50:34 UTC
  • mto: (3697.7.4 1.7)
  • mto: This revision was merged to the branch mainline in revision 3748.
  • Revision ID: john@arbash-meinel.com-20080730215034-n6n8nrcl3a1amiav
A couple of symlink tests, we need to do more.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1725
1725
        self.assertEqual(0, conflicts)
1726
1726
        self.assertTrue(wt.is_executable('foo-id'))
1727
1727
 
 
1728
    def test_create_symlink(self):
 
1729
        self.requireFeature(tests.SymlinkFeature)
 
1730
        #   A       
 
1731
        #  / \
 
1732
        # B   C 
 
1733
        # |\ /|
 
1734
        # | X |
 
1735
        # |/ \|
 
1736
        # D   E
 
1737
        #     |
 
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')
 
1757
        wt.revert()
 
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'))
 
1763
 
 
1764
    def test_unmodified_symlink(self):
 
1765
        self.requireFeature(tests.SymlinkFeature)
 
1766
        #   A       Create symlink foo => bar
 
1767
        #  / \
 
1768
        # B   C     B relinks foo => baz
 
1769
        # |\ /|
 
1770
        # | X |
 
1771
        # |/ \|
 
1772
        # D   E     D & E have foo => baz
 
1773
        #     |
 
1774
        #     F     F changes it to bing
 
1775
        #
 
1776
        # Merging D & F should result in F cleanly overriding D, because D's
 
1777
        # value actually comes from F
 
1778
 
 
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')
 
1782
        wt.lock_write()
 
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')
 
1792
        wt.revert()
 
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')
 
1802
        wt.revert()
 
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'))
 
1809
 
1728
1810
    def test_other_reverted_path_to_base(self):
1729
1811
        #   A       Path at 'foo'
1730
1812
        #  / \