~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Robert Collins
  • Date: 2007-09-03 02:58:58 UTC
  • mto: (2592.3.122 repository)
  • mto: This revision was merged to the branch mainline in revision 2791.
  • Revision ID: robertc@robertcollins.net-20070903025858-k2pxq3qz6ulhhtgq
 * The ``add_lines`` methods on ``VersionedFile`` implementations has changed
   its return value to include the sha1 and length of the inserted text. This
   allows the avoidance of double-sha1 calculations during commit.
   (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
419
419
    def _add_lines(self, version_id, parents, lines, parent_texts,
420
420
                   left_matching_blocks=None):
421
421
        """See VersionedFile.add_lines."""
422
 
        return self._add(version_id, lines, map(self._lookup, parents))
 
422
        idx = self._add(version_id, lines, map(self._lookup, parents))
 
423
        return sha_strings(lines), sum(map(len, lines)), idx
423
424
 
424
425
    def _add(self, version_id, lines, parents, sha1=None):
425
426
        """Add a single text on top of the weave.
491
492
        # another small special case: a merge, producing the same text
492
493
        # as auto-merge
493
494
        if lines == basis_lines:
494
 
            return new_version            
 
495
            return new_version
495
496
 
496
497
        # add a sentinel, because we can also match against the final line
497
498
        basis_lineno.append(len(self._weave))