~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testmerge.py

  • Committer: Robert Collins
  • Date: 2005-09-28 05:25:54 UTC
  • mfrom: (1185.1.42)
  • mto: (1092.2.18)
  • mto: This revision was merged to the branch mainline in revision 1397.
  • Revision ID: robertc@robertcollins.net-20050928052554-beb985505f77ea6a
update symlink branch to integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
 
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
 
9
 
 
10
 
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(".")
9
15
        commit(br, "lala!")
10
16
        self.assertEquals(len(br.pending_merges()), 0)
11
17
        merge(['.', -1], [None, None])
12
18
        self.assertEquals(len(br.pending_merges()), 0)
 
19
 
 
20
    def test_nocommits(self):
 
21
        self.test_pending()
 
22
        os.mkdir('branch2')
 
23
        br2 = Branch.initialize('branch2')
 
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])
 
33
        return br2
 
34
 
 
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)
 
41
        return (br1, br2)
 
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)