~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/index.py

  • Committer: Robert Collins
  • Date: 2007-07-12 15:47:29 UTC
  • mto: (2592.5.3 pack-repository)
  • mto: This revision was merged to the branch mainline in revision 2624.
  • Revision ID: robertc@robertcollins.net-20070712154729-ln0fpixap5lkcnsj
Make validate detect node reference parsing errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
class GraphIndex(object):
46
46
    """An index for data with embedded graphs.
47
 
    
 
47
 
 
48
    The index maps keys to a list of key reference lists, and a value.
 
49
    Each node has the same number of key reference lists. Each key reference
 
50
    list can be empty or an arbitrary length. The value is an opaque NULL
 
51
    terminated string.
48
52
    """
49
53
 
50
54
    def __init__(self, transport, name):
89
93
        signature = stream.read(len(self._signature()))
90
94
        if not signature == self._signature():
91
95
            raise errors.BadIndexFormatSignature(self._name, GraphIndex)
 
96
        options_line = stream.readline()
 
97
        if not options_line.startswith(_OPTION_NODE_REFS):
 
98
            raise errors.BadIndexOptions(self)
 
99
        try:
 
100
            node_ref_lists = int(options_line[len(_OPTION_NODE_REFS):-1])
 
101
        except ValueError:
 
102
            raise errors.BadIndexOptions(self)