~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_btree_serializer_pyx.pyx

  • Committer: Andrew Bennetts
  • Date: 2009-10-02 05:43:41 UTC
  • mfrom: (4634.52.10 2.0)
  • mto: This revision was merged to the branch mainline in revision 4723.
  • Revision ID: andrew.bennetts@canonical.com-20091002054341-99yxpjenx8cagpxn
Merge lp:bzr/2.0 into lp:bzr, duplicating relevant NEWS entries for 2.1.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
188
188
            # And the next string is right after it
189
189
            self._cur_str = last + 1
190
190
            # The last character is right before the '\n'
191
 
            last = last
192
191
 
193
192
        if last == self._start:
194
193
            # parsed it all.
195
194
            return 0
196
195
        if last < self._start:
197
196
            # Unexpected error condition - fail
198
 
            return -1
 
197
            raise AssertionError("last < self._start")
199
198
        if 0 == self._header_found:
200
199
            # The first line in a leaf node is the header "type=leaf\n"
201
200
            if strncmp("type=leaf", self._start, last - self._start) == 0:
204
203
            else:
205
204
                raise AssertionError('Node did not start with "type=leaf": %r'
206
205
                    % (safe_string_from_size(self._start, last - self._start)))
207
 
                return -1
208
206
 
209
207
        key = self.extract_key(last)
210
208
        # find the value area
211
209
        temp_ptr = <char*>_my_memrchr(self._start, c'\0', last - self._start)
212
210
        if temp_ptr == NULL:
213
211
            # Invalid line
214
 
            return -1
 
212
            raise AssertionError("Failed to find the value area")
215
213
        else:
216
214
            # capture the value string
217
215
            value = safe_string_from_size(temp_ptr + 1, last - temp_ptr - 1)
225
223
                # extract a reference list
226
224
                loop_counter = loop_counter + 1
227
225
                if last < self._start:
228
 
                    return -1
 
226
                    raise AssertionError("last < self._start")
229
227
                # find the next reference list end point:
230
228
                temp_ptr = <char*>memchr(self._start, c'\t', last - self._start)
231
229
                if temp_ptr == NULL:
232
230
                    # Only valid for the last list
233
231
                    if loop_counter != self.ref_list_length:
234
232
                        # Invalid line
235
 
                        return -1
236
 
                        raise AssertionError("invalid key")
 
233
                        raise AssertionError(
 
234
                            "invalid key, loop_counter != self.ref_list_length")
237
235
                    else:
238
236
                        # scan to the end of the ref list area
239
237
                        ref_ptr = last
259
257
        else:
260
258
            if last != self._start:
261
259
                # unexpected reference data present
262
 
                return -1
 
260
                raise AssertionError("unexpected reference data present")
263
261
            node_value = (value, ())
264
262
        PyList_Append(self.keys, (key, node_value))
265
263
        return 0