67
67
assert is_ancestor(revisions[3], revisions_2[3], sources)
68
68
assert not is_ancestor(revisions[3], revisions_2[3], br1)
70
class TestIntermediateRevisions(InTempDir):
72
from bzrlib.commit import commit
73
self.br1, self.br2 = make_branches()
74
commit(self.br2, "Commit eleven", rev_id="b@u-0-7")
75
commit(self.br2, "Commit twelve", rev_id="b@u-0-8")
76
commit(self.br2, "Commit thirtteen", rev_id="b@u-0-9")
77
self.br1.add_pending_merge(self.br2.revision_history()[6])
78
commit(self.br1, "Commit fourtten", rev_id="a@u-0-6")
79
self.br2.add_pending_merge(self.br1.revision_history()[6])
80
commit(self.br2, "Commit fifteen", rev_id="b@u-0-10")
82
from bzrlib.revision import MultipleRevisionSources
83
self.sources = MultipleRevisionSources(self.br1, self.br2)
85
def intervene(self, ancestor, revision, revision_history=None):
86
from bzrlib.revision import get_intervening_revisions
87
return get_intervening_revisions(ancestor,revision, self.sources,
91
"""Find intermediate revisions, without requiring history"""
92
assert len(self.intervene('a@u-0-0', 'a@u-0-0')) == 0
93
self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-1'), ['a@u-0-1'])
94
self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-2'),
95
['a@u-0-1', 'a@u-0-2'])
96
self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-3'),
97
['a@u-0-1', 'a@u-0-2', 'b@u-0-3'])
98
self.assertEqual(self.intervene('b@u-0-3', 'a@u-0-3'),
99
['b@u-0-4', 'a@u-0-3'])
100
self.assertEqual(self.intervene('a@u-0-2', 'a@u-0-3'),
102
self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-5',
103
self.br1.revision_history()),
104
['a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4',
106
self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-6',
107
self.br1.revision_history()),
108
['a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4',
110
self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-5'),
111
['a@u-0-1', 'a@u-0-2', 'b@u-0-3', 'b@u-0-4',
113
self.assertEqual(self.intervene('b@u-0-3', 'b@u-0-6'),
114
['b@u-0-4', 'b@u-0-5', 'b@u-0-6'])
115
self.assertEqual(self.intervene('b@u-0-6', 'b@u-0-10'),
116
['a@u-0-6', 'b@u-0-10'])
117
# self.assertEqual(self.intervene('b@u-0-6', 'b@u-0-10',
118
# self.br2.revision_history()),
119
# ['b@u-0-7', 'b@u-0-8', 'b@u-0-9', 'b@u-0-10'])
71
122
class TestCommonAncestor(InTempDir):
72
123
"""Test checking whether a revision is an ancestor of another revision"""