/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: Michael Ellerman
  • Date: 2006-03-09 00:24:48 UTC
  • mto: (1610.1.8 bzr.mbp.integration)
  • mto: This revision was merged to the branch mainline in revision 1616.
  • Revision ID: michael@ellerman.id.au-20060309002448-70cce15e3d605130
Make the "ignore line" in the commit message editor the "right" width, so
that if you make your message that wide it won't wrap in bzr log output.
Just as a visual aid.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
 
 
3
from bzrlib.branch import Branch
 
4
from bzrlib.builtins import merge
 
5
from bzrlib.commit import commit
 
6
from bzrlib.errors import UnrelatedBranches, NoCommits, BzrCommandError
 
7
from bzrlib.merge import transform_tree
 
8
from bzrlib.osutils import pathjoin
 
9
from bzrlib.revision import common_ancestor
 
10
from bzrlib.tests import TestCaseWithTransport
 
11
from bzrlib.workingtree import WorkingTree
 
12
 
 
13
 
 
14
class TestMerge(TestCaseWithTransport):
 
15
    """Test appending more than one revision"""
 
16
 
 
17
    def test_pending(self):
 
18
        wt = self.make_branch_and_tree('.')
 
19
        wt.commit("lala!")
 
20
        self.assertEquals(len(wt.pending_merges()), 0)
 
21
        merge([u'.', -1], [None, None])
 
22
        self.assertEquals(len(wt.pending_merges()), 0)
 
23
 
 
24
    def test_nocommits(self):
 
25
        self.test_pending()
 
26
        wt2 = self.make_branch_and_tree('branch2')
 
27
        self.assertRaises(NoCommits, merge, ['branch2', -1], 
 
28
                          [None, None])
 
29
        return wt2
 
30
 
 
31
    def test_unrelated(self):
 
32
        wt2 = self.test_nocommits()
 
33
        wt2.commit("blah")
 
34
        self.assertRaises(UnrelatedBranches, merge, ['branch2', -1], 
 
35
                          [None, None])
 
36
        return wt2
 
37
 
 
38
    def test_pending_with_null(self):
 
39
        """When base is forced to revno 0, pending_merges is set"""
 
40
        wt2 = self.test_unrelated()
 
41
        wt1 = WorkingTree.open('.')
 
42
        br1 = wt1.branch
 
43
        br1.fetch(wt2.branch)
 
44
        # merge all of branch 2 into branch 1 even though they 
 
45
        # are not related.
 
46
        self.assertRaises(BzrCommandError, merge, ['branch2', -1], 
 
47
                          ['branch2', 0], reprocess=True, show_base=True)
 
48
        merge(['branch2', -1], ['branch2', 0], reprocess=True)
 
49
        self.assertEquals(len(wt1.pending_merges()), 1)
 
50
        return (wt1, wt2.branch)
 
51
 
 
52
    def test_two_roots(self):
 
53
        """Merge base is sane when two unrelated branches are merged"""
 
54
        wt1, br2 = self.test_pending_with_null()
 
55
        wt1.commit("blah")
 
56
        last = wt1.branch.last_revision()
 
57
        self.assertEquals(common_ancestor(last, last, wt1.branch.repository), last)
 
58
 
 
59
    def test_create_rename(self):
 
60
        """Rename an inventory entry while creating the file"""
 
61
        tree =self.make_branch_and_tree('.')
 
62
        file('name1', 'wb').write('Hello')
 
63
        tree.add('name1')
 
64
        tree.commit(message="hello")
 
65
        tree.rename_one('name1', 'name2')
 
66
        os.unlink('name2')
 
67
        transform_tree(tree, tree.branch.basis_tree())
 
68
 
 
69
    def test_layered_rename(self):
 
70
        """Rename both child and parent at same time"""
 
71
        tree =self.make_branch_and_tree('.')
 
72
        os.mkdir('dirname1')
 
73
        tree.add('dirname1')
 
74
        filename = pathjoin('dirname1', 'name1')
 
75
        file(filename, 'wb').write('Hello')
 
76
        tree.add(filename)
 
77
        tree.commit(message="hello")
 
78
        filename2 = pathjoin('dirname1', 'name2')
 
79
        tree.rename_one(filename, filename2)
 
80
        tree.rename_one('dirname1', 'dirname2')
 
81
        transform_tree(tree, tree.branch.basis_tree())