132
132
class TestCommonAncestor(TestCaseInTempDir):
133
133
"""Test checking whether a revision is an ancestor of another revision"""
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)
145
expected_ancestors_list = {revisions[3]:(0, 0),
147
revisions_2[4]:(2, 1),
149
revisions_2[3]:(4, 2),
150
revisions[0]:(5, 3) }
151
ancestors_list = find_present_ancestors(revisions[3], sources)
152
assert len(expected_ancestors_list) == len(ancestors_list)
153
for key, value in expected_ancestors_list.iteritems():
154
self.assertEqual(ancestors_list[key], value,
155
"key %r, %r != %r" % (key, ancestors_list[key],
158
self.assertEqual(common_ancestor(revisions[0], revisions[0], sources),
160
self.assertEqual(common_ancestor(revisions[1], revisions[2], sources),
162
self.assertEqual(common_ancestor(revisions[1], revisions[1], sources),
164
self.assertEqual(common_ancestor(revisions[2], revisions_2[4], sources),
166
self.assertEqual(common_ancestor(revisions[3], revisions_2[4], sources),
168
self.assertEqual(common_ancestor(revisions[4], revisions_2[5], sources),
170
self.assertEqual(common_ancestor(revisions[5], revisions_2[6], sources),
172
self.assertEqual(common_ancestor(revisions_2[6], revisions[5], sources),
135
175
def test_common_ancestor(self):
136
from bzrlib.revision import find_present_ancestors, common_ancestor
176
"""Pick a reasonable merge base"""
177
from bzrlib.revision import find_present_ancestors
178
from bzrlib.revision import common_ancestor
137
179
from bzrlib.revision import MultipleRevisionSources
138
180
br1, br2 = make_branches()
139
181
revisions = br1.revision_history()