/* Generated by Pyrex 0.9.6.4 on Wed Aug 13 14:40:05 2008 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
#endif
#ifndef WIN32
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#include "stdlib.h"
#include "string.h"


typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/

static PyObject *__pyx_m;
static PyObject *__pyx_b;
static int __pyx_lineno;
static char *__pyx_filename;
static char **__pyx_f;

static char __pyx_mdoc[] = "Pyrex extensions to knit parsing.";

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static void __Pyx_WriteUnraisable(char *name); /*proto*/

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static void __Pyx_AddTraceback(char *funcname); /*proto*/

/* Declarations from _knit_load_data_c */

struct __pyx_obj_17_knit_load_data_c_KnitIndexReader {
  PyObject_HEAD
  struct __pyx_vtabstruct_17_knit_load_data_c_KnitIndexReader *__pyx_vtab;
  PyObject *kndx;
  PyObject *fp;
  PyObject *cache;
  PyObject *history;
  char *cur_str;
  char *end_str;
  int history_len;
};


struct __pyx_vtabstruct_17_knit_load_data_c_KnitIndexReader {
  void (*validate)(struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *);
  PyObject *(*process_options)(struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *,char *,char *);
  PyObject *(*process_parents)(struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *,char *,char *);
  int (*process_one_record)(struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *,char *,char *);
  int (*process_next_record)(struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *);
};
static struct __pyx_vtabstruct_17_knit_load_data_c_KnitIndexReader *__pyx_vtabptr_17_knit_load_data_c_KnitIndexReader;

static PyTypeObject *__pyx_ptype_17_knit_load_data_c_KnitIndexReader = 0;
static int __pyx_f_17_knit_load_data_c_string_to_int_safe(char *,char *,int *); /*proto*/


/* Implementation of _knit_load_data_c */


static PyObject *__pyx_n_sys;
static PyObject *__pyx_n_bzrlib;
static PyObject *__pyx_n_errors;

static PyObject *__pyx_n_ValueError;

static PyObject *__pyx_k4p;

static char __pyx_k4[] = "%r is not a valid integer";

