/* Generated by Pyrex 0.9.6.4 on Fri Sep  5 15:12:39 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 "_dirstate_helpers_c.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[] = "Helper functions for DirState.\n\nThis is the python implementation for DirState functions.\n";

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 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 _dirstate_helpers_c */

struct __pyx_obj_19_dirstate_helpers_c_Reader {
  PyObject_HEAD
  struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *__pyx_vtab;
  PyObject *text;
  char *text_cstr;
  int text_size;
  char *end_cstr;
  char *cur_cstr;
  char *next;
};


struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader {
  char *(*get_next)(struct __pyx_obj_19_dirstate_helpers_c_Reader *,int *);
  PyObject *(*get_next_str)(struct __pyx_obj_19_dirstate_helpers_c_Reader *);
  int (*_init)(struct __pyx_obj_19_dirstate_helpers_c_Reader *);
  PyObject *(*_get_entry)(struct __pyx_obj_19_dirstate_helpers_c_Reader *,int,void **,int *);
};
static struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *__pyx_vtabptr_19_dirstate_helpers_c_Reader;

static PyTypeObject *__pyx_ptype_19_dirstate_helpers_c_Reader = 0;
static PyObject *__pyx_k3;
static PyObject *__pyx_k4;
static PyObject *__pyx_k5;
static void *__pyx_f_19_dirstate_helpers_c__my_memrchr(void *,int,size_t); /*proto*/
static int __pyx_f_19_dirstate_helpers_c__is_aligned(void *); /*proto*/
static int __pyx_f_19_dirstate_helpers_c__cmp_by_dirs(char *,int,char *,int); /*proto*/
static int __pyx_f_19_dirstate_helpers_c__cmp_path_by_dirblock(char *,int,char *,int); /*proto*/


/* Implementation of _dirstate_helpers_c */

static char __pyx_k1[] = "bzrlib.dirstate";

static PyObject *__pyx_n_DirState;

static PyObject *__pyx_k1p;

static void *__pyx_f_19_dirstate_helpers_c__my_memrchr(void *__pyx_v_s,int __pyx_v_c,size_t __pyx_v_n) {
  char *__pyx_v_pos;
  char *__pyx_v_start;
  void *__pyx_r;
  int __pyx_1;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":81 */
  __pyx_v_start = ((char *)__pyx_v_s);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":82 */
  __pyx_v_pos = ((__pyx_v_start + __pyx_v_n) - 1);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":83 */
  while (1) {
    __pyx_1 = (__pyx_v_pos >= __pyx_v_start);
    if (!__pyx_1) break;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":84 */
    __pyx_1 = ((__pyx_v_pos[0]) == __pyx_v_c);
    if (__pyx_1) {
      __pyx_r = ((void *)__pyx_v_pos);
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":86 */
    __pyx_v_pos = (__pyx_v_pos - 1);
  }

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":87 */
  __pyx_r = NULL;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_k6p;

static char __pyx_k6[] = "Must be a single character string, not %s";

static PyObject *__pyx_f_19_dirstate_helpers_c__py_memrchr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_19_dirstate_helpers_c__py_memrchr[] = "Just to expose _my_memrchr for testing.\n\n    :param s: The Python string to search\n    :param c: The character to search for\n    :return: The offset to the last instance of \'c\' in s\n    ";
static PyObject *__pyx_f_19_dirstate_helpers_c__py_memrchr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_v_c = 0;
  void *__pyx_v__s;
  void *__pyx_v_found;
  int __pyx_v_length;
  char *__pyx_v__c;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  static char *__pyx_argnames[] = {"s","c",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_s, &__pyx_v_c)) return 0;
  Py_INCREF(__pyx_v_s);
  Py_INCREF(__pyx_v_c);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":102 */
  __pyx_v__s = PyString_AsString(__pyx_v_s);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":103 */
  __pyx_v_length = PyString_Size(__pyx_v_s);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":105 */
  __pyx_v__c = PyString_AsString(__pyx_v_c);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":106 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;}
  Py_INCREF(__pyx_v_c);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_c);
  __pyx_2 = PyNumber_Remainder(__pyx_k6p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!(PyString_Size(__pyx_v_c) == 1)) {
    PyErr_SetObject(PyExc_AssertionError, __pyx_2);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;}
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  #endif

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":108 */
  __pyx_v_found = __pyx_f_19_dirstate_helpers_c__my_memrchr(__pyx_v__s,(__pyx_v__c[0]),__pyx_v_length);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":109 */
  __pyx_3 = (__pyx_v_found == NULL);
  if (__pyx_3) {
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":111 */
  __pyx_1 = PyInt_FromLong((((char *)__pyx_v_found) - ((char *)__pyx_v__s))); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_dirstate_helpers_c._py_memrchr");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_s);
  Py_DECREF(__pyx_v_c);
  return __pyx_r;
}

