50
53
fetch(from_branch=br1, to_branch=br2)
51
54
br2.add_pending_merge(br1.revision_history()[4])
52
55
commit(br2, "Commit ten", rev_id="b@u-0-6")
57
fetch(from_branch=br2, to_branch=br1)
57
62
class TestIsAncestor(TestCaseInTempDir):
63
def test_recorded_ancestry(self):
64
"""Test that commit records all ancestors"""
65
br1, br2 = make_branches()
66
d = [('a@u-0-0', ['a@u-0-0']),
67
('a@u-0-1', ['a@u-0-0', 'a@u-0-1']),
68
('a@u-0-2', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2']),
69
('b@u-0-3', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'b@u-0-3']),
70
('b@u-0-4', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'b@u-0-3', 'b@u-0-3', 'b@u-0-4']),
72
for branch in br1, br2:
74
self.assertEquals(sorted(branch.get_ancestry(rev_id)),
58
78
def test_is_ancestor(self):
59
79
"""Test checking whether a revision is an ancestor of another revision"""
60
from bzrlib.revision import is_ancestor, MultipleRevisionSources
61
from bzrlib.errors import NoSuchRevision
62
80
br1, br2 = make_branches()
63
81
revisions = br1.revision_history()
64
82
revisions_2 = br2.revision_history()
65
sources = MultipleRevisionSources(br1, br2)
67
assert is_ancestor(revisions[0], revisions[0], sources)
85
assert is_ancestor(revisions[0], revisions[0], br1)
68
86
assert is_ancestor(revisions[1], revisions[0], sources)
69
87
assert not is_ancestor(revisions[0], revisions[1], sources)
70
88
assert is_ancestor(revisions_2[3], revisions[0], sources)
71
self.assertRaises(NoSuchRevision, is_ancestor, revisions_2[3],
89
# disabled mbp 20050914, doesn't seem to happen anymore
90
## self.assertRaises(NoSuchRevision, is_ancestor, revisions_2[3],
73
92
assert is_ancestor(revisions[3], revisions_2[4], sources)
74
93
assert is_ancestor(revisions[3], revisions_2[4], br1)
75
94
assert is_ancestor(revisions[3], revisions_2[3], sources)
76
95
assert not is_ancestor(revisions[3], revisions_2[3], br1)
78
99
class TestIntermediateRevisions(TestCaseInTempDir):
81
102
from bzrlib.commit import commit
82
103
TestCaseInTempDir.setUp(self)
83
104
self.br1, self.br2 = make_branches()
84
commit(self.br2, "Commit eleven", rev_id="b@u-0-7")
85
commit(self.br2, "Commit twelve", rev_id="b@u-0-8")
86
commit(self.br2, "Commit thirtteen", rev_id="b@u-0-9")
106
self.br2.commit("Commit eleven", rev_id="b@u-0-7")
107
self.br2.commit("Commit twelve", rev_id="b@u-0-8")
108
self.br2.commit("Commit thirtteen", rev_id="b@u-0-9")
110
fetch(from_branch=self.br2, to_branch=self.br1)
87
111
self.br1.add_pending_merge(self.br2.revision_history()[6])
88
commit(self.br1, "Commit fourtten", rev_id="a@u-0-6")
112
self.br1.commit("Commit fourtten", rev_id="a@u-0-6")
114
fetch(from_branch=self.br1, to_branch=self.br2)
89
115
self.br2.add_pending_merge(self.br1.revision_history()[6])
90
commit(self.br2, "Commit fifteen", rev_id="b@u-0-10")
116
self.br2.commit("Commit fifteen", rev_id="b@u-0-10")
92
118
from bzrlib.revision import MultipleRevisionSources
93
119
self.sources = MultipleRevisionSources(self.br1, self.br2)