~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 11:24:54 UTC
  • mto: (2592.5.3 pack-repository)
  • mto: This revision was merged to the branch mainline in revision 2624.
  • Revision ID: robertc@robertcollins.net-20070713112454-dsj464911g0l8wpa
Absent entries are not yeilded.

Show diffs side-by-side

added added

removed removed

Lines of Context:
170
170
    Each node has the same number of key reference lists. Each key reference
171
171
    list can be empty or an arbitrary length. The value is an opaque NULL
172
172
    terminated string without any newlines.
 
173
 
 
174
    It is presumed that the index will not be mutated - it is static data.
173
175
    """
174
176
 
175
177
    def __init__(self, transport, name):
191
193
        stream = self._transport.get(self._name)
192
194
        self._read_prefix(stream)
193
195
        line_count = 0
194
 
        keys_by_offset = {}
 
196
        self.keys_by_offset = {}
195
197
        trailers = 0
196
198
        pos = stream.tell()
197
199
        for line in stream.readlines():
205
207
                    int(ref) for ref in ref_string.split('\r') if ref
206
208
                    ]))
207
209
            ref_lists = tuple(ref_lists)
208
 
            keys_by_offset[pos] = (key, absent, ref_lists, value)
 
210
            self.keys_by_offset[pos] = (key, absent, ref_lists, value)
209
211
            pos += len(line)
210
 
        for key, absent, references, value in keys_by_offset.values():
 
212
        for key, absent, references, value in self.keys_by_offset.values():
 
213
            if absent:
 
214
                continue
211
215
            # resolve references:
212
216
            if self.node_ref_lists:
213
217
                node_refs = []
214
218
                for ref_list in references:
215
 
                    node_refs.append(tuple([keys_by_offset[ref][0] for ref in ref_list]))
 
219
                    node_refs.append(tuple([self.keys_by_offset[ref][0] for ref in ref_list]))
216
220
                node_refs = tuple(node_refs)
217
221
            else:
218
222
                node_refs = ()