static int __pyx_f_17_knit_load_data_c_string_to_int_safe(char *__pyx_v_s,char *__pyx_v_end,int *__pyx_v_out) {
  char *__pyx_v_integer_end;
  PyObject *__pyx_v_py_s;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_py_s = Py_None; Py_INCREF(Py_None);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":69 */
  (__pyx_v_out[0]) = ((int)strtol(__pyx_v_s,(&__pyx_v_integer_end),10));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":70 */
  __pyx_1 = (__pyx_v_integer_end != __pyx_v_end);
  if (__pyx_1) {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":71 */
    __pyx_2 = PyString_FromStringAndSize(__pyx_v_s,(__pyx_v_end - __pyx_v_s)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
    Py_DECREF(__pyx_v_py_s);
    __pyx_v_py_s = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":72 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
    Py_INCREF(__pyx_v_py_s);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_py_s);
    __pyx_4 = PyNumber_Remainder(__pyx_k4p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":73 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_knit_load_data_c.string_to_int_safe");
  __pyx_r = (-1);
  __pyx_L0:;
  Py_DECREF(__pyx_v_py_s);
  return __pyx_r;
}

static PyObject *__pyx_n__cache;
static PyObject *__pyx_n__history;

static int __pyx_f_17_knit_load_data_c_15KnitIndexReader___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_17_knit_load_data_c_15KnitIndexReader___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_kndx = 0;
  PyObject *__pyx_v_fp = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"kndx","fp",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_kndx, &__pyx_v_fp)) return -1;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_kndx);
  Py_INCREF(__pyx_v_fp);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":90 */
  Py_INCREF(__pyx_v_kndx);
  Py_DECREF(((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->kndx);
  ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->kndx = __pyx_v_kndx;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":91 */
  Py_INCREF(__pyx_v_fp);
  Py_DECREF(((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->fp);
  ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->fp = __pyx_v_fp;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":93 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_kndx, __pyx_n__cache); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->cache);
  ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->cache = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":94 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_kndx, __pyx_n__history); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->history);
  ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->history = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":96 */
  ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->cur_str = NULL;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":97 */
  ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->end_str = NULL;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":98 */
  ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->history_len = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_knit_load_data_c.KnitIndexReader.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_kndx);
  Py_DECREF(__pyx_v_fp);
  return __pyx_r;
}

static PyObject *__pyx_n_TypeError;

static PyObject *__pyx_k5p;
static PyObject *__pyx_k6p;

static char __pyx_k5[] = "kndx._cache must be a python dict";
static char __pyx_k6[] = "kndx._history must be a python list";

static void __pyx_f_17_knit_load_data_c_15KnitIndexReader_validate(struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *__pyx_v_self) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":101 */
  __pyx_1 = (!PyDict_CheckExact(__pyx_v_self->cache));
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;}
    Py_INCREF(__pyx_k5p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k5p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":103 */
  __pyx_1 = (!PyList_CheckExact(__pyx_v_self->history));
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;}
    Py_INCREF(__pyx_k6p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k6p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_knit_load_data_c.KnitIndexReader.validate");
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
}

static PyObject *__pyx_f_17_knit_load_data_c_15KnitIndexReader_process_options(struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *__pyx_v_self,char *__pyx_v_option_str,char *__pyx_v_end) {
  char *__pyx_v_next;
  PyObject *__pyx_v_final_options;
  PyObject *__pyx_v_next_option;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_INCREF(__pyx_v_self);
  __pyx_v_final_options = Py_None; Py_INCREF(Py_None);
  __pyx_v_next_option = Py_None; Py_INCREF(Py_None);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":118 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;}
  Py_DECREF(__pyx_v_final_options);
  __pyx_v_final_options = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":120 */
  while (1) {
    __pyx_2 = (__pyx_v_option_str < __pyx_v_end);
    if (!__pyx_2) break;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":121 */
    __pyx_v_next = ((char *)memchr(__pyx_v_option_str,',',(__pyx_v_end - __pyx_v_option_str)));

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":122 */
    __pyx_2 = (__pyx_v_next == NULL);
    if (__pyx_2) {
      __pyx_v_next = __pyx_v_end;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":124 */
    __pyx_1 = PyString_FromStringAndSize(__pyx_v_option_str,(__pyx_v_next - __pyx_v_option_str)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
    Py_DECREF(__pyx_v_next_option);
    __pyx_v_next_option = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":126 */
    __pyx_2 = PyList_Append(__pyx_v_final_options,__pyx_v_next_option); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":129 */
    __pyx_v_option_str = (__pyx_v_next + 1);
  }

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":131 */
  Py_INCREF(__pyx_v_final_options);
  __pyx_r = __pyx_v_final_options;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_knit_load_data_c.KnitIndexReader.process_options");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_final_options);
  Py_DECREF(__pyx_v_next_option);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_IndexError;
static PyObject *__pyx_n_tuple;

static PyObject *__pyx_k7p;

static char __pyx_k7[] = "Parent index refers to a revision which does not exist yet. %d > %d";

static PyObject *__pyx_f_17_knit_load_data_c_15KnitIndexReader_process_parents(struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *__pyx_v_self,char *__pyx_v_parent_str,char *__pyx_v_end) {
  char *__pyx_v_next;
  int __pyx_v_int_parent;
  PyObject *__pyx_v_parents;
  PyObject *__pyx_v_parent;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_parents = Py_None; Py_INCREF(Py_None);
  __pyx_v_parent = Py_None; Py_INCREF(Py_None);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":150 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;}
  Py_DECREF(__pyx_v_parents);
  __pyx_v_parents = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":151 */
  while (1) {
    __pyx_2 = (__pyx_v_parent_str <= __pyx_v_end);
    if (!__pyx_2) break;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":152 */
    __pyx_v_next = ((char *)memchr(__pyx_v_parent_str,' ',(__pyx_v_end - __pyx_v_parent_str)));

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":153 */
    __pyx_2 = (__pyx_v_next == NULL);
    if (!__pyx_2) {
      __pyx_2 = (__pyx_v_next >= __pyx_v_end);
      if (!__pyx_2) {
        __pyx_2 = (__pyx_v_next == __pyx_v_parent_str);
      }
    }
    if (__pyx_2) {
      goto __pyx_L3;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":156 */
    __pyx_2 = ((__pyx_v_parent_str[0]) == '.');
    if (__pyx_2) {

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":158 */
      __pyx_v_parent_str = (__pyx_v_parent_str + 1);

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":159 */
      __pyx_1 = PyString_FromStringAndSize(__pyx_v_parent_str,(__pyx_v_next - __pyx_v_parent_str)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}
      Py_DECREF(__pyx_v_parent);
      __pyx_v_parent = __pyx_1;
      __pyx_1 = 0;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":163 */
      __pyx_2 = __pyx_f_17_knit_load_data_c_string_to_int_safe(__pyx_v_parent_str,__pyx_v_next,(&__pyx_v_int_parent)); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; goto __pyx_L1;}

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":165 */
      __pyx_2 = (__pyx_v_int_parent >= __pyx_v_self->history_len);
      if (__pyx_2) {
        __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_IndexError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; goto __pyx_L1;}
        __pyx_3 = PyInt_FromLong(__pyx_v_int_parent); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L1;}
        __pyx_4 = PyInt_FromLong(__pyx_v_self->history_len); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L1;}
        __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
        PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
        __pyx_3 = 0;
        __pyx_4 = 0;
        __pyx_3 = PyNumber_Remainder(__pyx_k7p, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L1;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
        __pyx_3 = 0;
        __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __Pyx_Raise(__pyx_5, 0, 0);
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; goto __pyx_L1;}
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":169 */
      __pyx_3 = PyList_GET_ITEM(__pyx_v_self->history,__pyx_v_int_parent); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; goto __pyx_L1;}
      Py_DECREF(__pyx_v_parent);
      __pyx_v_parent = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":171 */
      Py_INCREF(__pyx_v_parent);
    }
    __pyx_L5:;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":172 */
    __pyx_2 = PyList_Append(__pyx_v_parents,__pyx_v_parent); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; goto __pyx_L1;}

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":173 */
    __pyx_v_parent_str = (__pyx_v_next + 1);
  }
  __pyx_L3:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":174 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
  Py_INCREF(__pyx_v_parents);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_parents);
  __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_knit_load_data_c.KnitIndexReader.process_parents");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_parents);
  Py_DECREF(__pyx_v_parent);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_KnitCorrupt;
