~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testrevision.py

  • Committer: Martin Pool
  • Date: 2005-08-29 10:57:01 UTC
  • mfrom: (1092.1.41)
  • Revision ID: mbp@sourcefrog.net-20050829105701-7aaa81ecf1bfee05
- merge in merge improvements and additional tests 
  from aaron and lifeless

robertc@robertcollins.net-20050825131100-85772edabc817481

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from bzrlib.selftest import InTempDir
 
17
from bzrlib.selftest import FunctionalTestCase
18
18
 
19
19
 
20
20
def make_branches():
46
46
    return br1, br2
47
47
 
48
48
 
49
 
class TestIsAncestor(InTempDir):
50
 
 
 
49
class TestIsAncestor(FunctionalTestCase):
51
50
    def test_is_ancestor(self):
52
51
        """Test checking whether a revision is an ancestor of another revision"""
53
52
        from bzrlib.revision import is_ancestor, MultipleRevisionSources
68
67
        assert is_ancestor(revisions[3], revisions_2[3], sources)
69
68
        assert not is_ancestor(revisions[3], revisions_2[3], br1)
70
69
 
71
 
class TestIntermediateRevisions(InTempDir):
72
 
 
73
 
    def setUp(self):
74
 
        from bzrlib.commit import commit
75
 
        InTempDir.setUp(self)
76
 
        self.br1, self.br2 = make_branches()
77
 
        commit(self.br2, "Commit eleven", rev_id="b@u-0-7")
78
 
        commit(self.br2, "Commit twelve", rev_id="b@u-0-8")
79
 
        commit(self.br2, "Commit thirtteen", rev_id="b@u-0-9")
80
 
        self.br1.add_pending_merge(self.br2.revision_history()[6])
81
 
        commit(self.br1, "Commit fourtten", rev_id="a@u-0-6")
82
 
        self.br2.add_pending_merge(self.br1.revision_history()[6])
83
 
        commit(self.br2, "Commit fifteen", rev_id="b@u-0-10")
84
 
 
85
 
        from bzrlib.revision import MultipleRevisionSources
86
 
        self.sources = MultipleRevisionSources(self.br1, self.br2)
87
 
 
88
 
    def intervene(self, ancestor, revision, revision_history=None):
89
 
        from bzrlib.revision import get_intervening_revisions
90
 
        return get_intervening_revisions(ancestor,revision, self.sources, 
91
 
                                         revision_history)
92
 
 
93
 
    def test_intervene(self):
94
 
        """Find intermediate revisions, without requiring history"""
95
 
        from bzrlib.errors import NotAncestor, NoSuchRevision
96
 
        assert len(self.intervene('a@u-0-0', 'a@u-0-0')) == 0
97
 
        self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-1'), ['a@u-0-1'])
98
 
        self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-2'), 
99
 
                         ['a@u-0-1', 'a@u-0-2'])
100
 
        self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-3'), 
101
 
                         ['a@u-0-1', 'a@u-0-2', 'b@u-0-3'])
102
 
        self.assertEqual(self.intervene('b@u-0-3', 'a@u-0-3'), 
103
 
                         ['b@u-0-4', 'a@u-0-3'])
104
 
        self.assertEqual(self.intervene('a@u-0-2', 'a@u-0-3', 
105
 
                                        self.br1.revision_history()), 
106
 
                         ['a@u-0-3'])
107
 
        self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-5', 
108
 
                                        self.br1.revision_history()), 
109
 
                         ['a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4', 
110
 
                          'a@u-0-5'])
111
 
        self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-6', 
112
 
                         self.br1.revision_history()), 
113
 
                         ['a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4', 
114
 
                          'b@u-0-6'])
115
 
        self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-5'), 
116
 
                         ['a@u-0-1', 'a@u-0-2', 'b@u-0-3', 'b@u-0-4', 
117
 
                          'b@u-0-5'])
118
 
        self.assertEqual(self.intervene('b@u-0-3', 'b@u-0-6', 
119
 
                         self.br2.revision_history()), 
120
 
                         ['b@u-0-4', 'b@u-0-5', 'b@u-0-6'])
121
 
        self.assertEqual(self.intervene('b@u-0-6', 'b@u-0-10'), 
122
 
                         ['b@u-0-7', 'b@u-0-8', 'b@u-0-9', 'b@u-0-10'])
123
 
        self.assertEqual(self.intervene('b@u-0-6', 'b@u-0-10', 
124
 
                                        self.br2.revision_history()), 
125
 
                         ['b@u-0-7', 'b@u-0-8', 'b@u-0-9', 'b@u-0-10'])
126
 
        self.assertRaises(NotAncestor, self.intervene, 'b@u-0-10', 'b@u-0-6', 
127
 
                          self.br2.revision_history())
128
 
        self.assertRaises(NoSuchRevision, self.intervene, 'c@u-0-10', 
129
 
                          'b@u-0-6', self.br2.revision_history())
130
 
        self.assertRaises(NoSuchRevision, self.intervene, 'b@u-0-10', 
131
 
                          'c@u-0-6', self.br2.revision_history())
132
 
 
133
 
 
134
 
class TestCommonAncestor(InTempDir):
 
70
 
 
71
class TestCommonAncestor(FunctionalTestCase):
135
72
    """Test checking whether a revision is an ancestor of another revision"""
136
73
 
137
74
    def test_common_ancestor(self):