static int __pyx_f_19_dirstate_helpers_c__is_aligned(void *__pyx_v_ptr) {
  int __pyx_r;
  __pyx_r = ((((intptr_t)__pyx_v_ptr) & ((sizeof(int)) - 1)) == 0);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static int __pyx_f_19_dirstate_helpers_c__cmp_by_dirs(char *__pyx_v_path1,int __pyx_v_size1,char *__pyx_v_path2,int __pyx_v_size2) {
  unsigned char *__pyx_v_cur1;
  unsigned char *__pyx_v_cur2;
  unsigned char *__pyx_v_end1;
  unsigned char *__pyx_v_end2;
  int *__pyx_v_cur_int1;
  int *__pyx_v_cur_int2;
  int *__pyx_v_end_int1;
  int *__pyx_v_end_int2;
  int __pyx_r;
  int __pyx_1;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":132 */
  __pyx_1 = (__pyx_v_path1 == __pyx_v_path2);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_size1 == __pyx_v_size2);
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":135 */
  __pyx_v_end1 = (((unsigned char *)__pyx_v_path1) + __pyx_v_size1);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":136 */
  __pyx_v_end2 = (((unsigned char *)__pyx_v_path2) + __pyx_v_size2);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":143 */
  __pyx_1 = __pyx_f_19_dirstate_helpers_c__is_aligned(__pyx_v_path1);
  if (__pyx_1) {
    __pyx_1 = __pyx_f_19_dirstate_helpers_c__is_aligned(__pyx_v_path2);
  }
  if (__pyx_1) {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":144 */
    __pyx_v_cur_int1 = ((int *)__pyx_v_path1);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":145 */
    __pyx_v_cur_int2 = ((int *)__pyx_v_path2);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":146 */
    __pyx_v_end_int1 = ((int *)((__pyx_v_path1 + __pyx_v_size1) - (__pyx_v_size1 % (sizeof(int)))));

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":147 */
    __pyx_v_end_int2 = ((int *)((__pyx_v_path2 + __pyx_v_size2) - (__pyx_v_size2 % (sizeof(int)))));

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":149 */
    while (1) {
      __pyx_1 = (__pyx_v_cur_int1 < __pyx_v_end_int1);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_cur_int2 < __pyx_v_end_int2);
      }
      if (!__pyx_1) break;

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":150 */
      __pyx_1 = ((__pyx_v_cur_int1[0]) != (__pyx_v_cur_int2[0]));
      if (__pyx_1) {
        goto __pyx_L5;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":152 */
      __pyx_v_cur_int1 = (__pyx_v_cur_int1 + 1);

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":153 */
      __pyx_v_cur_int2 = (__pyx_v_cur_int2 + 1);
    }
    __pyx_L5:;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":155 */
    __pyx_v_cur1 = ((unsigned char *)__pyx_v_cur_int1);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":156 */
    __pyx_v_cur2 = ((unsigned char *)__pyx_v_cur_int2);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":158 */
    __pyx_v_cur1 = ((unsigned char *)__pyx_v_path1);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":159 */
    __pyx_v_cur2 = ((unsigned char *)__pyx_v_path2);
  }
  __pyx_L3:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":161 */
  while (1) {
    __pyx_1 = (__pyx_v_cur1 < __pyx_v_end1);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_cur2 < __pyx_v_end2);
    }
    if (!__pyx_1) break;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":162 */
    __pyx_1 = ((__pyx_v_cur1[0]) == (__pyx_v_cur2[0]));
    if (__pyx_1) {

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":164 */
      __pyx_v_cur1 = (__pyx_v_cur1 + 1);

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":165 */
      __pyx_v_cur2 = (__pyx_v_cur2 + 1);

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":166 */
      goto __pyx_L7;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":168 */
    __pyx_1 = ((__pyx_v_cur1[0]) == '/');
    if (__pyx_1) {
      __pyx_r = (-1);
      goto __pyx_L0;
      goto __pyx_L10;
    }
    __pyx_1 = ((__pyx_v_cur2[0]) == '/');
    if (__pyx_1) {
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L10;
    }
    __pyx_1 = ((__pyx_v_cur1[0]) < (__pyx_v_cur2[0]));
    if (__pyx_1) {
      __pyx_r = (-1);
      goto __pyx_L0;
      goto __pyx_L10;
    }
    /*else*/ {
      __pyx_r = 1;
      goto __pyx_L0;
    }
    __pyx_L10:;
    __pyx_L7:;
  }

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":178 */
  __pyx_1 = (__pyx_v_cur1 < __pyx_v_end1);
  if (__pyx_1) {
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":180 */
  __pyx_1 = (__pyx_v_cur2 < __pyx_v_end2);
  if (__pyx_1) {
    __pyx_r = (-1);
    goto __pyx_L0;
    goto __pyx_L12;
  }
  __pyx_L12:;

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

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_n_TypeError;
static PyObject *__pyx_n_type;

static PyObject *__pyx_k7p;
static PyObject *__pyx_k8p;

static char __pyx_k7[] = "'path1' must be a plain string, not %s: %r";
static char __pyx_k8[] = "'path2' must be a plain string, not %s: %r";

static PyObject *__pyx_f_19_dirstate_helpers_c_cmp_by_dirs_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_19_dirstate_helpers_c_cmp_by_dirs_c[] = "Compare two paths directory by directory.\n\n    This is equivalent to doing::\n\n       cmp(path1.split(\'/\'), path2.split(\'/\'))\n\n    The idea is that you should compare path components separately. This\n    differs from plain ``cmp(path1, path2)`` for paths like ``\'a-b\'`` and\n    ``a/b``. \"a-b\" comes after \"a\" but would come before \"a/b\" lexically.\n\n    :param path1: first path\n    :param path2: second path\n    :return: negative number if ``path1`` comes first,\n        0 if paths are equal,\n        and positive number if ``path2`` sorts first\n    ";
static PyObject *__pyx_f_19_dirstate_helpers_c_cmp_by_dirs_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_path1 = 0;
  PyObject *__pyx_v_path2 = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"path1","path2",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_path1, &__pyx_v_path2)) return 0;
  Py_INCREF(__pyx_v_path1);
  Py_INCREF(__pyx_v_path2);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":203 */
  __pyx_1 = (!PyString_CheckExact(__pyx_v_path1));
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
    Py_INCREF(__pyx_v_path1);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_path1);
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    Py_INCREF(__pyx_v_path1);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_path1);
    __pyx_5 = 0;
    __pyx_4 = PyNumber_Remainder(__pyx_k7p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":206 */
  __pyx_1 = (!PyString_CheckExact(__pyx_v_path2));
  if (__pyx_1) {
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;}
    Py_INCREF(__pyx_v_path2);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_path2);
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    Py_INCREF(__pyx_v_path2);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_path2);
    __pyx_3 = 0;
    __pyx_5 = PyNumber_Remainder(__pyx_k8p, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    __pyx_5 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":209 */
  __pyx_5 = PyInt_FromLong(__pyx_f_19_dirstate_helpers_c__cmp_by_dirs(PyString_AsString(__pyx_v_path1),PyString_Size(__pyx_v_path1),PyString_AsString(__pyx_v_path2),PyString_Size(__pyx_v_path2))); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}
  __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_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_dirstate_helpers_c.cmp_by_dirs_c");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_path1);
  Py_DECREF(__pyx_v_path2);
  return __pyx_r;
}

static PyObject *__pyx_k9p;
static PyObject *__pyx_k10p;

static char __pyx_k9[] = "'path1' must be a plain string, not %s: %r";
static char __pyx_k10[] = "'path2' must be a plain string, not %s: %r";

static PyObject *__pyx_f_19_dirstate_helpers_c__cmp_path_by_dirblock_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_19_dirstate_helpers_c__cmp_path_by_dirblock_c[] = "Compare two paths based on what directory they are in.\n\n    This generates a sort order, such that all children of a directory are\n    sorted together, and grandchildren are in the same order as the\n    children appear. But all grandchildren come after all children.\n\n    In other words, all entries in a directory are sorted together, and\n    directorys are sorted in cmp_by_dirs order.\n\n    :param path1: first path\n    :param path2: the second path\n    :return: negative number if ``path1`` comes first,\n        0 if paths are equal\n        and a positive number if ``path2`` sorts first\n    ";
static PyObject *__pyx_f_19_dirstate_helpers_c__cmp_path_by_dirblock_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_path1 = 0;
  PyObject *__pyx_v_path2 = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"path1","path2",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_path1, &__pyx_v_path2)) return 0;
  Py_INCREF(__pyx_v_path1);
  Py_INCREF(__pyx_v_path2);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":231 */
  __pyx_1 = (!PyString_CheckExact(__pyx_v_path1));
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
    Py_INCREF(__pyx_v_path1);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_path1);
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    Py_INCREF(__pyx_v_path1);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_path1);
    __pyx_5 = 0;
    __pyx_4 = PyNumber_Remainder(__pyx_k9p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":234 */
  __pyx_1 = (!PyString_CheckExact(__pyx_v_path2));
  if (__pyx_1) {
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;}
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;}
    Py_INCREF(__pyx_v_path2);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_path2);
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    Py_INCREF(__pyx_v_path2);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_path2);
    __pyx_3 = 0;
    __pyx_5 = PyNumber_Remainder(__pyx_k10p, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    __pyx_5 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":237 */
  __pyx_5 = PyInt_FromLong(__pyx_f_19_dirstate_helpers_c__cmp_path_by_dirblock(PyString_AsString(__pyx_v_path1),PyString_Size(__pyx_v_path1),PyString_AsString(__pyx_v_path2),PyString_Size(__pyx_v_path2))); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; goto __pyx_L1;}
  __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_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_dirstate_helpers_c._cmp_path_by_dirblock_c");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_path1);
  Py_DECREF(__pyx_v_path2);
  return __pyx_r;
}

