68
67
assert is_ancestor(revisions[3], revisions_2[3], sources)
69
68
assert not is_ancestor(revisions[3], revisions_2[3], br1)
71
class TestIntermediateRevisions(InTempDir):
74
from bzrlib.commit import commit
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")
85
from bzrlib.revision import MultipleRevisionSources
86
self.sources = MultipleRevisionSources(self.br1, self.br2)
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,
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()),
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',
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',
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',
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())
134
71
class TestCommonAncestor(InTempDir):
135
72
"""Test checking whether a revision is an ancestor of another revision"""
137
def test_common_ancestor(self):
138
74
from bzrlib.revision import find_present_ancestors, common_ancestor
139
75
from bzrlib.revision import MultipleRevisionSources
140
76
br1, br2 = make_branches()