703
703
def snapshot(self, revision, path, previous_entries,
704
704
work_tree, commit_builder):
705
705
"""See InventoryEntry.snapshot."""
706
# We have a custom implementation of this for files because it's
707
# performance critical.
706
# Note: We use a custom implementation of this method for files
707
# because it's a performance critical part of commit.
709
# If this is the initial commit for this file, we know the sha is
710
# coming later so skip caluculating it now (in _read_tree_state())
708
711
if len(previous_entries) == 0:
709
# Initial commit so we know the sha is coming later
710
712
self.executable = work_tree.is_executable(self.file_id, path=path)
712
714
self._read_tree_state(path, work_tree)
713
if len(previous_entries) == 1:
714
parent_ie = previous_entries.values()[0]
715
if self._unchanged(parent_ie):
716
self.revision = parent_ie.revision
716
# If nothing is changed from the sole parent, there's nothing to do
717
if len(previous_entries) == 1:
718
parent_ie = previous_entries.values()[0]
719
if self._unchanged(parent_ie):
720
self.revision = parent_ie.revision
723
# Add the file to the repository
718
724
self.revision = revision
719
725
def get_content_byte_lines():
720
726
return work_tree.get_file(self.file_id, path).readlines()