static char __pyx_k11[] = "";
static char __pyx_k12[] = "";

static int __pyx_f_19_dirstate_helpers_c__cmp_path_by_dirblock(char *__pyx_v_path1,int __pyx_v_path1_len,char *__pyx_v_path2,int __pyx_v_path2_len) {
  char *__pyx_v_dirname1;
  int __pyx_v_dirname1_len;
  char *__pyx_v_dirname2;
  int __pyx_v_dirname2_len;
  char *__pyx_v_basename1;
  int __pyx_v_basename1_len;
  char *__pyx_v_basename2;
  int __pyx_v_basename2_len;
  int __pyx_v_cur_len;
  int __pyx_v_cmp_val;
  int __pyx_r;
  int __pyx_1;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":260 */
  __pyx_1 = (__pyx_v_path1_len == 0);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_path2_len == 0);
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":263 */
  __pyx_1 = (__pyx_v_path1 == __pyx_v_path2);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_path1_len == __pyx_v_path2_len);
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":266 */
  __pyx_1 = (__pyx_v_path1_len == 0);
  if (__pyx_1) {
    __pyx_r = (-1);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":269 */
  __pyx_1 = (__pyx_v_path2_len == 0);
  if (__pyx_1) {
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":272 */
  __pyx_v_basename1 = ((char *)__pyx_f_19_dirstate_helpers_c__my_memrchr(__pyx_v_path1,'/',__pyx_v_path1_len));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":274 */
  __pyx_1 = (__pyx_v_basename1 == NULL);
  if (__pyx_1) {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":275 */
    __pyx_v_basename1 = __pyx_v_path1;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":276 */
    __pyx_v_basename1_len = __pyx_v_path1_len;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":277 */
    __pyx_v_dirname1 = __pyx_k11;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":278 */
    __pyx_v_dirname1_len = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":280 */
    __pyx_v_dirname1 = __pyx_v_path1;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":281 */
    __pyx_v_dirname1_len = (__pyx_v_basename1 - __pyx_v_path1);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":282 */
    __pyx_v_basename1 = (__pyx_v_basename1 + 1);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":283 */
    __pyx_v_basename1_len = ((__pyx_v_path1_len - __pyx_v_dirname1_len) - 1);
  }
  __pyx_L6:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":285 */
  __pyx_v_basename2 = ((char *)__pyx_f_19_dirstate_helpers_c__my_memrchr(__pyx_v_path2,'/',__pyx_v_path2_len));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":287 */
  __pyx_1 = (__pyx_v_basename2 == NULL);
  if (__pyx_1) {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":288 */
    __pyx_v_basename2 = __pyx_v_path2;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":289 */
    __pyx_v_basename2_len = __pyx_v_path2_len;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":290 */
    __pyx_v_dirname2 = __pyx_k12;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":291 */
    __pyx_v_dirname2_len = 0;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":293 */
    __pyx_v_dirname2 = __pyx_v_path2;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":294 */
    __pyx_v_dirname2_len = (__pyx_v_basename2 - __pyx_v_path2);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":295 */
    __pyx_v_basename2 = (__pyx_v_basename2 + 1);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":296 */
    __pyx_v_basename2_len = ((__pyx_v_path2_len - __pyx_v_dirname2_len) - 1);
  }
  __pyx_L7:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":298 */
  __pyx_v_cmp_val = __pyx_f_19_dirstate_helpers_c__cmp_by_dirs(__pyx_v_dirname1,__pyx_v_dirname1_len,__pyx_v_dirname2,__pyx_v_dirname2_len);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":300 */
  __pyx_1 = (__pyx_v_cmp_val != 0);
  if (__pyx_1) {
    __pyx_r = __pyx_v_cmp_val;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":303 */
  __pyx_v_cur_len = __pyx_v_basename1_len;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":304 */
  __pyx_1 = (__pyx_v_basename2_len < __pyx_v_basename1_len);
  if (__pyx_1) {
    __pyx_v_cur_len = __pyx_v_basename2_len;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":307 */
  __pyx_v_cmp_val = memcmp(__pyx_v_basename1,__pyx_v_basename2,__pyx_v_cur_len);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":308 */
  __pyx_1 = (__pyx_v_cmp_val != 0);
  if (__pyx_1) {
    __pyx_r = __pyx_v_cmp_val;
    goto __pyx_L0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":310 */
  __pyx_1 = (__pyx_v_basename1_len == __pyx_v_basename2_len);
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":312 */
  __pyx_1 = (__pyx_v_basename1_len < __pyx_v_basename2_len);
  if (__pyx_1) {
    __pyx_r = (-1);
    goto __pyx_L0;
    goto __pyx_L12;
  }
  __pyx_L12:;

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

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_k13p;
static PyObject *__pyx_k14p;

static char __pyx_k13[] = "you must pass a python list for 'paths' not: %s %r";
static char __pyx_k14[] = "you must pass a string for 'path' not: %s %r";

static PyObject *__pyx_f_19_dirstate_helpers_c__bisect_path_left_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_19_dirstate_helpers_c__bisect_path_left_c[] = "Return the index where to insert path into paths.\n\n    This uses a path-wise comparison so we get::\n        a\n        a-b\n        a=b\n        a/b\n    Rather than::\n        a\n        a-b\n        a/b\n        a=b\n    :param paths: A list of paths to search through\n    :param path: A single path to insert\n    :return: An offset where \'path\' can be inserted.\n    :seealso: bisect.bisect_left\n    ";
static PyObject *__pyx_f_19_dirstate_helpers_c__bisect_path_left_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_paths = 0;
  PyObject *__pyx_v_path = 0;
  int __pyx_v__lo;
  int __pyx_v__hi;
  int __pyx_v__mid;
  char *__pyx_v_path_cstr;
  int __pyx_v_path_size;
  char *__pyx_v_cur_cstr;
  int __pyx_v_cur_size;
  void *__pyx_v_cur;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_ssize_t __pyx_6;
  static char *__pyx_argnames[] = {"paths","path",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_paths, &__pyx_v_path)) return 0;
  Py_INCREF(__pyx_v_paths);
  Py_INCREF(__pyx_v_path);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":344 */
  __pyx_1 = (!PyList_CheckExact(__pyx_v_paths));
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
    Py_INCREF(__pyx_v_paths);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_paths);
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    Py_INCREF(__pyx_v_paths);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_paths);
    __pyx_5 = 0;
    __pyx_4 = PyNumber_Remainder(__pyx_k13p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":347 */
  __pyx_1 = (!PyString_CheckExact(__pyx_v_path));
  if (__pyx_1) {
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
    Py_INCREF(__pyx_v_path);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_path);
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    Py_INCREF(__pyx_v_path);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_path);
    __pyx_3 = 0;
    __pyx_5 = PyNumber_Remainder(__pyx_k14p, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    __pyx_5 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":351 */
  __pyx_6 = PyObject_Length(__pyx_v_paths); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
  __pyx_v__hi = __pyx_6;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":352 */
  __pyx_v__lo = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":354 */
  __pyx_v_path_cstr = PyString_AsString(__pyx_v_path);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":355 */
  __pyx_v_path_size = PyString_Size(__pyx_v_path);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":357 */
  while (1) {
    __pyx_1 = (__pyx_v__lo < __pyx_v__hi);
    if (!__pyx_1) break;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":358 */
    __pyx_v__mid = ((__pyx_v__lo + __pyx_v__hi) / 2);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":359 */
    __pyx_v_cur = PyList_GET_ITEM(__pyx_v_paths,__pyx_v__mid);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":360 */
    __pyx_v_cur_cstr = PyString_AS_STRING(__pyx_v_cur);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":361 */
    __pyx_v_cur_size = PyString_GET_SIZE(__pyx_v_cur);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":362 */
    __pyx_1 = (__pyx_f_19_dirstate_helpers_c__cmp_path_by_dirblock(__pyx_v_cur_cstr,__pyx_v_cur_size,__pyx_v_path_cstr,__pyx_v_path_size) < 0);
    if (__pyx_1) {
      __pyx_v__lo = (__pyx_v__mid + 1);
      goto __pyx_L6;
    }
    /*else*/ {
      __pyx_v__hi = __pyx_v__mid;
    }
    __pyx_L6:;
  }

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":366 */
  __pyx_5 = PyInt_FromLong(__pyx_v__lo); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;}
  __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_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_dirstate_helpers_c._bisect_path_left_c");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_paths);
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

static PyObject *__pyx_k15p;
static PyObject *__pyx_k16p;

static char __pyx_k15[] = "you must pass a python list for 'paths' not: %s %r";
static char __pyx_k16[] = "you must pass a string for 'path' not: %s %r";

static PyObject *__pyx_f_19_dirstate_helpers_c__bisect_path_right_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_19_dirstate_helpers_c__bisect_path_right_c[] = "Return the index where to insert path into paths.\n\n    This uses a path-wise comparison so we get::\n        a\n        a-b\n        a=b\n        a/b\n    Rather than::\n        a\n        a-b\n        a/b\n        a=b\n    :param paths: A list of paths to search through\n    :param path: A single path to insert\n    :return: An offset where \'path\' can be inserted.\n    :seealso: bisect.bisect_right\n    ";
static PyObject *__pyx_f_19_dirstate_helpers_c__bisect_path_right_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_paths = 0;
  PyObject *__pyx_v_path = 0;
  int __pyx_v__lo;
  int __pyx_v__hi;
  int __pyx_v__mid;
  char *__pyx_v_path_cstr;
  int __pyx_v_path_size;
  char *__pyx_v_cur_cstr;
  int __pyx_v_cur_size;
  void *__pyx_v_cur;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_ssize_t __pyx_6;
  static char *__pyx_argnames[] = {"paths","path",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_paths, &__pyx_v_path)) return 0;
  Py_INCREF(__pyx_v_paths);
  Py_INCREF(__pyx_v_path);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":396 */
  __pyx_1 = (!PyList_CheckExact(__pyx_v_paths));
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
    Py_INCREF(__pyx_v_paths);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_paths);
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    Py_INCREF(__pyx_v_paths);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_paths);
    __pyx_5 = 0;
    __pyx_4 = PyNumber_Remainder(__pyx_k15p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":399 */
  __pyx_1 = (!PyString_CheckExact(__pyx_v_path));
  if (__pyx_1) {
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;}
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;}
    Py_INCREF(__pyx_v_path);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_path);
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    Py_INCREF(__pyx_v_path);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_path);
    __pyx_3 = 0;
    __pyx_5 = PyNumber_Remainder(__pyx_k16p, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    __pyx_5 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":403 */
  __pyx_6 = PyObject_Length(__pyx_v_paths); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; goto __pyx_L1;}
  __pyx_v__hi = __pyx_6;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":404 */
  __pyx_v__lo = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":406 */
  __pyx_v_path_cstr = PyString_AsString(__pyx_v_path);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":407 */
  __pyx_v_path_size = PyString_Size(__pyx_v_path);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":409 */
  while (1) {
    __pyx_1 = (__pyx_v__lo < __pyx_v__hi);
    if (!__pyx_1) break;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":410 */
    __pyx_v__mid = ((__pyx_v__lo + __pyx_v__hi) / 2);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":411 */
    __pyx_v_cur = PyList_GET_ITEM(__pyx_v_paths,__pyx_v__mid);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":412 */
    __pyx_v_cur_cstr = PyString_AS_STRING(__pyx_v_cur);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":413 */
    __pyx_v_cur_size = PyString_GET_SIZE(__pyx_v_cur);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":414 */
    __pyx_1 = (__pyx_f_19_dirstate_helpers_c__cmp_path_by_dirblock(__pyx_v_path_cstr,__pyx_v_path_size,__pyx_v_cur_cstr,__pyx_v_cur_size) < 0);
    if (__pyx_1) {
      __pyx_v__hi = __pyx_v__mid;
      goto __pyx_L6;
    }
    /*else*/ {
      __pyx_v__lo = (__pyx_v__mid + 1);
    }
    __pyx_L6:;
  }

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":418 */
  __pyx_5 = PyInt_FromLong(__pyx_v__lo); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; goto __pyx_L1;}
  __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_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_dirstate_helpers_c._bisect_path_right_c");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_paths);
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

