44
44
tree.commit(message='setup')
47
def create_conflicting_branches(self):
48
"""Create two branches which have overlapping modifications.
50
:return: (tree, other_branch) Where merging other_branch causes a file
53
builder = self.make_branch_builder('branch')
54
builder.build_snapshot('rev1', None,
55
[('add', ('', 'root-id', 'directory', None)),
56
('add', ('fname', 'f-id', 'file', 'a\nb\nc\n'))])
57
builder.build_snapshot('rev2other', ['rev1'],
58
[('modify', ('f-id', 'a\nB\nD\n'))])
59
other = builder.get_branch().bzrdir.sprout('other').open_branch()
60
builder.build_snapshot('rev2this', ['rev1'],
61
[('modify', ('f-id', 'a\nB\nC\n'))])
62
tree = builder.get_branch().create_checkout('tree', lightweight=True)
47
65
def test_merge_reprocess(self):
48
66
d = BzrDir.create_standalone_workingtree('.')
101
119
self.run_bzr('merge ../b -r last:1')
102
120
self.assertEqual([a_tip], a.get_parent_ids())
122
def test_merge_defaults_to_reprocess(self):
123
tree, other = self.create_conflicting_branches()
124
# The default merge algorithm should enable 'reprocess' because
125
# 'show-base' is not set
126
self.run_bzr('merge ../other', working_dir='tree',
128
self.assertEqualDiff('a\n'
134
'>>>>>>> MERGE-SOURCE\n',
135
tree.get_file_text('f-id'))
137
def test_merge_explicit_reprocess_show_base(self):
138
tree, other = self.create_conflicting_branches()
139
# Explicitly setting --reprocess, and --show-base is an error
140
self.run_bzr_error(['Cannot do conflict reduction and show base'],
141
'merge ../other --reprocess --show-base',
144
def test_merge_override_reprocess(self):
145
tree, other = self.create_conflicting_branches()
146
# Explicitly disable reprocess
147
self.run_bzr('merge ../other --no-reprocess', working_dir='tree',
149
self.assertEqualDiff('a\n'
156
'>>>>>>> MERGE-SOURCE\n',
157
tree.get_file_text('f-id'))
159
def test_merge_override_show_base(self):
160
tree, other = self.create_conflicting_branches()
161
# Setting '--show-base' will auto-disable '--reprocess'
162
self.run_bzr('merge ../other --show-base', working_dir='tree',
164
self.assertEqualDiff('a\n'
168
'||||||| BASE-REVISION\n'
174
'>>>>>>> MERGE-SOURCE\n',
175
tree.get_file_text('f-id'))
104
177
def test_merge_with_missing_file(self):
105
178
"""Merge handles missing file conflicts"""
106
179
self.build_tree_contents([