~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-02 18:59:18 UTC
  • mto: This revision was merged to the branch mainline in revision 4469.
  • Revision ID: john@arbash-meinel.com-20090602185918-86l9eljnn8z2iljk
Add a VersionedFile.add_text() api.

Similar to VF.add_lines() except it takes a string for the content, rather
than a list of lines.

For now, it just thunks over to VF.add_lines(), but it will be special
cased in the future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
745
745
                        entry.executable = True
746
746
                    else:
747
747
                        entry.executable = False
748
 
                    if (carry_over_possible and 
 
748
                    if (carry_over_possible and
749
749
                        parent_entry.executable == entry.executable):
750
750
                            # Check the file length, content hash after reading
751
751
                            # the file.
754
754
                        nostore_sha = None
755
755
                    file_obj, stat_value = tree.get_file_with_stat(file_id, change[1][1])
756
756
                    try:
757
 
                        lines = file_obj.readlines()
 
757
                        text = file_obj.read()
758
758
                    finally:
759
759
                        file_obj.close()
760
760
                    try:
761
761
                        entry.text_sha1, entry.text_size = self._add_text_to_weave(
762
 
                            file_id, lines, heads, nostore_sha)
 
762
                            file_id, text, heads, nostore_sha)
763
763
                        yield file_id, change[1][1], (entry.text_sha1, stat_value)
764
764
                    except errors.ExistingContent:
765
765
                        # No content change against a carry_over parent
818
818
            self._require_root_change(tree)
819
819
        self.basis_delta_revision = basis_revision_id
820
820
 
821
 
    def _add_text_to_weave(self, file_id, new_lines, parents, nostore_sha):
 
821
    def _add_text_to_weave(self, file_id, new_text, parents, nostore_sha):
822
822
        # Note: as we read the content directly from the tree, we know its not
823
823
        # been turned into unicode or badly split - but a broken tree
824
824
        # implementation could give us bad output from readlines() so this is
825
825
        # not a guarantee of safety. What would be better is always checking
826
826
        # the content during test suite execution. RBC 20070912
827
827
        parent_keys = tuple((file_id, parent) for parent in parents)
828
 
        return self.repository.texts.add_lines(
829
 
            (file_id, self._new_revision_id), parent_keys, new_lines,
 
828
        return self.repository.texts.add_text(
 
829
            (file_id, self._new_revision_id), parent_keys, new_text,
830
830
            nostore_sha=nostore_sha, random_id=self.random_revid,
831
831
            check_content=False)[0:2]
832
832