static PyObject *__pyx_k17p;
static PyObject *__pyx_k18p;

static char __pyx_k17[] = "you must pass a python list for 'dirblocks' not: %s %r";
static char __pyx_k18[] = "you must pass a string for dirname not: %s %r";

static PyObject *__pyx_f_19_dirstate_helpers_c_bisect_dirblock_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_19_dirstate_helpers_c_bisect_dirblock_c[] = "Return the index where to insert dirname into the dirblocks.\n\n    The return value idx is such that all directories blocks in dirblock[:idx]\n    have names < dirname, and all blocks in dirblock[idx:] have names >=\n    dirname.\n\n    Optional args lo (default 0) and hi (default len(dirblocks)) bound the\n    slice of a to be searched.\n    ";
static PyObject *__pyx_f_19_dirstate_helpers_c_bisect_dirblock_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dirblocks = 0;
  PyObject *__pyx_v_dirname = 0;
  PyObject *__pyx_v_lo = 0;
  PyObject *__pyx_v_hi = 0;
  PyObject *__pyx_v_cache = 0;
  int __pyx_v__lo;
  int __pyx_v__hi;
  int __pyx_v__mid;
  char *__pyx_v_dirname_cstr;
  int __pyx_v_dirname_size;
  char *__pyx_v_cur_cstr;
  int __pyx_v_cur_size;
  void *__pyx_v_cur;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_ssize_t __pyx_6;
  static char *__pyx_argnames[] = {"dirblocks","dirname","lo","hi","cache",0};
  __pyx_v_lo = __pyx_k3;
  __pyx_v_hi = __pyx_k4;
  __pyx_v_cache = __pyx_k5;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|OOO", __pyx_argnames, &__pyx_v_dirblocks, &__pyx_v_dirname, &__pyx_v_lo, &__pyx_v_hi, &__pyx_v_cache)) return 0;
  Py_INCREF(__pyx_v_dirblocks);
  Py_INCREF(__pyx_v_dirname);
  Py_INCREF(__pyx_v_lo);
  Py_INCREF(__pyx_v_hi);
  Py_INCREF(__pyx_v_cache);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":440 */
  __pyx_1 = (!PyList_CheckExact(__pyx_v_dirblocks));
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}
    Py_INCREF(__pyx_v_dirblocks);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_dirblocks);
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    Py_INCREF(__pyx_v_dirblocks);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_dirblocks);
    __pyx_5 = 0;
    __pyx_4 = PyNumber_Remainder(__pyx_k17p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":443 */
  __pyx_1 = (!PyString_CheckExact(__pyx_v_dirname));
  if (__pyx_1) {
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;}
    Py_INCREF(__pyx_v_dirname);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_dirname);
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    Py_INCREF(__pyx_v_dirname);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_dirname);
    __pyx_3 = 0;
    __pyx_5 = PyNumber_Remainder(__pyx_k18p, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    __pyx_5 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":446 */
  __pyx_1 = __pyx_v_hi == Py_None;
  if (__pyx_1) {
    __pyx_6 = PyObject_Length(__pyx_v_dirblocks); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}
    __pyx_v__hi = __pyx_6;
    goto __pyx_L4;
  }
  /*else*/ {
    __pyx_1 = PyInt_AsLong(__pyx_v_hi); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}
    __pyx_v__hi = __pyx_1;
  }
  __pyx_L4:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":451 */
  __pyx_1 = PyInt_AsLong(__pyx_v_lo); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}
  __pyx_v__lo = __pyx_1;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":452 */
  __pyx_v_dirname_cstr = PyString_AsString(__pyx_v_dirname);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":453 */
  __pyx_v_dirname_size = PyString_Size(__pyx_v_dirname);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":455 */
  while (1) {
    __pyx_1 = (__pyx_v__lo < __pyx_v__hi);
    if (!__pyx_1) break;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":456 */
    __pyx_v__mid = ((__pyx_v__lo + __pyx_v__hi) / 2);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":459 */
    __pyx_v_cur = PyTuple_GET_ITEM(PyList_GET_ITEM(__pyx_v_dirblocks,__pyx_v__mid),0);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":461 */
    __pyx_v_cur_cstr = PyString_AS_STRING(__pyx_v_cur);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":462 */
    __pyx_v_cur_size = PyString_GET_SIZE(__pyx_v_cur);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":463 */
    __pyx_1 = (__pyx_f_19_dirstate_helpers_c__cmp_by_dirs(__pyx_v_cur_cstr,__pyx_v_cur_size,__pyx_v_dirname_cstr,__pyx_v_dirname_size) < 0);
    if (__pyx_1) {
      __pyx_v__lo = (__pyx_v__mid + 1);
      goto __pyx_L7;
    }
    /*else*/ {
      __pyx_v__hi = __pyx_v__mid;
    }
    __pyx_L7:;
  }

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":467 */
  __pyx_5 = PyInt_FromLong(__pyx_v__lo); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}
  __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_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_dirstate_helpers_c.bisect_dirblock_c");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_dirblocks);
  Py_DECREF(__pyx_v_dirname);
  Py_DECREF(__pyx_v_lo);
  Py_DECREF(__pyx_v_hi);
  Py_DECREF(__pyx_v_cache);
  return __pyx_r;
}

