~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/index.py

  • Committer: Robert Collins
  • Date: 2007-07-13 07:22:42 UTC
  • mto: (2592.5.3 pack-repository)
  • mto: This revision was merged to the branch mainline in revision 2624.
  • Revision ID: robertc@robertcollins.net-20070713072242-vgf4mkayfyjk6zy0
Node references are tab separated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    NODE           := KEY NULL ABSENT? NULL REFERENCES NULL VALUE NEWLINE
42
42
    KEY            := Not-whitespace-utf8
43
43
    ABSENT         := 'a'
44
 
    REFERENCES     := (REFERENCE_LIST TAB) {node_ref_lists}
45
 
    REFERENCE_LIST := (KEY (CR KEY)*)?
 
44
    REFERENCES     := REFERENCE_LIST (TAB REFERENCE_LIST){node_ref_lists - 1}
 
45
    REFERENCE_LIST := (REFERENCE (CR REFERENCE)*)?
 
46
    REFERENCE      := DIGITS  ; digits is the byte offset in the index of the
 
47
                              ; referenced key.
46
48
    VALUE          := no-newline-no-null-bytes
47
49
    """
48
50
 
82
84
        lines = [_SIGNATURE]
83
85
        lines.append(_OPTION_NODE_REFS + str(self.reference_lists) + '\n')
84
86
        for key, (references, value) in sorted(self._nodes.items(),reverse=True):
85
 
            flattened_references = ''
86
 
            lines.append("%s\0\0%s\0%s\n" % (key, flattened_references, value))
 
87
            flattened_references = []
 
88
            for ref_list in references:
 
89
                flattened_references.append('')
 
90
            lines.append("%s\0\0%s\0%s\n" % (key,
 
91
                '\t'.join(flattened_references), value))
87
92
        lines.append('\n')
88
93
        return StringIO(''.join(lines))
89
94