static PyObject *__pyx_n__filename;

static PyObject *__pyx_k8p;

static char __pyx_k8[] = "line %r: %s";

static int __pyx_f_17_knit_load_data_c_15KnitIndexReader_process_one_record(struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *__pyx_v_self,char *__pyx_v_start,char *__pyx_v_end) {
  char *__pyx_v_version_id_str;
  int __pyx_v_version_id_size;
  char *__pyx_v_option_str;
  char *__pyx_v_option_end;
  char *__pyx_v_pos_str;
  int __pyx_v_pos;
  char *__pyx_v_size_str;
  int __pyx_v_size;
  char *__pyx_v_parent_str;
  void *__pyx_v_cache_entry;
  PyObject *__pyx_v_version_id;
  PyObject *__pyx_v_options;
  PyObject *__pyx_v_parents;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_py_line;
  PyObject *__pyx_v_index;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_version_id = Py_None; Py_INCREF(Py_None);
  __pyx_v_options = Py_None; Py_INCREF(Py_None);
  __pyx_v_parents = Py_None; Py_INCREF(Py_None);
  __pyx_v_e = Py_None; Py_INCREF(Py_None);
  __pyx_v_py_line = Py_None; Py_INCREF(Py_None);
  __pyx_v_index = Py_None; Py_INCREF(Py_None);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":190 */
  __pyx_v_version_id_str = __pyx_v_start;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":191 */
  __pyx_v_option_str = ((char *)memchr(__pyx_v_version_id_str,' ',(__pyx_v_end - __pyx_v_version_id_str)));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":192 */
  __pyx_1 = (__pyx_v_option_str == NULL);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_option_str >= __pyx_v_end);
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":195 */
  __pyx_v_version_id_size = ((int)(__pyx_v_option_str - __pyx_v_version_id_str));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":197 */
  __pyx_v_option_str = (__pyx_v_option_str + 1);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":199 */
  __pyx_v_pos_str = ((char *)memchr(__pyx_v_option_str,' ',(__pyx_v_end - __pyx_v_option_str)));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":200 */
  __pyx_1 = (__pyx_v_pos_str == NULL);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_pos_str >= __pyx_v_end);
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":203 */
  __pyx_v_option_end = __pyx_v_pos_str;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":204 */
  __pyx_v_pos_str = (__pyx_v_pos_str + 1);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":206 */
  __pyx_v_size_str = ((char *)memchr(__pyx_v_pos_str,' ',(__pyx_v_end - __pyx_v_pos_str)));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":207 */
  __pyx_1 = (__pyx_v_size_str == NULL);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_size_str >= __pyx_v_end);
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":210 */
  __pyx_v_size_str = (__pyx_v_size_str + 1);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":212 */
  __pyx_v_parent_str = ((char *)memchr(__pyx_v_size_str,' ',(__pyx_v_end - __pyx_v_size_str)));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":213 */
  __pyx_1 = (__pyx_v_parent_str == NULL);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_parent_str >= __pyx_v_end);
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":216 */
  __pyx_v_parent_str = (__pyx_v_parent_str + 1);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":218 */
  __pyx_2 = PyString_FromStringAndSize(__pyx_v_version_id_str,__pyx_v_version_id_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;}
  Py_DECREF(__pyx_v_version_id);
  __pyx_v_version_id = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":220 */
  __pyx_2 = ((struct __pyx_vtabstruct_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self->__pyx_vtab)->process_options(__pyx_v_self,__pyx_v_option_str,__pyx_v_option_end); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;}
  Py_DECREF(__pyx_v_options);
  __pyx_v_options = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":222 */
  /*try:*/ {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":223 */
    __pyx_1 = __pyx_f_17_knit_load_data_c_string_to_int_safe(__pyx_v_pos_str,(__pyx_v_size_str - 1),(&__pyx_v_pos)); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L6;}

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":224 */
    __pyx_1 = __pyx_f_17_knit_load_data_c_string_to_int_safe(__pyx_v_size_str,(__pyx_v_parent_str - 1),(&__pyx_v_size)); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L6;}

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":225 */
    __pyx_2 = ((struct __pyx_vtabstruct_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self->__pyx_vtab)->process_parents(__pyx_v_self,__pyx_v_parent_str,__pyx_v_end); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L6;}
    Py_DECREF(__pyx_v_parents);
    __pyx_v_parents = __pyx_2;
    __pyx_2 = 0;
  }
  goto __pyx_L7;
  __pyx_L6:;
  Py_XDECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":226 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}
  __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_IndexError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_1 = PyErr_ExceptionMatches(__pyx_4);
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_1) {
    __Pyx_AddTraceback("_knit_load_data_c.process_one_record");
    if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_e);
    __pyx_v_e = __pyx_3;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":227 */
    __pyx_5 = PyString_FromStringAndSize(__pyx_v_start,(__pyx_v_end - __pyx_v_start)); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;}
    Py_DECREF(__pyx_v_py_line);
    __pyx_v_py_line = __pyx_5;
    __pyx_5 = 0;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":228 */
    __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_errors); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;}
    __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_KnitCorrupt); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_5 = PyObject_GetAttr(__pyx_v_self->kndx, __pyx_n__filename); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;}
    __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;}
    Py_INCREF(__pyx_v_py_line);
    PyTuple_SET_ITEM(__pyx_7, 0, __pyx_v_py_line);
    Py_INCREF(__pyx_v_e);
    PyTuple_SET_ITEM(__pyx_7, 1, __pyx_v_e);
    __pyx_8 = PyNumber_Remainder(__pyx_k8p, __pyx_7); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;}
    Py_DECREF(__pyx_7); __pyx_7 = 0;
    __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_7, 0, __pyx_5);
    PyTuple_SET_ITEM(__pyx_7, 1, __pyx_8);
    __pyx_5 = 0;
    __pyx_8 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_6, __pyx_7); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_7); __pyx_7 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L7;
  }
  goto __pyx_L1;
  __pyx_L7:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":231 */
  __pyx_v_cache_entry = PyDict_GetItem(__pyx_v_self->cache,__pyx_v_version_id);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":232 */
  __pyx_1 = (__pyx_v_cache_entry == NULL);
  if (__pyx_1) {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":233 */
    __pyx_1 = PyList_Append(__pyx_v_self->history,__pyx_v_version_id); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":234 */
    __pyx_8 = PyInt_FromLong(__pyx_v_self->history_len); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; goto __pyx_L1;}
    Py_DECREF(__pyx_v_index);
    __pyx_v_index = __pyx_8;
    __pyx_8 = 0;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":235 */
    __pyx_v_self->history_len = (__pyx_v_self->history_len + 1);
    goto __pyx_L8;
  }
  /*else*/ {
    __pyx_6 = (PyObject *)PyTuple_GET_ITEM(__pyx_v_cache_entry,5);
    Py_INCREF(__pyx_6);
    Py_DECREF(__pyx_v_index);
    __pyx_v_index = __pyx_6;
    __pyx_6 = 0;
  }
  __pyx_L8:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":241 */
  __pyx_7 = PyInt_FromLong(__pyx_v_pos); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(__pyx_v_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(6); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}
  Py_INCREF(__pyx_v_version_id);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_version_id);
  Py_INCREF(__pyx_v_options);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_options);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_7);
  PyTuple_SET_ITEM(__pyx_2, 3, __pyx_5);
  Py_INCREF(__pyx_v_parents);
  PyTuple_SET_ITEM(__pyx_2, 4, __pyx_v_parents);
  Py_INCREF(__pyx_v_index);
  PyTuple_SET_ITEM(__pyx_2, 5, __pyx_v_index);
  __pyx_7 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyDict_SetItem(__pyx_v_self->cache,__pyx_v_version_id,__pyx_2); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":249 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  __Pyx_AddTraceback("_knit_load_data_c.KnitIndexReader.process_one_record");
  __pyx_r = (-1);
  __pyx_L0:;
  Py_DECREF(__pyx_v_version_id);
  Py_DECREF(__pyx_v_options);
  Py_DECREF(__pyx_v_parents);
  Py_DECREF(__pyx_v_e);
  Py_DECREF(__pyx_v_py_line);
  Py_DECREF(__pyx_v_index);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_17_knit_load_data_c_15KnitIndexReader_process_next_record(struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *__pyx_v_self) {
  char *__pyx_v_last;
  char *__pyx_v_start;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF(__pyx_v_self);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":256 */
  __pyx_v_start = __pyx_v_self->cur_str;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":258 */
  __pyx_v_last = ((char *)memchr(__pyx_v_start,'\n',(__pyx_v_self->end_str - __pyx_v_start)));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":259 */
  __pyx_1 = (__pyx_v_last == NULL);
  if (__pyx_1) {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":261 */
    __pyx_v_last = (__pyx_v_self->end_str - 1);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":262 */
    __pyx_v_self->cur_str = __pyx_v_self->end_str;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":266 */
    __pyx_v_self->cur_str = (__pyx_v_last + 1);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":267 */
    __pyx_v_last = (__pyx_v_last - 1);
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":269 */
  __pyx_1 = (__pyx_v_last <= __pyx_v_start);
  if (!__pyx_1) {
    __pyx_1 = ((__pyx_v_last[0]) != ':');
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":273 */
  __pyx_1 = ((struct __pyx_vtabstruct_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self->__pyx_vtab)->process_one_record(__pyx_v_self,__pyx_v_start,__pyx_v_last); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_knit_load_data_c.KnitIndexReader.process_next_record");
  __pyx_r = (-1);
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_check_header;
static PyObject *__pyx_n_read;

static PyObject *__pyx_f_17_knit_load_data_c_15KnitIndexReader_read(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_17_knit_load_data_c_15KnitIndexReader_read(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_text_size;
  PyObject *__pyx_v_text;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_text = Py_None; Py_INCREF(Py_None);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":278 */
  ((struct __pyx_vtabstruct_17_knit_load_data_c_KnitIndexReader *)((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->__pyx_vtab)->validate(((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":280 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->kndx, __pyx_n_check_header); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;}
  Py_INCREF(((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->fp);
  PyTuple_SET_ITEM(__pyx_2, 0, ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->fp);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":290 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->fp, __pyx_n_read); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_text);
  __pyx_v_text = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":291 */
  __pyx_v_text_size = PyString_Size(__pyx_v_text);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":292 */
  ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->cur_str = PyString_AsString(__pyx_v_text);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":294 */
  ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->end_str = (((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->cur_str + __pyx_v_text_size);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":296 */
  while (1) {
    __pyx_4 = (((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->cur_str < ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->end_str);
    if (!__pyx_4) break;
    __pyx_4 = ((struct __pyx_vtabstruct_17_knit_load_data_c_KnitIndexReader *)((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)->__pyx_vtab)->process_next_record(((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)__pyx_v_self)); if (__pyx_4 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; goto __pyx_L1;}
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_knit_load_data_c.KnitIndexReader.read");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_text);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_17_knit_load_data_c__load_data_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_17_knit_load_data_c__load_data_c[] = "Load the knit index file into memory.";
static PyObject *__pyx_f_17_knit_load_data_c__load_data_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_kndx = 0;
  PyObject *__pyx_v_fp = 0;
  PyObject *__pyx_v_reader;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {"kndx","fp",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_kndx, &__pyx_v_fp)) return 0;
  Py_INCREF(__pyx_v_kndx);
  Py_INCREF(__pyx_v_fp);
  __pyx_v_reader = Py_None; Py_INCREF(Py_None);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":302 */
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}
  Py_INCREF(__pyx_v_kndx);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_kndx);
  Py_INCREF(__pyx_v_fp);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_fp);
  __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_17_knit_load_data_c_KnitIndexReader), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_reader);
  __pyx_v_reader = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":303 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_read); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_knit_load_data_c._load_data_c");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_reader);
  Py_DECREF(__pyx_v_kndx);
  Py_DECREF(__pyx_v_fp);
  return __pyx_r;
}

static __Pyx_InternTabEntry __pyx_intern_tab[] = {
  {&__pyx_n_IndexError, "IndexError"},
  {&__pyx_n_KnitCorrupt, "KnitCorrupt"},
  {&__pyx_n_TypeError, "TypeError"},
  {&__pyx_n_ValueError, "ValueError"},
  {&__pyx_n__cache, "_cache"},
  {&__pyx_n__filename, "_filename"},
  {&__pyx_n__history, "_history"},
  {&__pyx_n_bzrlib, "bzrlib"},
  {&__pyx_n_check_header, "check_header"},
  {&__pyx_n_errors, "errors"},
  {&__pyx_n_read, "read"},
  {&__pyx_n_sys, "sys"},
  {&__pyx_n_tuple, "tuple"},
  {0, 0}
};

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_k4p, __pyx_k4, sizeof(__pyx_k4)},
  {&__pyx_k5p, __pyx_k5, sizeof(__pyx_k5)},
  {&__pyx_k6p, __pyx_k6, sizeof(__pyx_k6)},
  {&__pyx_k7p, __pyx_k7, sizeof(__pyx_k7)},
  {&__pyx_k8p, __pyx_k8, sizeof(__pyx_k8)},
  {0, 0, 0}
};
static struct __pyx_vtabstruct_17_knit_load_data_c_KnitIndexReader __pyx_vtable_17_knit_load_data_c_KnitIndexReader;

static PyObject *__pyx_tp_new_17_knit_load_data_c_KnitIndexReader(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)o);
  *(struct __pyx_vtabstruct_17_knit_load_data_c_KnitIndexReader **)&p->__pyx_vtab = __pyx_vtabptr_17_knit_load_data_c_KnitIndexReader;
  p->kndx = Py_None; Py_INCREF(Py_None);
  p->fp = Py_None; Py_INCREF(Py_None);
  p->cache = Py_None; Py_INCREF(Py_None);
  p->history = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_17_knit_load_data_c_KnitIndexReader(PyObject *o) {
  struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *p = (struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)o;
  Py_XDECREF(p->kndx);
  Py_XDECREF(p->fp);
  Py_XDECREF(p->cache);
  Py_XDECREF(p->history);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_17_knit_load_data_c_KnitIndexReader(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *p = (struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)o;
  if (p->kndx) {
    e = (*v)(p->kndx, a); if (e) return e;
  }
  if (p->fp) {
    e = (*v)(p->fp, a); if (e) return e;
  }
  if (p->cache) {
    e = (*v)(p->cache, a); if (e) return e;
  }
  if (p->history) {
    e = (*v)(p->history, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_17_knit_load_data_c_KnitIndexReader(PyObject *o) {
  struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *p = (struct __pyx_obj_17_knit_load_data_c_KnitIndexReader *)o;
  Py_XDECREF(p->kndx);
  p->kndx = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(p->fp);
  p->fp = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(p->cache);
  p->cache = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(p->history);
  p->history = Py_None; Py_INCREF(Py_None);
  return 0;
}

static struct PyMethodDef __pyx_methods_17_knit_load_data_c_KnitIndexReader[] = {
  {"read", (PyCFunction)__pyx_f_17_knit_load_data_c_15KnitIndexReader_read, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_KnitIndexReader = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_KnitIndexReader = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_KnitIndexReader = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_KnitIndexReader = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_17_knit_load_data_c_KnitIndexReader = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_knit_load_data_c.KnitIndexReader", /*tp_name*/
  sizeof(struct __pyx_obj_17_knit_load_data_c_KnitIndexReader), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_17_knit_load_data_c_KnitIndexReader, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_KnitIndexReader, /*tp_as_number*/
  &__pyx_tp_as_sequence_KnitIndexReader, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_KnitIndexReader, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_KnitIndexReader, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_17_knit_load_data_c_KnitIndexReader, /*tp_traverse*/
  __pyx_tp_clear_17_knit_load_data_c_KnitIndexReader, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_17_knit_load_data_c_KnitIndexReader, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_17_knit_load_data_c_15KnitIndexReader___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_17_knit_load_data_c_KnitIndexReader, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static struct PyMethodDef __pyx_methods[] = {
  {"_load_data_c", (PyCFunction)__pyx_f_17_knit_load_data_c__load_data_c, METH_VARARGS|METH_KEYWORDS, __pyx_doc_17_knit_load_data_c__load_data_c},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC init_knit_load_data_c(void); /*proto*/
PyMODINIT_FUNC init_knit_load_data_c(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("_knit_load_data_c", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  __pyx_vtabptr_17_knit_load_data_c_KnitIndexReader = &__pyx_vtable_17_knit_load_data_c_KnitIndexReader;
  *(void(**)(void))&__pyx_vtable_17_knit_load_data_c_KnitIndexReader.validate = (void(*)(void))__pyx_f_17_knit_load_data_c_15KnitIndexReader_validate;
  *(void(**)(void))&__pyx_vtable_17_knit_load_data_c_KnitIndexReader.process_options = (void(*)(void))__pyx_f_17_knit_load_data_c_15KnitIndexReader_process_options;
  *(void(**)(void))&__pyx_vtable_17_knit_load_data_c_KnitIndexReader.process_parents = (void(*)(void))__pyx_f_17_knit_load_data_c_15KnitIndexReader_process_parents;
  *(void(**)(void))&__pyx_vtable_17_knit_load_data_c_KnitIndexReader.process_one_record = (void(*)(void))__pyx_f_17_knit_load_data_c_15KnitIndexReader_process_one_record;
  *(void(**)(void))&__pyx_vtable_17_knit_load_data_c_KnitIndexReader.process_next_record = (void(*)(void))__pyx_f_17_knit_load_data_c_15KnitIndexReader_process_next_record;
  __pyx_type_17_knit_load_data_c_KnitIndexReader.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_17_knit_load_data_c_KnitIndexReader) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_17_knit_load_data_c_KnitIndexReader.tp_dict, __pyx_vtabptr_17_knit_load_data_c_KnitIndexReader) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "KnitIndexReader", (PyObject *)&__pyx_type_17_knit_load_data_c_KnitIndexReader) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; goto __pyx_L1;}
  __pyx_ptype_17_knit_load_data_c_KnitIndexReader = &__pyx_type_17_knit_load_data_c_KnitIndexReader;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":19 */
  __pyx_1 = __Pyx_Import(__pyx_n_sys, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_sys, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":21 */
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;}
  Py_INCREF(__pyx_n_errors);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_n_errors);
  __pyx_2 = __Pyx_Import(__pyx_n_bzrlib, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_errors); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_errors, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_knit_load_data_c.pyx":300 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_knit_load_data_c");
}

static char *__pyx_filenames[] = {
  "_knit_load_data_c.pyx",
};

/* Runtime support code */

static void __pyx_init_filenames(void) {
  __pyx_f = __pyx_filenames;
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *__import__ = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
    if (!__import__)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    module = PyObject_CallFunction(__import__, "OOOO",
        name, global_dict, empty_dict, list);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(__import__);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) type->ob_type;
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }
    PyErr_Restore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

static void __Pyx_WriteUnraisable(char *name) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    PyErr_Fetch(&old_exc, &old_val, &old_tb);
    ctx = PyString_FromString(name);
    PyErr_Restore(old_exc, old_val, old_tb);
    if (!ctx)
        ctx = Py_None;
    PyErr_WriteUnraisable(ctx);
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_Get();
    PyErr_Fetch(type, value, tb);
    PyErr_NormalizeException(type, value, tb);
    if (PyErr_Occurred())
        goto bad;
    Py_INCREF(*type);
    Py_INCREF(*value);
    Py_INCREF(*tb);
    Py_XDECREF(tstate->exc_type);
    Py_XDECREF(tstate->exc_value);
    Py_XDECREF(tstate->exc_traceback);
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
    return 0;
bad:
    Py_XDECREF(*type);
    Py_XDECREF(*value);
    Py_XDECREF(*tb);
    return -1;
}

static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
    while (t->p) {
        *t->p = PyString_InternFromString(t->s);
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
    PyObject *pycobj = 0;
    int result;
    
    pycobj = PyCObject_FromVoidPtr(vtable, 0);
    if (!pycobj)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0)
        goto bad;
    result = 0;
    goto done;

bad:
    result = -1;
done:
    Py_XDECREF(pycobj);
    return result;
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyObject *empty_tuple = 0;
    PyObject *empty_string = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    
    py_srcfile = PyString_FromString(__pyx_filename);
    if (!py_srcfile) goto bad;
    py_funcname = PyString_FromString(funcname);
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    empty_tuple = PyTuple_New(0);
    if (!empty_tuple) goto bad;
    empty_string = PyString_FromString("");
    if (!empty_string) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        empty_string, /*PyObject *code,*/
        empty_tuple,  /*PyObject *consts,*/
        empty_tuple,  /*PyObject *names,*/
        empty_tuple,  /*PyObject *varnames,*/
        empty_tuple,  /*PyObject *freevars,*/
        empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        empty_string  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_Get(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(empty_tuple);
    Py_XDECREF(empty_string);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}
