64
65
fetch(from_branch=br2, to_branch=br1)
65
66
br1.add_pending_merge(revisions_2[4])
66
assert revisions_2[4] == 'b@u-0-4'
67
self.assertEquals(revisions_2[4], 'b@u-0-4')
67
68
commit(br1, "Commit six", rev_id="a@u-0-3")
68
69
commit(br1, "Commit seven", rev_id="a@u-0-4")
69
70
commit(br2, "Commit eight", rev_id="b@u-0-5")
82
83
class TestIsAncestor(TestCaseInTempDir):
83
84
def test_recorded_ancestry(self):
84
85
"""Test that commit records all ancestors"""
85
br1, br2 = make_branches()
86
br1, br2 = make_branches(self)
86
87
d = [('a@u-0-0', ['a@u-0-0']),
87
88
('a@u-0-1', ['a@u-0-0', 'a@u-0-1']),
88
89
('a@u-0-2', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2']),
119
120
def test_is_ancestor(self):
120
121
"""Test checking whether a revision is an ancestor of another revision"""
121
br1, br2 = make_branches()
122
br1, br2 = make_branches(self)
122
123
revisions = br1.revision_history()
123
124
revisions_2 = br2.revision_history()
126
assert is_ancestor(revisions[0], revisions[0], br1)
127
assert is_ancestor(revisions[1], revisions[0], sources)
128
assert not is_ancestor(revisions[0], revisions[1], sources)
129
assert is_ancestor(revisions_2[3], revisions[0], sources)
127
self.assert_(is_ancestor(revisions[0], revisions[0], br1))
128
self.assert_(is_ancestor(revisions[1], revisions[0], sources))
129
self.assert_(not is_ancestor(revisions[0], revisions[1], sources))
130
self.assert_(is_ancestor(revisions_2[3], revisions[0], sources))
130
131
# disabled mbp 20050914, doesn't seem to happen anymore
131
132
## self.assertRaises(NoSuchRevision, is_ancestor, revisions_2[3],
132
133
## revisions[0], br1)
133
assert is_ancestor(revisions[3], revisions_2[4], sources)
134
assert is_ancestor(revisions[3], revisions_2[4], br1)
135
assert is_ancestor(revisions[3], revisions_2[3], sources)
136
## assert not is_ancestor(revisions[3], revisions_2[3], br1)
134
self.assert_(is_ancestor(revisions[3], revisions_2[4], sources))
135
self.assert_(is_ancestor(revisions[3], revisions_2[4], br1))
136
self.assert_(is_ancestor(revisions[3], revisions_2[3], sources))
137
## self.assert_(not is_ancestor(revisions[3], revisions_2[3], br1))
139
140
class TestIntermediateRevisions(TestCaseInTempDir):
142
143
from bzrlib.commit import commit
143
144
TestCaseInTempDir.setUp(self)
144
self.br1, self.br2 = make_branches()
145
self.br1, self.br2 = make_branches(self)
146
147
self.br2.commit("Commit eleven", rev_id="b@u-0-7")
147
148
self.br2.commit("Commit twelve", rev_id="b@u-0-8")
166
167
def test_intervene(self):
167
168
"""Find intermediate revisions, without requiring history"""
168
169
from bzrlib.errors import NotAncestor, NoSuchRevision
169
assert len(self.intervene('a@u-0-0', 'a@u-0-0')) == 0
170
self.assertEquals(len(self.intervene('a@u-0-0', 'a@u-0-0')), 0)
170
171
self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-1'), ['a@u-0-1'])
171
172
self.assertEqual(self.intervene('a@u-0-0', 'a@u-0-2'),
172
173
['a@u-0-1', 'a@u-0-2'])
210
211
def test_old_common_ancestor(self):
211
212
"""Pick a resonable merge base using the old functionality"""
212
213
from bzrlib.revision import old_common_ancestor as common_ancestor
213
br1, br2 = make_branches()
214
br1, br2 = make_branches(self)
214
215
revisions = br1.revision_history()
215
216
revisions_2 = br2.revision_history()
222
223
revisions_2[3]:(4, 2),
223
224
revisions[0]:(5, 3) }
224
225
ancestors_list = find_present_ancestors(revisions[3], sources)
225
assert len(expected_ancestors_list) == len(ancestors_list)
226
self.assertEquals(len(expected_ancestors_list), len(ancestors_list))
226
227
for key, value in expected_ancestors_list.iteritems():
227
228
self.assertEqual(ancestors_list[key], value,
228
229
"key %r, %r != %r" % (key, ancestors_list[key],
249
250
def test_common_ancestor(self):
250
251
"""Pick a reasonable merge base"""
251
252
from bzrlib.revision import common_ancestor
252
br1, br2 = make_branches()
253
br1, br2 = make_branches(self)
253
254
revisions = br1.revision_history()
254
255
revisions_2 = br2.revision_history()
255
256
sources = MultipleRevisionSources(br1, br2)
260
261
revisions_2[3]:(4, 2),
261
262
revisions[0]:(5, 3) }
262
263
ancestors_list = find_present_ancestors(revisions[3], sources)
263
assert len(expected_ancestors_list) == len(ancestors_list)
264
self.assertEquals(len(expected_ancestors_list), len(ancestors_list))
264
265
for key, value in expected_ancestors_list.iteritems():
265
266
self.assertEqual(ancestors_list[key], value,
266
267
"key %r, %r != %r" % (key, ancestors_list[key],
286
287
"""combined_graph
287
288
Ensure it's not order-sensitive
289
br1, br2 = make_branches()
290
br1, br2 = make_branches(self)
290
291
source = MultipleRevisionSources(br1, br2)
291
292
combined_1 = combined_graph(br1.last_revision(),
292
293
br2.last_revision(), source)
293
294
combined_2 = combined_graph(br2.last_revision(),
294
295
br1.last_revision(), source)
295
assert combined_1[1] == combined_2[1]
296
assert combined_1[2] == combined_2[2]
297
assert combined_1[3] == combined_2[3]
298
assert combined_1 == combined_2
296
self.assertEquals(combined_1[1], combined_2[1])
297
self.assertEquals(combined_1[2], combined_2[2])
298
self.assertEquals(combined_1[3], combined_2[3])
299
self.assertEquals(combined_1, combined_2)