/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/workingtree_implementations/test_merge_from_branch.py

First attempt to merge .dev and resolve the conflicts (but tests are 
failing)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Tests for the WorkingTree.merge_from_branch api."""
19
19
 
 
20
import os
 
21
 
 
22
from bzrlib import (
 
23
    errors,
 
24
    merge
 
25
    )
20
26
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
21
27
 
22
28
 
49
55
            to_revision=self.second_rev)
50
56
        self.assertEqual([self.to_second_rev, self.second_rev],
51
57
            self.tree_to.get_parent_ids())
 
58
 
 
59
    def test_compare_after_merge(self):
 
60
        tree_a = self.make_branch_and_tree('tree_a')
 
61
        self.build_tree_contents([('tree_a/file', 'text-a')])
 
62
        tree_a.add('file')
 
63
        tree_a.commit('added file')
 
64
        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
 
65
        os.unlink('tree_a/file')
 
66
        tree_a.commit('deleted file')
 
67
        self.build_tree_contents([('tree_b/file', 'text-b')])
 
68
        tree_b.commit('changed file')
 
69
        tree_a.merge_from_branch(tree_b.branch)
 
70
        tree_a.lock_read()
 
71
        self.addCleanup(tree_a.unlock)
 
72
        list(tree_a.iter_changes(tree_a.basis_tree()))
 
73
 
 
74
    def test_merge_empty(self):
 
75
        tree_a = self.make_branch_and_tree('tree_a')
 
76
        self.build_tree_contents([('tree_a/file', 'text-a')])
 
77
        tree_a.add('file')
 
78
        tree_a.commit('added file')
 
79
        tree_b = self.make_branch_and_tree('treeb')
 
80
        self.assertRaises(errors.NoCommits, tree_a.merge_from_branch,
 
81
                          tree_b.branch)
 
82
        tree_b.merge_from_branch(tree_a.branch)
 
83
 
 
84
    def test_merge_base(self):
 
85
        tree_a = self.make_branch_and_tree('tree_a')
 
86
        self.build_tree_contents([('tree_a/file', 'text-a')])
 
87
        tree_a.add('file')
 
88
        tree_a.commit('added file', rev_id='rev_1')
 
89
        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
 
90
        os.unlink('tree_a/file')
 
91
        tree_a.commit('deleted file')
 
92
        self.build_tree_contents([('tree_b/file', 'text-b')])
 
93
        tree_b.commit('changed file')
 
94
        self.assertRaises(errors.PointlessMerge, tree_a.merge_from_branch,
 
95
            tree_b.branch, from_revision=tree_b.branch.last_revision())
 
96
        tree_a.merge_from_branch(tree_b.branch, from_revision='rev_1')
 
97
        tree_a.lock_read()
 
98
        self.addCleanup(tree_a.unlock)
 
99
        changes = list(tree_a.iter_changes(tree_a.basis_tree()))
 
100
        self.assertEqual(1, len(changes))
 
101
 
 
102
    def test_merge_type(self):
 
103
        this = self.make_branch_and_tree('this')
 
104
        self.build_tree_contents([('this/foo', 'foo')])
 
105
        this.add('foo', 'foo-id')
 
106
        this.commit('added foo')
 
107
        other = this.bzrdir.sprout('other').open_workingtree()
 
108
        self.build_tree_contents([('other/foo', 'bar')])
 
109
        other.commit('content -> bar')
 
110
        self.build_tree_contents([('this/foo', 'baz')])
 
111
        this.commit('content -> baz')
 
112
        class QuxMerge(merge.Merge3Merger):
 
113
            def text_merge(self, file_id, trans_id):
 
114
                self.tt.create_file('qux', trans_id)
 
115
        this.merge_from_branch(other.branch, merge_type=QuxMerge)
 
116
        self.assertEqual('qux', this.get_file_text('foo-id'))