~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testrevision.py

  • Committer: Robert Collins
  • Date: 2005-09-12 12:28:19 UTC
  • mfrom: (1185.3.4)
  • mto: (1092.3.2)
  • mto: This revision was merged to the branch mainline in revision 1397.
  • Revision ID: robertc@robertcollins.net-20050912122819-e3f141d4a14f3f7f
mergeĀ fromĀ HEAD

Show diffs side-by-side

added added

removed removed

Lines of Context:
132
132
class TestCommonAncestor(TestCaseInTempDir):
133
133
    """Test checking whether a revision is an ancestor of another revision"""
134
134
 
 
135
    def test_old_common_ancestor(self):
 
136
        """Pick a resonable merge base using the old functionality"""
 
137
        from bzrlib.revision import find_present_ancestors
 
138
        from bzrlib.revision import old_common_ancestor as common_ancestor
 
139
        from bzrlib.revision import MultipleRevisionSources
 
140
        br1, br2 = make_branches()
 
141
        revisions = br1.revision_history()
 
142
        revisions_2 = br2.revision_history()
 
143
        sources = MultipleRevisionSources(br1, br2)
 
144
        expected_ancestors_list = {revisions[3]:(0, 0), 
 
145
                                   revisions[2]:(1, 1),
 
146
                                   revisions_2[4]:(2, 1), 
 
147
                                   revisions[1]:(3, 2),
 
148
                                   revisions_2[3]:(4, 2),
 
149
                                   revisions[0]:(5, 3) }
 
150
        ancestors_list = find_present_ancestors(revisions[3], sources)
 
151
        assert len(expected_ancestors_list) == len(ancestors_list)
 
152
        for key, value in expected_ancestors_list.iteritems():
 
153
            self.assertEqual(ancestors_list[key], value, 
 
154
                              "key %r, %r != %r" % (key, ancestors_list[key],
 
155
                                                    value))
 
156
        self.assertEqual(common_ancestor(revisions[0], revisions[0], sources),
 
157
                          revisions[0])
 
158
        self.assertEqual(common_ancestor(revisions[1], revisions[2], sources),
 
159
                          revisions[1])
 
160
        self.assertEqual(common_ancestor(revisions[1], revisions[1], sources),
 
161
                          revisions[1])
 
162
        self.assertEqual(common_ancestor(revisions[2], revisions_2[4], sources),
 
163
                          revisions[2])
 
164
        self.assertEqual(common_ancestor(revisions[3], revisions_2[4], sources),
 
165
                          revisions_2[4])
 
166
        self.assertEqual(common_ancestor(revisions[4], revisions_2[5], sources),
 
167
                          revisions_2[4])
 
168
        self.assertEqual(common_ancestor(revisions[5], revisions_2[6], sources),
 
169
                          revisions[4])
 
170
        self.assertEqual(common_ancestor(revisions_2[6], revisions[5], sources),
 
171
                          revisions_2[5])
 
172
 
135
173
    def test_common_ancestor(self):
136
 
        from bzrlib.revision import find_present_ancestors, common_ancestor
 
174
        """Pick a reasonable merge base"""
 
175
        from bzrlib.revision import find_present_ancestors
 
176
        from bzrlib.revision import common_ancestor
137
177
        from bzrlib.revision import MultipleRevisionSources
138
178
        br1, br2 = make_branches()
139
179
        revisions = br1.revision_history()
140
180
        revisions_2 = br2.revision_history()
141
181
        sources = MultipleRevisionSources(br1, br2)
142
 
 
143
182
        expected_ancestors_list = {revisions[3]:(0, 0), 
144
183
                                   revisions[2]:(1, 1),
145
184
                                   revisions_2[4]:(2, 1), 
152
191
            self.assertEqual(ancestors_list[key], value, 
153
192
                              "key %r, %r != %r" % (key, ancestors_list[key],
154
193
                                                    value))
155
 
 
156
194
        self.assertEqual(common_ancestor(revisions[0], revisions[0], sources),
157
195
                          revisions[0])
158
196
        self.assertEqual(common_ancestor(revisions[1], revisions[2], sources),
168
206
        self.assertEqual(common_ancestor(revisions[5], revisions_2[6], sources),
169
207
                          revisions[4])
170
208
        self.assertEqual(common_ancestor(revisions_2[6], revisions[5], sources),
171
 
                          revisions_2[5])
 
209
                          revisions[4])
 
210
 
172
211
 
173
212
class TestCreateSignedRevision(TestCaseInTempDir):
174
213
 
177
216
        # create a revision, sign it, apply to the store.
178
217
        pass
179
218
 
 
219
 
180
220
class TestOperators(TestCase):
181
221
 
182
222
    def test___eq__(self):