static int __pyx_f_19_dirstate_helpers_c_6Reader___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_19_dirstate_helpers_c_6Reader___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text = 0;
  int __pyx_r;
  static char *__pyx_argnames[] = {"text",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_text)) return -1;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_text);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":482 */
  Py_INCREF(__pyx_v_text);
  Py_DECREF(((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->text);
  ((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->text = __pyx_v_text;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":483 */
  ((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->text_cstr = PyString_AsString(__pyx_v_text);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":484 */
  ((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->text_size = PyString_Size(__pyx_v_text);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":485 */
  ((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->end_cstr = (((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->text_cstr + ((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->text_size);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":486 */
  ((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->cur_cstr = ((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->text_cstr;

  __pyx_r = 0;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

static char *__pyx_f_19_dirstate_helpers_c_6Reader_get_next(struct __pyx_obj_19_dirstate_helpers_c_Reader *__pyx_v_self,int *__pyx_v_size) {
  char *__pyx_v_next;
  char *__pyx_r;
  Py_INCREF(__pyx_v_self);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":491 */
  __pyx_v_next = __pyx_v_self->cur_cstr;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":492 */
  __pyx_v_self->cur_cstr = ((char *)memchr(__pyx_v_next,'\0',(__pyx_v_self->end_cstr - __pyx_v_next)));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":493 */
  (__pyx_v_size[0]) = (__pyx_v_self->cur_cstr - __pyx_v_next);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":494 */
  __pyx_v_self->cur_cstr = (__pyx_v_self->cur_cstr + 1);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":495 */
  __pyx_r = __pyx_v_next;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_19_dirstate_helpers_c_6Reader_get_next_str(struct __pyx_obj_19_dirstate_helpers_c_Reader *__pyx_v_self) {
  int __pyx_v_size;
  char *__pyx_v_next;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":501 */
  __pyx_v_next = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)__pyx_v_self->__pyx_vtab)->get_next(__pyx_v_self,(&__pyx_v_size));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":502 */
  __pyx_1 = PyString_FromStringAndSize(__pyx_v_next,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_dirstate_helpers_c.Reader.get_next_str");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_AssertionError;

static PyObject *__pyx_k19p;

static char __pyx_k19[] = "First character should be null not: %s";

static int __pyx_f_19_dirstate_helpers_c_6Reader__init(struct __pyx_obj_19_dirstate_helpers_c_Reader *__pyx_v_self) {
  char *__pyx_v_first;
  int __pyx_v_size;
  int __pyx_r;
  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/_dirstate_helpers_c.pyx":515 */
  __pyx_v_first = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)__pyx_v_self->__pyx_vtab)->get_next(__pyx_v_self,(&__pyx_v_size));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":516 */
  __pyx_1 = ((__pyx_v_first[0]) != '\0');
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_size == 0);
  }
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_AssertionError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(__pyx_v_first); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyNumber_Remainder(__pyx_k19p, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":519 */
  __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("_dirstate_helpers_c.Reader._init");
  __pyx_r = (-1);
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k20p;

static char __pyx_k20[] = "Bad parse, we expected to end on \\n, not: %d %s: %s";

static PyObject *__pyx_f_19_dirstate_helpers_c_6Reader__get_entry(struct __pyx_obj_19_dirstate_helpers_c_Reader *__pyx_v_self,int __pyx_v_num_trees,void **__pyx_v_p_current_dirname,int *__pyx_v_new_block) {
  PyObject *__pyx_v_path_name_file_id_key;
  char *__pyx_v_entry_size_cstr;
  unsigned long __pyx_v_entry_size;
  char *__pyx_v_executable_cstr;
  int __pyx_v_is_executable;
  char *__pyx_v_dirname_cstr;
  char *__pyx_v_trailing;
  int __pyx_v_cur_size;
  int __pyx_v_i;
  PyObject *__pyx_v_minikind;
  PyObject *__pyx_v_fingerprint;
  PyObject *__pyx_v_info;
  PyObject *__pyx_v_dirname;
  PyObject *__pyx_v_trees;
  PyObject *__pyx_v_ret;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_path_name_file_id_key = Py_None; Py_INCREF(Py_None);
  __pyx_v_minikind = Py_None; Py_INCREF(Py_None);
  __pyx_v_fingerprint = Py_None; Py_INCREF(Py_None);
  __pyx_v_info = Py_None; Py_INCREF(Py_None);
  __pyx_v_dirname = Py_None; Py_INCREF(Py_None);
  __pyx_v_trees = Py_None; Py_INCREF(Py_None);
  __pyx_v_ret = Py_None; Py_INCREF(Py_None);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":556 */
  __pyx_v_dirname_cstr = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)__pyx_v_self->__pyx_vtab)->get_next(__pyx_v_self,(&__pyx_v_cur_size));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":564 */
  __pyx_1 = (__pyx_v_cur_size != PyString_GET_SIZE((__pyx_v_p_current_dirname[0])));
  if (!__pyx_1) {
    __pyx_1 = (strncmp(__pyx_v_dirname_cstr,PyString_AS_STRING((__pyx_v_p_current_dirname[0])),(__pyx_v_cur_size + 1)) != 0);
  }
  if (__pyx_1) {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":573 */
    __pyx_2 = PyString_FromStringAndSize(__pyx_v_dirname_cstr,__pyx_v_cur_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; goto __pyx_L1;}
    Py_DECREF(__pyx_v_dirname);
    __pyx_v_dirname = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":574 */
    (__pyx_v_p_current_dirname[0]) = ((void *)__pyx_v_dirname);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":575 */
    (__pyx_v_new_block[0]) = 1;
    goto __pyx_L2;
  }
  /*else*/ {
    (__pyx_v_new_block[0]) = 0;
  }
  __pyx_L2:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":582 */
  __pyx_2 = (PyObject *)(__pyx_v_p_current_dirname[0]);
  Py_INCREF(__pyx_2);
  __pyx_3 = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)__pyx_v_self->__pyx_vtab)->get_next_str(__pyx_v_self); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; goto __pyx_L1;}
  __pyx_4 = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)__pyx_v_self->__pyx_vtab)->get_next_str(__pyx_v_self); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  Py_DECREF(__pyx_v_path_name_file_id_key);
  __pyx_v_path_name_file_id_key = __pyx_5;
  __pyx_5 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":600 */
  __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;}
  Py_DECREF(__pyx_v_trees);
  __pyx_v_trees = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":601 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_num_trees; ++__pyx_v_i) {

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":602 */
    __pyx_3 = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)__pyx_v_self->__pyx_vtab)->get_next_str(__pyx_v_self); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; goto __pyx_L1;}
    Py_DECREF(__pyx_v_minikind);
    __pyx_v_minikind = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":603 */
    __pyx_4 = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)__pyx_v_self->__pyx_vtab)->get_next_str(__pyx_v_self); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; goto __pyx_L1;}
    Py_DECREF(__pyx_v_fingerprint);
    __pyx_v_fingerprint = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":604 */
    __pyx_v_entry_size_cstr = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)__pyx_v_self->__pyx_vtab)->get_next(__pyx_v_self,(&__pyx_v_cur_size));

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":605 */
    __pyx_v_entry_size = strtoul(__pyx_v_entry_size_cstr,NULL,10);

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":606 */
    __pyx_v_executable_cstr = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)__pyx_v_self->__pyx_vtab)->get_next(__pyx_v_self,(&__pyx_v_cur_size));

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":607 */
    __pyx_v_is_executable = ((__pyx_v_executable_cstr[0]) == 'y');

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":608 */
    __pyx_5 = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)__pyx_v_self->__pyx_vtab)->get_next_str(__pyx_v_self); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; goto __pyx_L1;}
    Py_DECREF(__pyx_v_info);
    __pyx_v_info = __pyx_5;
    __pyx_5 = 0;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":609 */
    __pyx_2 = PyLong_FromUnsignedLong(__pyx_v_entry_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_is_executable); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; goto __pyx_L1;}
    Py_INCREF(__pyx_v_minikind);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_minikind);
    Py_INCREF(__pyx_v_fingerprint);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_fingerprint);
    PyTuple_SET_ITEM(__pyx_4, 2, __pyx_2);
    PyTuple_SET_ITEM(__pyx_4, 3, __pyx_3);
    Py_INCREF(__pyx_v_info);
    PyTuple_SET_ITEM(__pyx_4, 4, __pyx_v_info);
    __pyx_2 = 0;
    __pyx_3 = 0;
    __pyx_1 = PyList_Append(__pyx_v_trees,__pyx_4); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":618 */
  __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;}
  Py_INCREF(__pyx_v_path_name_file_id_key);
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_path_name_file_id_key);
  Py_INCREF(__pyx_v_trees);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_trees);
  Py_DECREF(__pyx_v_ret);
  __pyx_v_ret = __pyx_5;
  __pyx_5 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":622 */
  __pyx_v_trailing = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)__pyx_v_self->__pyx_vtab)->get_next(__pyx_v_self,(&__pyx_v_cur_size));

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":623 */
  __pyx_1 = (__pyx_v_cur_size != 1);
  if (!__pyx_1) {
    __pyx_1 = ((__pyx_v_trailing[0]) != '\n');
  }
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_AssertionError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_cur_size); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; goto __pyx_L1;}
    __pyx_4 = PyString_FromStringAndSize(__pyx_v_trailing,__pyx_v_cur_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
    Py_INCREF(__pyx_v_ret);
    PyTuple_SET_ITEM(__pyx_5, 2, __pyx_v_ret);
    __pyx_3 = 0;
    __pyx_4 = 0;
    __pyx_3 = PyNumber_Remainder(__pyx_k20p, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; 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 = 624; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 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 = 624; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":628 */
  Py_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_dirstate_helpers_c.Reader._get_entry");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_path_name_file_id_key);
  Py_DECREF(__pyx_v_minikind);
  Py_DECREF(__pyx_v_fingerprint);
  Py_DECREF(__pyx_v_info);
  Py_DECREF(__pyx_v_dirname);
  Py_DECREF(__pyx_v_trees);
  Py_DECREF(__pyx_v_ret);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n__num_present_parents;
static PyObject *__pyx_n__num_entries;
static PyObject *__pyx_n__dirblocks;
static PyObject *__pyx_n__split_root_dirblock_into_contents;

static PyObject *__pyx_k21p;
static PyObject *__pyx_k22p;
static PyObject *__pyx_k23p;
static PyObject *__pyx_k24p;

static char __pyx_k21[] = "";
static char __pyx_k22[] = "";
static char __pyx_k23[] = "";
static char __pyx_k24[] = "We read the wrong number of entries. We expected to read %s, but read %s";

static PyObject *__pyx_f_19_dirstate_helpers_c_6Reader__parse_dirblocks(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_19_dirstate_helpers_c_6Reader__parse_dirblocks[] = "Parse all dirblocks in the state file.";
static PyObject *__pyx_f_19_dirstate_helpers_c_6Reader__parse_dirblocks(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_state = 0;
  int __pyx_v_num_trees;
  PyObject *__pyx_v_current_block;
  PyObject *__pyx_v_entry;
  void *__pyx_v_current_dirname;
  int __pyx_v_new_block;
  int __pyx_v_expected_entry_count;
  int __pyx_v_entry_count;
  PyObject *__pyx_v_obj;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"state",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_state)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_state);
  __pyx_v_current_block = Py_None; Py_INCREF(Py_None);
  __pyx_v_entry = Py_None; Py_INCREF(Py_None);
  __pyx_v_obj = Py_None; Py_INCREF(Py_None);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":640 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_state, __pyx_n__num_present_parents); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}
  __pyx_3 = PyNumber_Add(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_v_num_trees = __pyx_4;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":641 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_state, __pyx_n__num_entries); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; goto __pyx_L1;}
  __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_expected_entry_count = __pyx_4;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":644 */
  __pyx_4 = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->__pyx_vtab)->_init(((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)); if (__pyx_4 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}

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

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":647 */
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;}
  Py_INCREF(__pyx_k21p);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k21p);
  Py_INCREF(__pyx_v_current_block);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_current_block);
  __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;}
  Py_INCREF(__pyx_k22p);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k22p);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyList_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;}
  PyList_SET_ITEM(__pyx_2, 0, __pyx_3);
  PyList_SET_ITEM(__pyx_2, 1, __pyx_1);
  __pyx_3 = 0;
  __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_v_state, __pyx_n__dirblocks, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":648 */
  Py_INCREF(__pyx_k23p);
  Py_DECREF(__pyx_v_obj);
  __pyx_v_obj = __pyx_k23p;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":649 */
  __pyx_v_current_dirname = ((void *)__pyx_v_obj);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":650 */
  __pyx_v_new_block = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":651 */
  __pyx_v_entry_count = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":660 */
  while (1) {
    __pyx_4 = (((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->cur_cstr < ((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->end_cstr);
    if (!__pyx_4) break;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":661 */
    __pyx_3 = ((struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader *)((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self)->__pyx_vtab)->_get_entry(((struct __pyx_obj_19_dirstate_helpers_c_Reader *)__pyx_v_self),__pyx_v_num_trees,(&__pyx_v_current_dirname),(&__pyx_v_new_block)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; goto __pyx_L1;}
    Py_DECREF(__pyx_v_entry);
    __pyx_v_entry = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":662 */
    __pyx_4 = __pyx_v_new_block;
    if (__pyx_4) {

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

      /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":665 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_state, __pyx_n__dirblocks); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;}
      __pyx_3 = (PyObject *)__pyx_v_current_dirname;
      Py_INCREF(__pyx_3);
      __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
      Py_INCREF(__pyx_v_current_block);
      PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_current_block);
      __pyx_3 = 0;
      __pyx_4 = PyList_Append(__pyx_2,__pyx_1); if (__pyx_4 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":667 */
    __pyx_4 = PyList_Append(__pyx_v_current_block,__pyx_v_entry); if (__pyx_4 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; goto __pyx_L1;}

    /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":668 */
    __pyx_v_entry_count = (__pyx_v_entry_count + 1);
  }

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":669 */
  __pyx_4 = (__pyx_v_entry_count != __pyx_v_expected_entry_count);
  if (__pyx_4) {
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_AssertionError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong(__pyx_v_expected_entry_count); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}
    __pyx_1 = PyInt_FromLong(__pyx_v_entry_count); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1);
    __pyx_2 = 0;
    __pyx_1 = 0;
    __pyx_2 = PyNumber_Remainder(__pyx_k24p, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":673 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_state, __pyx_n__split_root_dirblock_into_contents); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __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);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_dirstate_helpers_c.Reader._parse_dirblocks");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_current_block);
  Py_DECREF(__pyx_v_entry);
  Py_DECREF(__pyx_v_obj);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_state);
  return __pyx_r;
}

static PyObject *__pyx_n__state_file;
static PyObject *__pyx_n_seek;
static PyObject *__pyx_n__end_of_header;
static PyObject *__pyx_n_read;
static PyObject *__pyx_n__parse_dirblocks;
static PyObject *__pyx_n_IN_MEMORY_UNMODIFIED;
static PyObject *__pyx_n__dirblock_state;

static PyObject *__pyx_f_19_dirstate_helpers_c__read_dirblocks_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_19_dirstate_helpers_c__read_dirblocks_c[] = "Read in the dirblocks for the given DirState object.\n\n    This is tightly bound to the DirState internal representation. It should be\n    thought of as a member function, which is only separated out so that we can\n    re-write it in pyrex.\n\n    :param state: A DirState object.\n    :return: None\n    :postcondition: The dirblocks will be loaded into the appropriate fields in\n        the DirState object.\n    ";
static PyObject *__pyx_f_19_dirstate_helpers_c__read_dirblocks_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v_text;
  PyObject *__pyx_v_reader;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"state",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_state)) return 0;
  Py_INCREF(__pyx_v_state);
  __pyx_v_text = Py_None; Py_INCREF(Py_None);
  __pyx_v_reader = Py_None; Py_INCREF(Py_None);

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":688 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_state, __pyx_n__state_file); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_seek); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_v_state, __pyx_n__end_of_header); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  __pyx_1 = 0;
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

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

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":692 */
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; goto __pyx_L1;}
  Py_INCREF(__pyx_v_text);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_text);
  __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_19_dirstate_helpers_c_Reader), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_v_reader);
  __pyx_v_reader = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":694 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_reader, __pyx_n__parse_dirblocks); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; goto __pyx_L1;}
  Py_INCREF(__pyx_v_state);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_state);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; 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/_dirstate_helpers_c.pyx":695 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DirState); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_IN_MEMORY_UNMODIFIED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_v_state, __pyx_n__dirblock_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; goto __pyx_L1;}
  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);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_dirstate_helpers_c._read_dirblocks_c");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_text);
  Py_DECREF(__pyx_v_reader);
  Py_DECREF(__pyx_v_state);
  return __pyx_r;
}

