20
20
from bzrlib import (
22
23
merge as _mod_merge,
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,
45
47
self.assertEqual([rev_a], wt.get_parent_ids())
47
50
def test_undo(self):
48
51
wt = self.make_branch_and_tree('.')
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))
54
58
def test_nocommits(self):
59
wt = self.test_pending()
56
60
wt2 = self.make_branch_and_tree('branch2')
57
self.assertRaises(NoCommits, _merge_helper, ['branch2', -1],
61
self.assertRaises(NoCommits, wt.merge_from_branch, wt2.branch)
61
64
def test_unrelated(self):
62
wt2 = self.test_nocommits()
65
wt, wt2 = self.test_nocommits()
64
self.assertRaises(UnrelatedBranches, _merge_helper, ['branch2', -1],
67
self.assertRaises(UnrelatedBranches, wt.merge_from_branch, wt2.branch)
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
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)
280
280
tree_a.commit('commit 2')
281
281
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
282
282
tree_b.rename_one('file_1', 'renamed')
283
_merge_helper(['b', None], ['b', -1], this_dir='a')
283
merger = _mod_merge.Merger.from_uncommitted(tree_a, tree_b,
284
progress.DummyProgress())
285
merger.merge_type = _mod_merge.Merge3Merger
284
287
self.assertEqual(tree_a.get_parent_ids(), [tree_b.last_revision()])