/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/knitrepo.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-08-31 02:05:10 UTC
  • mfrom: (2670.3.8 vf-data-stream)
  • Revision ID: pqm@pqm.ubuntu.com-20070831020510-emrlta5dk6ta95zp
(Andrew Bennetts) Add get_data_stream, insert_data_stream and get_format_signature to KnitVersionedFile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
import bzrlib.revision as _mod_revision
38
38
from bzrlib.store.versioned import VersionedFileStore
39
39
from bzrlib.trace import mutter, note, warning
 
40
from bzrlib.util import bencode
40
41
 
41
42
 
42
43
class _KnitParentsProvider(object):
480
481
                                     _revision_store=_revision_store,
481
482
                                     control_store=control_store,
482
483
                                     text_store=text_store)
 
484
 
 
485
 
 
486
def _get_stream_as_bytes(knit, required_versions):
 
487
    """Generate a serialised data stream.
 
488
 
 
489
    The format is a bencoding of a list.  The first element of the list is a
 
490
    string of the format signature, then each subsequent element is a list
 
491
    corresponding to a record.  Those lists contain:
 
492
 
 
493
      * a version id
 
494
      * a list of options
 
495
      * a list of parents
 
496
      * the bytes
 
497
 
 
498
    :returns: a bencoded list.
 
499
    """
 
500
    knit_stream = knit.get_data_stream(required_versions)
 
501
    format_signature, data_list, callable = knit_stream
 
502
    data = []
 
503
    data.append(format_signature)
 
504
    for version, options, length, parents in data_list:
 
505
        data.append([version, options, parents, callable(length)])
 
506
    return bencode.bencode(data)
 
507