~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-05 21:25:15 UTC
  • mto: (1946.2.8 reduce-knit-churn)
  • mto: This revision was merged to the branch mainline in revision 1988.
  • Revision ID: john@arbash-meinel.com-20060905212515-60abd5d7c8d6fb69
Switch over to Transport.append_bytes or append_files

Show diffs side-by-side

added added

removed removed

Lines of Context:
955
955
        self._file_mode=file_mode
956
956
 
957
957
    def write_header(self):
958
 
        if self._transport.append(self._filename, StringIO(self.HEADER),
 
958
        if self._transport.append_bytes(self._filename, self.HEADER,
959
959
            mode=self._file_mode):
960
960
            raise KnitCorrupt(self._filename, 'misaligned after writing header')
961
961
 
1247
1247
            assert isinstance(line, str), \
1248
1248
                'content must be utf-8 encoded: %r' % (line,)
1249
1249
            lines.append(line)
1250
 
        self._transport.append(self._filename, StringIO(''.join(lines)))
 
1250
        self._transport.append_bytes(self._filename, ''.join(lines))
1251
1251
        # cache after writing, so that a failed write leads to missing cache
1252
1252
        # entries not extra ones. XXX TODO: RBC 20060502 in the event of a 
1253
1253
        # failure, reload the index or flush it or some such, to prevent
1355
1355
        :return: the offset in the data file raw_data was written.
1356
1356
        """
1357
1357
        assert isinstance(raw_data, str), 'data must be plain bytes'
1358
 
        return self._transport.append(self._filename, StringIO(raw_data))
 
1358
        return self._transport.append_bytes(self._filename, raw_data)
1359
1359
        
1360
1360
    def add_record(self, version_id, digest, lines):
1361
1361
        """Write new text record to disk.  Returns the position in the
1362
1362
        file where it was written."""
1363
1363
        size, sio = self._record_to_data(version_id, digest, lines)
1364
1364
        # write to disk
1365
 
        start_pos = self._transport.append(self._filename, sio)
 
1365
        start_pos = self._transport.append_file(self._filename, sio)
1366
1366
        if self._do_cache:
1367
1367
            self._cache[version_id] = sio.getvalue()
1368
1368
        return start_pos, size