~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-12-11 20:23:00 UTC
  • mfrom: (3890.2.18 get_record_stream_chunked)
  • Revision ID: pqm@pqm.ubuntu.com-20081211202300-6dz1vo3phfsc23pj
(jam) Add ContentFactory.get_bytes_as('chunked') and
        osutils.chunks_to_lines()

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
from bzrlib import tsort
80
80
""")
81
81
from bzrlib import (
 
82
    errors,
 
83
    osutils,
82
84
    progress,
83
85
    )
84
86
from bzrlib.errors import (WeaveError, WeaveFormatError, WeaveParentMismatch,
88
90
        WeaveRevisionAlreadyPresent,
89
91
        WeaveRevisionNotPresent,
90
92
        )
91
 
import bzrlib.errors as errors
92
93
from bzrlib.osutils import dirname, sha, sha_strings, split_lines
93
94
import bzrlib.patiencediff
94
95
from bzrlib.revision import NULL_REVISION
122
123
    def get_bytes_as(self, storage_kind):
123
124
        if storage_kind == 'fulltext':
124
125
            return self._weave.get_text(self.key[-1])
 
126
        elif storage_kind == 'chunked':
 
127
            return self._weave.get_lines(self.key[-1])
125
128
        else:
126
129
            raise UnavailableRepresentation(self.key, storage_kind, 'fulltext')
127
130
 
357
360
                raise RevisionNotPresent([record.key[0]], self)
358
361
            # adapt to non-tuple interface
359
362
            parents = [parent[0] for parent in record.parents]
360
 
            if record.storage_kind == 'fulltext':
 
363
            if (record.storage_kind == 'fulltext'
 
364
                or record.storage_kind == 'chunked'):
361
365
                self.add_lines(record.key[0], parents,
362
 
                    split_lines(record.get_bytes_as('fulltext')))
 
366
                    osutils.chunks_to_lines(record.get_bytes_as('chunked')))
363
367
            else:
364
368
                adapter_key = record.storage_kind, 'fulltext'
365
369
                try: