~bzr-pqm/bzr/bzr.dev

974.1.56 by aaron.bentley at utoronto
Added merge test
1
from bzrlib.branch import Branch
2
from bzrlib.commit import commit
3
from bzrlib.selftest import TestCaseInTempDir
4
from bzrlib.merge import merge
974.1.80 by Aaron Bentley
Improved merge error handling and testing
5
from bzrlib.errors import UnrelatedBranches, NoCommits
6
import os
974.1.56 by aaron.bentley at utoronto
Added merge test
7
class TestMerge(TestCaseInTempDir):
8
    """Test appending more than one revision"""
9
    def test_pending(self):
10
        br = Branch(".", init=True)
11
        commit(br, "lala!")
12
        self.assertEquals(len(br.pending_merges()), 0)
13
        merge(['.', -1], [None, None])
14
        self.assertEquals(len(br.pending_merges()), 0)
974.1.80 by Aaron Bentley
Improved merge error handling and testing
15
16
    def test_nocommits(self):
17
        self.test_pending()
18
        os.mkdir('branch2')
19
        br2 = Branch('branch2', init=True)
20
        self.assertRaises(NoCommits, merge, ['branch2', -1], 
21
                          [None, None])
22
        return br2
23
24
    def test_unrelated(self):
25
        br2 = self.test_nocommits()
26
        commit(br2, "blah")
27
        self.assertRaises(UnrelatedBranches, merge, ['branch2', -1], 
28
                          [None, None])
974.1.88 by Aaron Bentley
Set a pending_merge if the merge base is forced to revno 0
29
        return br2
974.1.80 by Aaron Bentley
Improved merge error handling and testing
30
974.1.88 by Aaron Bentley
Set a pending_merge if the merge base is forced to revno 0
31
    def test_pending_with_null(self):
32
        """When base is forced to revno 0, pending_merges is set"""
33
        br2 = self.test_unrelated()
34
        br1 = Branch('.')
35
        merge(['branch2', -1], ['branch2', 0])
36
        self.assertEquals(len(br1.pending_merges()), 1)
37
        return (br1, br2)