250
250
@decorators.cachedproperty
251
251
def base_lines(self):
252
252
"""The lines of the 'base' version of the file."""
253
return self._merger.get_lines(self._merger.base_tree, self.base_path, self.file_id)
253
return self._merger.get_lines(self._merger.base_tree, self.base_path)
255
255
@decorators.cachedproperty
256
256
def this_lines(self):
257
257
"""The lines of the 'this' version of the file."""
258
return self._merger.get_lines(self._merger.this_tree, self.this_path, self.file_id)
258
return self._merger.get_lines(self._merger.this_tree, self.this_path)
260
260
@decorators.cachedproperty
261
261
def other_lines(self):
262
262
"""The lines of the 'other' version of the file."""
263
return self._merger.get_lines(self._merger.other_tree, self.other_path, self.file_id)
263
return self._merger.get_lines(self._merger.other_tree, self.other_path)
266
266
class Merger(object):
1080
1080
self.working_tree.set_merge_modified(modified_hashes)
1083
def parent(entry, file_id):
1084
1084
"""Determine the parent for a file_id (used as a key method)"""
1085
1085
if entry is None:
1087
1087
return entry.parent_id
1090
def name(entry, file_id):
1091
1091
"""Determine the name for a file_id (used as a key method)"""
1092
1092
if entry is None:
1094
1094
return entry.name
1097
def contents_sha1(tree, path, file_id=None):
1097
def contents_sha1(tree, path):
1098
1098
"""Determine the sha1 of the file contents (used as a key method)."""
1100
return tree.get_file_sha1(path, file_id)
1100
return tree.get_file_sha1(path)
1101
1101
except errors.NoSuchFile:
1105
def executable(tree, path, file_id=None):
1105
def executable(tree, path):
1106
1106
"""Determine the executability of a file-id (used as a key method)."""
1108
if tree.kind(path, file_id) != "file":
1108
if tree.kind(path) != "file":
1110
1110
except errors.NoSuchFile:
1112
1112
return tree.is_executable(path)
1115
def kind(tree, path, file_id=None):
1115
def kind(tree, path):
1116
1116
"""Determine the kind of a file-id (used as a key method)."""
1118
return tree.kind(path, file_id)
1118
return tree.kind(path)
1119
1119
except errors.NoSuchFile:
1401
1401
return 'not_applicable', None
1403
def get_lines(self, tree, path, file_id=None):
1403
def get_lines(self, tree, path):
1404
1404
"""Return the lines in a file, or an empty list."""
1405
1405
if path is None:
1704
1704
requires_file_merge_plan = False
1706
def dump_file(self, temp_dir, name, tree, path, file_id=None):
1706
def dump_file(self, temp_dir, name, tree, path):
1707
1707
out_path = osutils.pathjoin(temp_dir, name)
1708
1708
with open(out_path, "wb") as out_file:
1709
1709
in_file = tree.get_file(path)
1723
1723
new_file = osutils.pathjoin(temp_dir, "new")
1724
1724
this = self.dump_file(
1725
temp_dir, "this", self.this_tree, this_path, file_id)
1725
temp_dir, "this", self.this_tree, this_path)
1726
1726
base = self.dump_file(
1727
temp_dir, "base", self.base_tree, base_path, file_id)
1727
temp_dir, "base", self.base_tree, base_path)
1728
1728
other = self.dump_file(
1729
temp_dir, "other", self.other_tree, other_path, file_id)
1729
temp_dir, "other", self.other_tree, other_path)
1730
1730
status = breezy.patch.diff3(new_file, this, base, other)
1731
1731
if status not in (0, 1):
1732
1732
raise errors.BzrError("Unhandled diff3 exit code")