~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Ian Clatworthy
  • Author(s): Robert Collins
  • Date: 2009-04-03 05:08:45 UTC
  • mfrom: (4241.4.1 bzr.bris-vf)
  • mto: This revision was merged to the branch mainline in revision 4245.
  • Revision ID: ian.clatworthy@canonical.com-20090403050845-w656xtmr19jtuovs
add sha generation support to versioned files (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
955
955
                lines[-1] = lines[-1] + '\n'
956
956
                line_bytes += '\n'
957
957
 
958
 
        for element in key:
 
958
        for element in key[:-1]:
959
959
            if type(element) != str:
960
960
                raise TypeError("key contains non-strings: %r" % (key,))
 
961
        if key[-1] is None:
 
962
            key = key[:-1] + ('sha1:' + digest,)
 
963
        elif type(key[-1]) != str:
 
964
                raise TypeError("key contains non-strings: %r" % (key,))
961
965
        # Knit hunks are still last-element only
962
966
        version_id = key[-1]
963
967
        content = self._factory.make(lines, version_id)
1022
1026
    def _check_add(self, key, lines, random_id, check_content):
1023
1027
        """check that version_id and lines are safe to add."""
1024
1028
        version_id = key[-1]
1025
 
        if contains_whitespace(version_id):
1026
 
            raise InvalidRevisionId(version_id, self)
1027
 
        self.check_not_reserved_id(version_id)
 
1029
        if version_id is not None:
 
1030
            if contains_whitespace(version_id):
 
1031
                raise InvalidRevisionId(version_id, self)
 
1032
            self.check_not_reserved_id(version_id)
1028
1033
        # TODO: If random_id==False and the key is already present, we should
1029
1034
        # probably check that the existing content is identical to what is
1030
1035
        # being inserted, and otherwise raise an exception.  This would make