Merge lp:~jameinel/bzr/weave_conflict_delete_328171 into lp:~bzr/bzr/trunk-old

Proposed by John A Meinel
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jameinel/bzr/weave_conflict_delete_328171
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 104 lines
To merge this branch: bzr merge lp:~jameinel/bzr/weave_conflict_delete_328171
Reviewer Review Type Date Requested Status
Bazaar Developers Pending
Review via email: mp+6027@code.launchpad.net
To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

Fixes bug #328171 by considering 'killed-both' to be a change on both sides.

This should be fine, considering the earlier code that has 'killed-a' set 'ch_a = True', etc.

We already check if both sides are considered 'changed' whether the actual content is identical (lines_a == lines_b).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2009-05-01 07:59:02 +0000
3+++ NEWS 2009-05-01 19:35:11 +0000
4@@ -38,6 +38,9 @@
5 * Adding now works properly when path contains a symbolic link.
6 (Geoff Bache, #183831)
7
8+* ``bzr merge --weave`` will now generate a conflict if one side deletes a
9+ line, and the other side modifies the line. (John Arbash Meinel, #328171)
10+
11 * ``bzr send`` works to send emails again using MAPI.
12 (Neil Martinsen-Burrell, #346998)
13
14
15=== modified file 'bzrlib/tests/test_merge.py'
16--- bzrlib/tests/test_merge.py 2009-03-24 01:53:42 +0000
17+++ bzrlib/tests/test_merge.py 2009-05-01 19:35:11 +0000
18@@ -1095,6 +1095,52 @@
19 '>>>>>>> MERGE-SOURCE\n'
20 'line 4\n', 'this/file1')
21
22+ def test_modify_conflicts_with_delete(self):
23+ # If one side deletes a line, and the other modifies that line, then
24+ # the modification should be considered a conflict
25+ builder = self.make_branch_builder('test')
26+ builder.start_series()
27+ builder.build_snapshot('BASE-id', None,
28+ [('add', ('', None, 'directory', None)),
29+ ('add', ('foo', 'foo-id', 'file', 'a\nb\nc\nd\ne\n')),
30+ ])
31+ # Delete 'b\n'
32+ builder.build_snapshot('OTHER-id', ['BASE-id'],
33+ [('modify', ('foo-id', 'a\nc\nd\ne\n'))])
34+ # Modify 'b\n', add 'X\n'
35+ builder.build_snapshot('THIS-id', ['BASE-id'],
36+ [('modify', ('foo-id', 'a\nb2\nc\nd\nX\ne\n'))])
37+ builder.finish_series()
38+ branch = builder.get_branch()
39+ this_tree = branch.bzrdir.create_workingtree()
40+ this_tree.lock_write()
41+ self.addCleanup(this_tree.unlock)
42+ other_tree = this_tree.bzrdir.sprout('other', 'OTHER-id').open_workingtree()
43+ self.do_merge(this_tree, other_tree)
44+ if self.merge_type is _mod_merge.LCAMerger:
45+ self.expectFailure("lca merge doesn't track deleted lines",
46+ self.assertFileEqual,
47+ 'a\n'
48+ '<<<<<<< TREE\n'
49+ 'b2\n'
50+ '=======\n'
51+ '>>>>>>> MERGE-SOURCE\n'
52+ 'c\n'
53+ 'd\n'
54+ 'X\n'
55+ 'e\n', 'test/foo')
56+ else:
57+ self.assertFileEqual(
58+ 'a\n'
59+ '<<<<<<< TREE\n'
60+ 'b2\n'
61+ '=======\n'
62+ '>>>>>>> MERGE-SOURCE\n'
63+ 'c\n'
64+ 'd\n'
65+ 'X\n'
66+ 'e\n', 'test/foo')
67+
68
69 class TestMerge3Merge(TestCaseWithTransport, TestMergeImplementation):
70
71
72=== modified file 'bzrlib/tests/test_versionedfile.py'
73--- bzrlib/tests/test_versionedfile.py 2009-04-09 20:23:07 +0000
74+++ bzrlib/tests/test_versionedfile.py 2009-05-01 19:35:11 +0000
75@@ -1152,6 +1152,10 @@
76 """
77 result = """\
78 line 1
79+<<<<<<<\x20
80+ line 2
81+=======
82+>>>>>>>\x20
83 """
84 self._test_merge_from_strings(base, a, b, result)
85
86
87=== modified file 'bzrlib/versionedfile.py'
88--- bzrlib/versionedfile.py 2009-04-09 20:23:07 +0000
89+++ bzrlib/versionedfile.py 2009-05-01 19:35:11 +0000
90@@ -1403,9 +1403,13 @@
91 elif state == 'conflicted-b':
92 ch_b = ch_a = True
93 lines_b.append(line)
94+ elif state == 'killed-both':
95+ # This counts as a change, even though there is no associated
96+ # line
97+ ch_b = ch_a = True
98 else:
99 if state not in ('irrelevant', 'ghost-a', 'ghost-b',
100- 'killed-base', 'killed-both'):
101+ 'killed-base'):
102 raise AssertionError(state)
103 for struct in outstanding_struct():
104 yield struct