~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

(jam) Update 'bzr merge --weave' to generate conflicts when one side
        modifies and one side deletes a line. (bug #328171)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1095
1095
            '>>>>>>> MERGE-SOURCE\n'
1096
1096
            'line 4\n', 'this/file1')
1097
1097
 
 
1098
    def test_modify_conflicts_with_delete(self):
 
1099
        # If one side deletes a line, and the other modifies that line, then
 
1100
        # the modification should be considered a conflict
 
1101
        builder = self.make_branch_builder('test')
 
1102
        builder.start_series()
 
1103
        builder.build_snapshot('BASE-id', None,
 
1104
            [('add', ('', None, 'directory', None)),
 
1105
             ('add', ('foo', 'foo-id', 'file', 'a\nb\nc\nd\ne\n')),
 
1106
            ])
 
1107
        # Delete 'b\n'
 
1108
        builder.build_snapshot('OTHER-id', ['BASE-id'],
 
1109
            [('modify', ('foo-id', 'a\nc\nd\ne\n'))])
 
1110
        # Modify 'b\n', add 'X\n'
 
1111
        builder.build_snapshot('THIS-id', ['BASE-id'],
 
1112
            [('modify', ('foo-id', 'a\nb2\nc\nd\nX\ne\n'))])
 
1113
        builder.finish_series()
 
1114
        branch = builder.get_branch()
 
1115
        this_tree = branch.bzrdir.create_workingtree()
 
1116
        this_tree.lock_write()
 
1117
        self.addCleanup(this_tree.unlock)
 
1118
        other_tree = this_tree.bzrdir.sprout('other', 'OTHER-id').open_workingtree()
 
1119
        self.do_merge(this_tree, other_tree)
 
1120
        if self.merge_type is _mod_merge.LCAMerger:
 
1121
            self.expectFailure("lca merge doesn't track deleted lines",
 
1122
                self.assertFileEqual,
 
1123
                    'a\n'
 
1124
                    '<<<<<<< TREE\n'
 
1125
                    'b2\n'
 
1126
                    '=======\n'
 
1127
                    '>>>>>>> MERGE-SOURCE\n'
 
1128
                    'c\n'
 
1129
                    'd\n'
 
1130
                    'X\n'
 
1131
                    'e\n', 'test/foo')
 
1132
        else:
 
1133
            self.assertFileEqual(
 
1134
                'a\n'
 
1135
                '<<<<<<< TREE\n'
 
1136
                'b2\n'
 
1137
                '=======\n'
 
1138
                '>>>>>>> MERGE-SOURCE\n'
 
1139
                'c\n'
 
1140
                'd\n'
 
1141
                'X\n'
 
1142
                'e\n', 'test/foo')
 
1143
 
1098
1144
 
1099
1145
class TestMerge3Merge(TestCaseWithTransport, TestMergeImplementation):
1100
1146