27
27
from bzrlib.errors import NoSuchRevision
29
29
def make_branches():
30
"""Create two branches
32
branch 1 has 6 commits, branch 2 has 3 commits
33
commit 10 was a psuedo merge from branch 1
34
but has been disabled until ghost support is
47
so A is missing b6 at the start
48
and B is missing a3, a4, a5
30
50
os.mkdir("branch1")
31
51
br1 = Branch.initialize("branch1")
51
71
fetch(from_branch=br2, to_branch=br1)
52
72
br1.add_pending_merge(br2.revision_history()[5])
53
73
commit(br1, "Commit nine", rev_id="a@u-0-5")
55
fetch(from_branch=br1, to_branch=br2)
56
br2.add_pending_merge(br1.revision_history()[4])
57
commit(br2, "Commit ten", rev_id="b@u-0-6")
59
fetch(from_branch=br2, to_branch=br1)
74
# disabled - it makes testing fetch too hard,
75
# but can be easily reenabled (without the fetch
76
# when GHOSTS are supported. RBC 20050928
77
#fetch(from_branch=br1, to_branch=br2)
78
#br2.add_pending_merge(br1.revision_history()[4])
79
commit(br2, "Commit ten - no merge", rev_id="b@u-0-6")
81
#fetch(from_branch=br2, to_branch=br1)
80
102
('a@u-0-5', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4',
81
103
'b@u-0-3', 'b@u-0-4',
82
104
'b@u-0-5', 'a@u-0-5']),
83
('b@u-0-6', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4',
105
('b@u-0-6', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2',
84
106
'b@u-0-3', 'b@u-0-4',
85
107
'b@u-0-5', 'b@u-0-6']),
109
br1_only = ('a@u-0-3', 'a@u-0-4', 'a@u-0-5')
110
br2_only = ('b@u-0-6',)
87
111
for branch in br1, br2:
88
112
for rev_id, anc in d:
113
if rev_id in br1_only and not branch is br1:
115
if rev_id in br2_only and not branch is br2:
89
117
mutter('ancestry of {%s}: %r',
90
118
rev_id, branch.get_ancestry(rev_id))
91
119
self.assertEquals(sorted(branch.get_ancestry(rev_id)),
158
186
self.br1.revision_history()),
159
187
['a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4',
161
self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-6',
162
self.br1.revision_history()),
163
['a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4',
165
self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-5'),
166
['a@u-0-1', 'a@u-0-2', 'b@u-0-3', 'b@u-0-4',
189
print ("testrevision.py 191 - intervene appears to return b..6 even"
190
"though it is not reachable!")
191
# self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-6',
192
# self.br1.revision_history()),
193
# ['a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4',
195
# self.assertEqual(self.intervene('a@u-0-0', 'b@u-0-5'),
196
# ['a@u-0-1', 'a@u-0-2', 'b@u-0-3', 'b@u-0-4',
168
198
self.assertEqual(self.intervene('b@u-0-3', 'b@u-0-6',
169
199
self.br2.revision_history()),
170
200
['b@u-0-4', 'b@u-0-5', 'b@u-0-6'])
218
248
self.assertEqual(common_ancestor(revisions[4], revisions_2[5], sources),
250
fetch(from_branch=br2, to_branch=br1)
220
251
self.assertEqual(common_ancestor(revisions[5], revisions_2[6], sources),
222
253
self.assertEqual(common_ancestor(revisions_2[6], revisions[5], sources),
256
287
self.assertEqual(common_ancestor(revisions[4], revisions_2[5], sources),
258
289
self.assertEqual(common_ancestor(revisions[5], revisions_2[6], sources),
260
291
self.assertEqual(common_ancestor(revisions_2[6], revisions[5], sources),
263
294
def test_combined(self):
264
295
"""combined_graph