static __Pyx_InternTabEntry __pyx_intern_tab[] = {
  {&__pyx_n_AssertionError, "AssertionError"},
  {&__pyx_n_DirState, "DirState"},
  {&__pyx_n_IN_MEMORY_UNMODIFIED, "IN_MEMORY_UNMODIFIED"},
  {&__pyx_n_TypeError, "TypeError"},
  {&__pyx_n__dirblock_state, "_dirblock_state"},
  {&__pyx_n__dirblocks, "_dirblocks"},
  {&__pyx_n__end_of_header, "_end_of_header"},
  {&__pyx_n__num_entries, "_num_entries"},
  {&__pyx_n__num_present_parents, "_num_present_parents"},
  {&__pyx_n__parse_dirblocks, "_parse_dirblocks"},
  {&__pyx_n__split_root_dirblock_into_contents, "_split_root_dirblock_into_contents"},
  {&__pyx_n__state_file, "_state_file"},
  {&__pyx_n_read, "read"},
  {&__pyx_n_seek, "seek"},
  {&__pyx_n_type, "type"},
  {0, 0}
};

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_k1p, __pyx_k1, sizeof(__pyx_k1)},
  {&__pyx_k6p, __pyx_k6, sizeof(__pyx_k6)},
  {&__pyx_k7p, __pyx_k7, sizeof(__pyx_k7)},
  {&__pyx_k8p, __pyx_k8, sizeof(__pyx_k8)},
  {&__pyx_k9p, __pyx_k9, sizeof(__pyx_k9)},
  {&__pyx_k10p, __pyx_k10, sizeof(__pyx_k10)},
  {&__pyx_k13p, __pyx_k13, sizeof(__pyx_k13)},
  {&__pyx_k14p, __pyx_k14, sizeof(__pyx_k14)},
  {&__pyx_k15p, __pyx_k15, sizeof(__pyx_k15)},
  {&__pyx_k16p, __pyx_k16, sizeof(__pyx_k16)},
  {&__pyx_k17p, __pyx_k17, sizeof(__pyx_k17)},
  {&__pyx_k18p, __pyx_k18, sizeof(__pyx_k18)},
  {&__pyx_k19p, __pyx_k19, sizeof(__pyx_k19)},
  {&__pyx_k20p, __pyx_k20, sizeof(__pyx_k20)},
  {&__pyx_k21p, __pyx_k21, sizeof(__pyx_k21)},
  {&__pyx_k22p, __pyx_k22, sizeof(__pyx_k22)},
  {&__pyx_k23p, __pyx_k23, sizeof(__pyx_k23)},
  {&__pyx_k24p, __pyx_k24, sizeof(__pyx_k24)},
  {0, 0, 0}
};
static struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader __pyx_vtable_19_dirstate_helpers_c_Reader;

