~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/index.py

  • Committer: Vincent Ladeuil
  • Date: 2011-05-26 20:30:53 UTC
  • mfrom: (5920 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5924.
  • Revision ID: v.ladeuil+lp@free.fr-20110526203053-hbjn6yuzwg03wnuv
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
class GraphIndexBuilder(object):
71
71
    """A builder that can build a GraphIndex.
72
72
 
73
 
    The resulting graph has the structure:
 
73
    The resulting graph has the structure::
74
74
 
75
 
    _SIGNATURE OPTIONS NODES NEWLINE
76
 
    _SIGNATURE     := 'Bazaar Graph Index 1' NEWLINE
77
 
    OPTIONS        := 'node_ref_lists=' DIGITS NEWLINE
78
 
    NODES          := NODE*
79
 
    NODE           := KEY NULL ABSENT? NULL REFERENCES NULL VALUE NEWLINE
80
 
    KEY            := Not-whitespace-utf8
81
 
    ABSENT         := 'a'
82
 
    REFERENCES     := REFERENCE_LIST (TAB REFERENCE_LIST){node_ref_lists - 1}
83
 
    REFERENCE_LIST := (REFERENCE (CR REFERENCE)*)?
84
 
    REFERENCE      := DIGITS  ; digits is the byte offset in the index of the
85
 
                              ; referenced key.
86
 
    VALUE          := no-newline-no-null-bytes
 
75
      _SIGNATURE OPTIONS NODES NEWLINE
 
76
      _SIGNATURE     := 'Bazaar Graph Index 1' NEWLINE
 
77
      OPTIONS        := 'node_ref_lists=' DIGITS NEWLINE
 
78
      NODES          := NODE*
 
79
      NODE           := KEY NULL ABSENT? NULL REFERENCES NULL VALUE NEWLINE
 
80
      KEY            := Not-whitespace-utf8
 
81
      ABSENT         := 'a'
 
82
      REFERENCES     := REFERENCE_LIST (TAB REFERENCE_LIST){node_ref_lists - 1}
 
83
      REFERENCE_LIST := (REFERENCE (CR REFERENCE)*)?
 
84
      REFERENCE      := DIGITS  ; digits is the byte offset in the index of the
 
85
                                ; referenced key.
 
86
      VALUE          := no-newline-no-null-bytes
87
87
    """
88
88
 
89
89
    def __init__(self, reference_lists=0, key_elements=1):
185
185
        :param value: The value associate with this key. Must not contain
186
186
            newlines or null characters.
187
187
        :return: (node_refs, absent_references)
188
 
            node_refs   basically a packed form of 'references' where all
189
 
                        iterables are tuples
190
 
            absent_references   reference keys that are not in self._nodes.
191
 
                                This may contain duplicates if the same key is
192
 
                                referenced in multiple lists.
 
188
        
 
189
            * node_refs: basically a packed form of 'references' where all
 
190
              iterables are tuples
 
191
            * absent_references: reference keys that are not in self._nodes.
 
192
              This may contain duplicates if the same key is referenced in
 
193
              multiple lists.
193
194
        """
194
195
        as_st = StaticTuple.from_sequence
195
196
        self._check_key(key)
220
221
        :param references: An iterable of iterables of keys. Each is a
221
222
            reference to another key.
222
223
        :param value: The value to associate with the key. It may be any
223
 
            bytes as long as it does not contain \0 or \n.
 
224
            bytes as long as it does not contain \\0 or \\n.
224
225
        """
225
226
        (node_refs,
226
227
         absent_references) = self._check_key_ref_value(key, references, value)