~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: Ian Clatworthy
  • Date: 2007-08-14 03:59:22 UTC
  • mto: (2733.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2734.
  • Revision ID: ian.clatworthy@internode.on.net-20070814035922-siavg542cwvkf4r5
Fix pretty doc generation so works for all html docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from bzrlib import (
21
21
    conflicts,
 
22
    errors,
22
23
    merge as _mod_merge,
23
24
    option,
 
25
    progress,
24
26
    )
25
27
from bzrlib.branch import Branch
26
 
from bzrlib.builtins import _merge_helper
27
28
from bzrlib.conflicts import ConflictList, TextConflict
28
29
from bzrlib.errors import UnrelatedBranches, NoCommits, BzrCommandError
29
30
from bzrlib.merge import transform_tree, merge_inner
41
42
        wt = self.make_branch_and_tree('.')
42
43
        rev_a = wt.commit("lala!")
43
44
        self.assertEqual([rev_a], wt.get_parent_ids())
44
 
        _merge_helper([u'.', -1], [None, None])
 
45
        self.assertRaises(errors.PointlessMerge, wt.merge_from_branch,
 
46
                          wt.branch)
45
47
        self.assertEqual([rev_a], wt.get_parent_ids())
 
48
        return wt
46
49
 
47
50
    def test_undo(self):
48
51
        wt = self.make_branch_and_tree('.')
49
52
        wt.commit("lala!")
50
53
        wt.commit("haha!")
51
54
        wt.commit("blabla!")
52
 
        _merge_helper([u'.', 2], [u'.', 1])
 
55
        wt.merge_from_branch(wt.branch, wt.branch.get_rev_id(2),
 
56
                             wt.branch.get_rev_id(1))
53
57
 
54
58
    def test_nocommits(self):
55
 
        self.test_pending()
 
59
        wt = self.test_pending()
56
60
        wt2 = self.make_branch_and_tree('branch2')
57
 
        self.assertRaises(NoCommits, _merge_helper, ['branch2', -1],
58
 
                          [None, None])
59
 
        return wt2
 
61
        self.assertRaises(NoCommits, wt.merge_from_branch, wt2.branch)
 
62
        return wt, wt2
60
63
 
61
64
    def test_unrelated(self):
62
 
        wt2 = self.test_nocommits()
 
65
        wt, wt2 = self.test_nocommits()
63
66
        wt2.commit("blah")
64
 
        self.assertRaises(UnrelatedBranches, _merge_helper, ['branch2', -1],
65
 
                          [None, None])
 
67
        self.assertRaises(UnrelatedBranches, wt.merge_from_branch, wt2.branch)
66
68
        return wt2
67
69
 
68
70
    def test_merge_one_file(self):
92
94
        br1.fetch(wt2.branch)
93
95
        # merge all of branch 2 into branch 1 even though they 
94
96
        # are not related.
95
 
        self.assertRaises(BzrCommandError, _merge_helper, ['branch2', -1],
96
 
                          ['branch2', 0], reprocess=True, show_base=True)
97
 
        _merge_helper(['branch2', -1], ['branch2', 0], reprocess=True)
 
97
        wt1.merge_from_branch(wt2.branch, wt2.last_revision(), 'null:')
98
98
        self.assertEqual([br1.last_revision(), wt2.branch.last_revision()],
99
99
            wt1.get_parent_ids())
100
100
        return (wt1, wt2.branch)
270
270
            tree_b.merge_from_branch(tree_a.branch)
271
271
        except AttributeError:
272
272
            self.fail('tried to join a path when name was None')
 
273
 
 
274
    def test_merge_uncommitted_otherbasis_ancestor_of_thisbasis(self):
 
275
        tree_a = self.make_branch_and_tree('a')
 
276
        self.build_tree(['a/file_1', 'a/file_2'])
 
277
        tree_a.add(['file_1'])
 
278
        tree_a.commit('commit 1')
 
279
        tree_a.add(['file_2'])
 
280
        tree_a.commit('commit 2')
 
281
        tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
 
282
        tree_b.rename_one('file_1', 'renamed')
 
283
        merger = _mod_merge.Merger.from_uncommitted(tree_a, tree_b,
 
284
                                                    progress.DummyProgress())
 
285
        merger.merge_type = _mod_merge.Merge3Merger
 
286
        merger.do_merge()
 
287
        self.assertEqual(tree_a.get_parent_ids(), [tree_b.last_revision()])