~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testmerge.py

  • Committer: Aaron Bentley
  • Date: 2005-09-29 04:59:47 UTC
  • mto: (1393.1.21) (1185.14.1)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: aaron.bentley@utoronto.ca-20050929045947-ff08a7f6578f9657
Conflict handling where OTHER is deleted

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
7
import os
 
8
class TestMerge(TestCaseInTempDir):
 
9
    """Test appending more than one revision"""
 
10
    def test_pending(self):
 
11
        br = Branch.initialize(".")
 
12
        commit(br, "lala!")
 
13
        self.assertEquals(len(br.pending_merges()), 0)
 
14
        merge(['.', -1], [None, None])
 
15
        self.assertEquals(len(br.pending_merges()), 0)
 
16
 
 
17
    def test_nocommits(self):
 
18
        self.test_pending()
 
19
        os.mkdir('branch2')
 
20
        br2 = Branch.initialize('branch2')
 
21
        self.assertRaises(NoCommits, merge, ['branch2', -1], 
 
22
                          [None, None])
 
23
        return br2
 
24
 
 
25
    def test_unrelated(self):
 
26
        br2 = self.test_nocommits()
 
27
        commit(br2, "blah")
 
28
        self.assertRaises(UnrelatedBranches, merge, ['branch2', -1], 
 
29
                          [None, None])
 
30
        return br2
 
31
 
 
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)
 
38
        return (br1, br2)
 
39
 
 
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()
 
43
        commit(br1, "blah")
 
44
        last = br1.last_patch()
 
45
        self.assertEquals(common_ancestor(last, last, br1), last)