/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1185.1.41 by Robert Collins
massive patch from Alexander Belchenko - many PEP8 fixes, removes unused function uuid
1
import os
2
974.1.56 by aaron.bentley at utoronto
Added merge test
3
from bzrlib.branch import Branch
4
from bzrlib.commit import commit
5
from bzrlib.selftest import TestCaseInTempDir
6
from bzrlib.merge import merge
974.1.80 by Aaron Bentley
Improved merge error handling and testing
7
from bzrlib.errors import UnrelatedBranches, NoCommits
974.1.89 by Aaron Bentley
Fixed merging with multiple roots, by using null as graph root.
8
from bzrlib.revision import common_ancestor
1185.1.41 by Robert Collins
massive patch from Alexander Belchenko - many PEP8 fixes, removes unused function uuid
9
10
974.1.56 by aaron.bentley at utoronto
Added merge test
11
class TestMerge(TestCaseInTempDir):
12
    """Test appending more than one revision"""
13
    def test_pending(self):
1185.2.19 by Lalo Martins
made tests pass again, after merge from integration
14
        br = Branch.initialize(".")
974.1.56 by aaron.bentley at utoronto
Added merge test
15
        commit(br, "lala!")
16
        self.assertEquals(len(br.pending_merges()), 0)
17
        merge(['.', -1], [None, None])
18
        self.assertEquals(len(br.pending_merges()), 0)
974.1.80 by Aaron Bentley
Improved merge error handling and testing
19
20
    def test_nocommits(self):
21
        self.test_pending()
22
        os.mkdir('branch2')
1185.2.19 by Lalo Martins
made tests pass again, after merge from integration
23
        br2 = Branch.initialize('branch2')
974.1.80 by Aaron Bentley
Improved merge error handling and testing
24
        self.assertRaises(NoCommits, merge, ['branch2', -1], 
25
                          [None, None])
26
        return br2
27
28
    def test_unrelated(self):
29
        br2 = self.test_nocommits()
30
        commit(br2, "blah")
31
        self.assertRaises(UnrelatedBranches, merge, ['branch2', -1], 
32
                          [None, None])
974.1.88 by Aaron Bentley
Set a pending_merge if the merge base is forced to revno 0
33
        return br2
974.1.80 by Aaron Bentley
Improved merge error handling and testing
34
974.1.88 by Aaron Bentley
Set a pending_merge if the merge base is forced to revno 0
35
    def test_pending_with_null(self):
36
        """When base is forced to revno 0, pending_merges is set"""
37
        br2 = self.test_unrelated()
974.1.91 by Aaron Bentley
Merged latest from mpool
38
        br1 = Branch.open('.')
974.1.88 by Aaron Bentley
Set a pending_merge if the merge base is forced to revno 0
39
        merge(['branch2', -1], ['branch2', 0])
40
        self.assertEquals(len(br1.pending_merges()), 1)
41
        return (br1, br2)
974.1.89 by Aaron Bentley
Fixed merging with multiple roots, by using null as graph root.
42
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()
46
        commit(br1, "blah")
47
        last = br1.last_patch()
48
        self.assertEquals(common_ancestor(last, last, br1), last)