static PyObject *__pyx_tp_new_19_dirstate_helpers_c_Reader(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_19_dirstate_helpers_c_Reader *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_19_dirstate_helpers_c_Reader *)o);
  *(struct __pyx_vtabstruct_19_dirstate_helpers_c_Reader **)&p->__pyx_vtab = __pyx_vtabptr_19_dirstate_helpers_c_Reader;
  p->text = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_19_dirstate_helpers_c_Reader(PyObject *o) {
  struct __pyx_obj_19_dirstate_helpers_c_Reader *p = (struct __pyx_obj_19_dirstate_helpers_c_Reader *)o;
  Py_XDECREF(p->text);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_19_dirstate_helpers_c_Reader(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_19_dirstate_helpers_c_Reader *p = (struct __pyx_obj_19_dirstate_helpers_c_Reader *)o;
  if (p->text) {
    e = (*v)(p->text, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_19_dirstate_helpers_c_Reader(PyObject *o) {
  struct __pyx_obj_19_dirstate_helpers_c_Reader *p = (struct __pyx_obj_19_dirstate_helpers_c_Reader *)o;
  Py_XDECREF(p->text);
  p->text = Py_None; Py_INCREF(Py_None);
  return 0;
}

static struct PyMethodDef __pyx_methods_19_dirstate_helpers_c_Reader[] = {
  {"_parse_dirblocks", (PyCFunction)__pyx_f_19_dirstate_helpers_c_6Reader__parse_dirblocks, METH_VARARGS|METH_KEYWORDS, __pyx_doc_19_dirstate_helpers_c_6Reader__parse_dirblocks},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Reader = {
  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_Reader = {
  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_Reader = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

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

PyTypeObject __pyx_type_19_dirstate_helpers_c_Reader = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_dirstate_helpers_c.Reader", /*tp_name*/
  sizeof(struct __pyx_obj_19_dirstate_helpers_c_Reader), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_19_dirstate_helpers_c_Reader, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Reader, /*tp_as_number*/
  &__pyx_tp_as_sequence_Reader, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Reader, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Reader, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Maintain the current location, and return fields as you parse them.", /*tp_doc*/
  __pyx_tp_traverse_19_dirstate_helpers_c_Reader, /*tp_traverse*/
  __pyx_tp_clear_19_dirstate_helpers_c_Reader, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_19_dirstate_helpers_c_Reader, /*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_19_dirstate_helpers_c_6Reader___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_19_dirstate_helpers_c_Reader, /*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[] = {
  {"_py_memrchr", (PyCFunction)__pyx_f_19_dirstate_helpers_c__py_memrchr, METH_VARARGS|METH_KEYWORDS, __pyx_doc_19_dirstate_helpers_c__py_memrchr},
  {"cmp_by_dirs_c", (PyCFunction)__pyx_f_19_dirstate_helpers_c_cmp_by_dirs_c, METH_VARARGS|METH_KEYWORDS, __pyx_doc_19_dirstate_helpers_c_cmp_by_dirs_c},
  {"_cmp_path_by_dirblock_c", (PyCFunction)__pyx_f_19_dirstate_helpers_c__cmp_path_by_dirblock_c, METH_VARARGS|METH_KEYWORDS, __pyx_doc_19_dirstate_helpers_c__cmp_path_by_dirblock_c},
  {"_bisect_path_left_c", (PyCFunction)__pyx_f_19_dirstate_helpers_c__bisect_path_left_c, METH_VARARGS|METH_KEYWORDS, __pyx_doc_19_dirstate_helpers_c__bisect_path_left_c},
  {"_bisect_path_right_c", (PyCFunction)__pyx_f_19_dirstate_helpers_c__bisect_path_right_c, METH_VARARGS|METH_KEYWORDS, __pyx_doc_19_dirstate_helpers_c__bisect_path_right_c},
  {"bisect_dirblock_c", (PyCFunction)__pyx_f_19_dirstate_helpers_c_bisect_dirblock_c, METH_VARARGS|METH_KEYWORDS, __pyx_doc_19_dirstate_helpers_c_bisect_dirblock_c},
  {"_read_dirblocks_c", (PyCFunction)__pyx_f_19_dirstate_helpers_c__read_dirblocks_c, METH_VARARGS|METH_KEYWORDS, __pyx_doc_19_dirstate_helpers_c__read_dirblocks_c},
  {0, 0, 0, 0}
};

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

PyMODINIT_FUNC init_dirstate_helpers_c(void); /*proto*/
PyMODINIT_FUNC init_dirstate_helpers_c(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("_dirstate_helpers_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_19_dirstate_helpers_c_Reader = &__pyx_vtable_19_dirstate_helpers_c_Reader;
  *(void(**)(void))&__pyx_vtable_19_dirstate_helpers_c_Reader.get_next = (void(*)(void))__pyx_f_19_dirstate_helpers_c_6Reader_get_next;
  *(void(**)(void))&__pyx_vtable_19_dirstate_helpers_c_Reader.get_next_str = (void(*)(void))__pyx_f_19_dirstate_helpers_c_6Reader_get_next_str;
  *(void(**)(void))&__pyx_vtable_19_dirstate_helpers_c_Reader._init = (void(*)(void))__pyx_f_19_dirstate_helpers_c_6Reader__init;
  *(void(**)(void))&__pyx_vtable_19_dirstate_helpers_c_Reader._get_entry = (void(*)(void))__pyx_f_19_dirstate_helpers_c_6Reader__get_entry;
  __pyx_type_19_dirstate_helpers_c_Reader.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_19_dirstate_helpers_c_Reader) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_19_dirstate_helpers_c_Reader.tp_dict, __pyx_vtabptr_19_dirstate_helpers_c_Reader) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Reader", (PyObject *)&__pyx_type_19_dirstate_helpers_c_Reader) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; goto __pyx_L1;}
  __pyx_ptype_19_dirstate_helpers_c_Reader = &__pyx_type_19_dirstate_helpers_c_Reader;

  /* "/home/jameinel/dev/bzr/releases/bzr.1.6/bzrlib/_dirstate_helpers_c.pyx":22 */
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
  Py_INCREF(__pyx_n_DirState);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_n_DirState);
  __pyx_2 = __Pyx_Import(__pyx_k1p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_DirState); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_DirState, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; 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/_dirstate_helpers_c.pyx":421 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;}
  __pyx_k3 = __pyx_2;
  __pyx_2 = 0;
  Py_INCREF(Py_None);
  __pyx_k4 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k5 = Py_None;

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

static char *__pyx_filenames[] = {
  "_dirstate_helpers_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 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);
}
