~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Robert Collins
  • Date: 2007-09-03 03:03:26 UTC
  • mto: (2592.3.122 repository)
  • mto: This revision was merged to the branch mainline in revision 2791.
  • Revision ID: robertc@robertcollins.net-20070903030326-xam93hxlthc6l37w
Don't double-calculate the text sha1 during commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2260
2260
            and text_sha1 == file_parents.values()[0].text_sha1
2261
2261
            and text_size == file_parents.values()[0].text_size):
2262
2262
            previous_ie = file_parents.values()[0]
2263
 
            versionedfile = self.repository.weave_store.get_weave(file_id, 
 
2263
            versionedfile = self.repository.weave_store.get_weave(file_id,
2264
2264
                self.repository.get_transaction())
2265
 
            versionedfile.clone_text(self._new_revision_id, 
 
2265
            versionedfile.clone_text(self._new_revision_id,
2266
2266
                previous_ie.revision, file_parents.keys())
2267
2267
            return text_sha1, text_size
2268
2268
        else:
2269
2269
            new_lines = get_content_byte_lines()
2270
 
            # TODO: Rather than invoking sha_strings here, _add_text_to_weave
2271
 
            # should return the SHA1 and size
2272
 
            self._add_text_to_weave(file_id, new_lines, file_parents.keys())
2273
 
            return osutils.sha_strings(new_lines), \
2274
 
                sum(map(len, new_lines))
 
2270
            return self._add_text_to_weave(file_id, new_lines,
 
2271
                file_parents.keys())
2275
2272
 
2276
2273
    def modified_link(self, file_id, file_parents, link_target):
2277
2274
        """Record the presence of a symbolic link.
2285
2282
    def _add_text_to_weave(self, file_id, new_lines, parents):
2286
2283
        versionedfile = self.repository.weave_store.get_weave_or_empty(
2287
2284
            file_id, self.repository.get_transaction())
2288
 
        versionedfile.add_lines(self._new_revision_id, parents, new_lines)
 
2285
        result = versionedfile.add_lines(
 
2286
            self._new_revision_id, parents, new_lines)[0:2]
2289
2287
        versionedfile.clear_cache()
 
2288
        return result
2290
2289
 
2291
2290
 
2292
2291
class _CommitBuilder(CommitBuilder):