1
3
from bzrlib.branch import Branch
2
4
from bzrlib.commit import commit
3
5
from bzrlib.selftest import TestCaseInTempDir
4
6
from bzrlib.merge import merge
7
from bzrlib.errors import UnrelatedBranches, NoCommits
8
from bzrlib.revision import common_ancestor
5
11
class TestMerge(TestCaseInTempDir):
6
12
"""Test appending more than one revision"""
7
13
def test_pending(self):
8
br = Branch(".", init=True)
14
br = Branch.initialize(".")
10
16
self.assertEquals(len(br.pending_merges()), 0)
11
17
merge(['.', -1], [None, None])
12
18
self.assertEquals(len(br.pending_merges()), 0)
20
def test_nocommits(self):
23
br2 = Branch.initialize('branch2')
24
self.assertRaises(NoCommits, merge, ['branch2', -1],
28
def test_unrelated(self):
29
br2 = self.test_nocommits()
31
self.assertRaises(UnrelatedBranches, merge, ['branch2', -1],
35
def test_pending_with_null(self):
36
"""When base is forced to revno 0, pending_merges is set"""
37
br2 = self.test_unrelated()
38
br1 = Branch.open('.')
39
merge(['branch2', -1], ['branch2', 0])
40
self.assertEquals(len(br1.pending_merges()), 1)
43
def test_two_roots(self):
44
"""Merge base is sane when two unrelated branches are merged"""
45
br1, br2 = self.test_pending_with_null()
47
last = br1.last_patch()
48
self.assertEquals(common_ancestor(last, last, br1), last)