1
from bzrlib.branch import Branch
2
from bzrlib.commit import commit
3
from bzrlib.selftest import TestCaseInTempDir
4
from bzrlib.merge import merge
5
from bzrlib.errors import UnrelatedBranches, NoCommits
6
from bzrlib.revision import common_ancestor
8
class TestMerge(TestCaseInTempDir):
9
"""Test appending more than one revision"""
10
def test_pending(self):
11
br = Branch.initialize(".")
13
self.assertEquals(len(br.pending_merges()), 0)
14
merge(['.', -1], [None, None])
15
self.assertEquals(len(br.pending_merges()), 0)
17
def test_nocommits(self):
20
br2 = Branch.initialize('branch2')
21
self.assertRaises(NoCommits, merge, ['branch2', -1],
25
def test_unrelated(self):
26
br2 = self.test_nocommits()
28
self.assertRaises(UnrelatedBranches, merge, ['branch2', -1],
32
def test_pending_with_null(self):
33
"""When base is forced to revno 0, pending_merges is set"""
34
br2 = self.test_unrelated()
35
br1 = Branch.open('.')
36
merge(['branch2', -1], ['branch2', 0])
37
self.assertEquals(len(br1.pending_merges()), 1)
40
def test_two_roots(self):
41
"""Merge base is sane when two unrelated branches are merged"""
42
br1, br2 = self.test_pending_with_null()
44
last = br1.last_patch()
45
self.assertEquals(common_ancestor(last, last, br1), last)