Rev 3953: merge jam fix in lp:~bzr/bzr/1.12-lca-deleted
Vincent Ladeuil
v.ladeuil+lp at free.fr
Fri Jan 23 19:40:40 GMT 2009
At lp:~bzr/bzr/1.12-lca-deleted
------------------------------------------------------------
revno: 3953
revision-id: v.ladeuil+lp at free.fr-20090123194036-y35ps7a7xghq3q31
parent: v.ladeuil+lp at free.fr-20090123095303-gvzd86p6p2ytmhxz
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: spurious-conflicts
timestamp: Fri 2009-01-23 20:40:36 +0100
message:
merge jam fix
-------------- next part --------------
=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py 2009-01-21 10:33:02 +0000
+++ b/bzrlib/merge.py 2009-01-23 19:40:36 +0000
@@ -1118,33 +1118,41 @@
# file kind...
base_pair = contents_pair(self.base_tree)
other_pair = contents_pair(self.other_tree)
- if base_pair == other_pair:
- # OTHER introduced no changes
- return "unmodified"
+ # TODO: we could evaluate this only after evaluating base vs other vs
+ # lcas, as at least some of the time it isn't needed
this_pair = contents_pair(self.this_tree)
- if this_pair == other_pair:
- # THIS and OTHER introduced the same changes
+ if self._lca_trees:
+ lca_pairs = [contents_pair(tree) for tree in self._lca_trees]
+ winner = self._lca_multi_way((base_pair, lca_pairs), other_pair,
+ this_pair, allow_overriding_lca=False)
+ else:
+ winner = self._three_way(base_pair, other_pair, this_pair)
+ if winner == 'this':
+ # No interesting changes introduced by OTHER
return "unmodified"
+ trans_id = self.tt.trans_id_file_id(file_id)
+ if winner == 'other':
+ # OTHER is a straight winner, so replace this contents with other
+ if file_id in self.this_tree:
+ # Remove any existing contents
+ self.tt.delete_contents(trans_id)
+ # XXX: why do we use file_id in self.other_tree, but then use
+ if file_id in self.other_tree:
+ # OTHER changed the file
+ create_from_tree(self.tt, trans_id,
+ self.other_tree, file_id)
+ if file_id not in self.this_tree:
+ self.tt.version_file(file_id, trans_id)
+ return "modified"
+ elif file_id in self.this_tree:
+ # OTHER deleted the file
+ self.tt.unversion_file(trans_id)
+ return "deleted"
else:
- trans_id = self.tt.trans_id_file_id(file_id)
- if this_pair == base_pair:
- # only OTHER introduced changes
- if file_id in self.this_tree:
- # Remove any existing contents
- self.tt.delete_contents(trans_id)
- if file_id in self.other_tree:
- # OTHER changed the file
- create_from_tree(self.tt, trans_id,
- self.other_tree, file_id)
- if file_id not in self.this_tree:
- self.tt.version_file(file_id, trans_id)
- return "modified"
- elif file_id in self.this_tree.inventory:
- # OTHER deleted the file
- self.tt.unversion_file(trans_id)
- return "deleted"
- #BOTH THIS and OTHER introduced changes; scalar conflict
- elif this_pair[0] == "file" and other_pair[0] == "file":
+ # We have a hypothetical conflict, but if we have files, then we
+ # can try to merge the content
+ assert winner == 'conflict'
+ if this_pair[0] == 'file' and other_pair[0] == 'file':
# THIS and OTHER are both files, so text merge. Either
# BASE is a file, or both converted to files, so at least we
# have agreement that output should be a file.
@@ -1161,7 +1169,6 @@
pass
return "modified"
else:
- # Scalar conflict, can't text merge. Dump conflicts
return contents_conflict()
def get_lines(self, tree, file_id):
=== modified file 'bzrlib/tests/test_merge.py'
--- a/bzrlib/tests/test_merge.py 2009-01-23 09:53:03 +0000
+++ b/bzrlib/tests/test_merge.py 2009-01-23 19:40:36 +0000
@@ -2421,8 +2421,7 @@
# TODO: We need to use the per-file graph to properly select a BASE
# before this will work. Or at least use the LCA trees to find
# the appropriate content base. (which is B, not A).
- self.expectFailure("Merge3Merger doesn't recognize reverted content",
- self.assertEqual, 'base content\n', wt.get_file_text('foo-id'))
+ self.assertEqual('base content\n', wt.get_file_text('foo-id'))
def test_other_modified_content(self):
builder = self.get_builder()
@@ -2438,8 +2437,6 @@
[('modify', ('foo-id', 'F content\n'))]) # Override B content
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
wt, conflicts = self.do_merge(builder, 'F-id')
- self.expectFailure("Merge3Merger only uses BASE for content",
- self.assertEqual, 'F content\n', wt.get_file_text('foo-id'))
self.assertEqual(0, conflicts)
self.assertEqual('F content\n', wt.get_file_text('foo-id'))
More information about the bazaar-commits
mailing list