977
977
:return: 'this', 'other', or 'conflict' depending on whether an entry
980
# See doc/developers/lca_merge_resolution.txt for details about this
980
# See doc/developers/lca_tree_merging.txt for details about this
982
982
if other == this:
983
983
# Either Ambiguously clean, or nothing was actually changed. We
1119
1119
base_pair = contents_pair(self.base_tree)
1120
1120
other_pair = contents_pair(self.other_tree)
1121
# TODO: we could evaluate this only after evaluating base vs other vs
1122
# lcas, as at least some of the time it isn't needed
1123
this_pair = contents_pair(self.this_tree)
1124
1121
if self._lca_trees:
1122
this_pair = contents_pair(self.this_tree)
1125
1123
lca_pairs = [contents_pair(tree) for tree in self._lca_trees]
1126
1124
winner = self._lca_multi_way((base_pair, lca_pairs), other_pair,
1127
1125
this_pair, allow_overriding_lca=False)
1129
winner = self._three_way(base_pair, other_pair, this_pair)
1127
if base_pair == other_pair:
1130
# We delayed evaluating this_pair as long as we can to avoid
1131
# unnecessary sha1 calculation
1132
this_pair = contents_pair(self.this_tree)
1133
winner = self._three_way(base_pair, other_pair, this_pair)
1130
1134
if winner == 'this':
1131
1135
# No interesting changes introduced by OTHER
1132
1136
return "unmodified"
1133
1137
trans_id = self.tt.trans_id_file_id(file_id)
1134
1138
if winner == 'other':
1135
1139
# OTHER is a straight winner, so replace this contents with other
1136
if file_id in self.this_tree:
1140
file_in_this = file_id in self.this_tree
1137
1142
# Remove any existing contents
1138
1143
self.tt.delete_contents(trans_id)
1139
# XXX: why do we use file_id in self.other_tree, but then use
1140
1144
if file_id in self.other_tree:
1141
1145
# OTHER changed the file
1142
1146
create_from_tree(self.tt, trans_id,
1143
1147
self.other_tree, file_id)
1144
if file_id not in self.this_tree:
1148
if not file_in_this:
1145
1149
self.tt.version_file(file_id, trans_id)
1146
1150
return "modified"
1147
elif file_id in self.this_tree:
1148
1152
# OTHER deleted the file
1149
1153
self.tt.unversion_file(trans_id)
1150
1154
return "deleted"
1152
1156
# We have a hypothetical conflict, but if we have files, then we
1153
1157
# can try to merge the content
1154
assert winner == 'conflict'
1155
1158
if this_pair[0] == 'file' and other_pair[0] == 'file':
1156
1159
# THIS and OTHER are both files, so text merge. Either
1157
1160
# BASE is a file, or both converted to files, so at least we