/* Generated by Pyrex 0.9.8.5 on Thu Nov 25 16:59:20 2010 */

#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
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #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 "python-compat.h"


typedef struct {PyObject **p; int i; 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[] = "Functionality for doing annotations in the \'optimal\' way";

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

static PyObject *__Pyx_UnpackItem(PyObject *); /*proto*/
static int __Pyx_EndUnpack(PyObject *); /*proto*/

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

static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i); /*proto*/

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

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

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/

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

/* Declarations from bzrlib._annotator_pyx */


/* Declarations from implementation of bzrlib._annotator_pyx */

static int __pyx_f_6bzrlib_14_annotator_pyx__check_annotations_are_lists(PyObject *,PyObject *); /*proto*/
static int __pyx_f_6bzrlib_14_annotator_pyx__check_match_ranges(PyObject *,PyObject *,Py_ssize_t,Py_ssize_t,Py_ssize_t); /*proto*/
static PyObject *__pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(PyObject *,Py_ssize_t *); /*proto*/
static PyObject *__pyx_f_6bzrlib_14_annotator_pyx__combine_annotations(PyObject *,PyObject *,PyObject *); /*proto*/
static int __pyx_f_6bzrlib_14_annotator_pyx__apply_parent_annotations(PyObject *,PyObject *,PyObject *); /*proto*/
static int __pyx_f_6bzrlib_14_annotator_pyx__merge_annotations(PyObject *,PyObject *,PyObject *,PyObject *,PyObject *); /*proto*/

static char __pyx_k1[] = "annotations must be a list";
static char __pyx_k2[] = "parent_annotations must be a list";
static char __pyx_k3[] = "Match length exceeds len of parent_annotations %s > %s";
static char __pyx_k4[] = "Match length exceeds len of annotations %s > %s";
static char __pyx_k5[] = "annotations must be tuples";
static char __pyx_k6[] = "_get_parent_annotations_and_matches";
static char __pyx_k7[] = "_ann_tuple_cache";
static char __pyx_k8[] = "bzrlib";
static char __pyx_k9[] = "annotate";
static char __pyx_k10[] = "_break_annotation_tie";
static char __pyx_k11[] = "_get_heads_provider";
static char __pyx_k12[] = "heads";
static char __pyx_k13[] = "_resolve_annotation_tie";
static char __pyx_k14[] = "_annotator_py";
static char __pyx_k15[] = "Annotator";
static char __pyx_k16[] = "Class that drives performing annotations.";
static char __pyx_k17[] = "_update_from_first_parent";
static char __pyx_k18[] = "_update_from_other_parents";
static char __pyx_k19[] = "annotate_flat";

static PyObject *__pyx_n_Annotator;
static PyObject *__pyx_n__ann_tuple_cache;
static PyObject *__pyx_n__annotator_py;
static PyObject *__pyx_n__break_annotation_tie;
static PyObject *__pyx_n__get_heads_provider;
static PyObject *__pyx_n__resolve_annotation_tie;
static PyObject *__pyx_n__update_from_first_parent;
static PyObject *__pyx_n__update_from_other_parents;
static PyObject *__pyx_n_annotate;
static PyObject *__pyx_n_annotate_flat;
static PyObject *__pyx_n_bzrlib;
static PyObject *__pyx_n_heads;

static PyObject *__pyx_k1p;
static PyObject *__pyx_k2p;
static PyObject *__pyx_k3p;
static PyObject *__pyx_k4p;
static PyObject *__pyx_k5p;
static PyObject *__pyx_k6p;
static PyObject *__pyx_k16p;

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_Annotator, 1, __pyx_k15, sizeof(__pyx_k15)},
  {&__pyx_n__ann_tuple_cache, 1, __pyx_k7, sizeof(__pyx_k7)},
  {&__pyx_n__annotator_py, 1, __pyx_k14, sizeof(__pyx_k14)},
  {&__pyx_n__break_annotation_tie, 1, __pyx_k10, sizeof(__pyx_k10)},
  {&__pyx_n__get_heads_provider, 1, __pyx_k11, sizeof(__pyx_k11)},
  {&__pyx_n__resolve_annotation_tie, 1, __pyx_k13, sizeof(__pyx_k13)},
  {&__pyx_n__update_from_first_parent, 1, __pyx_k17, sizeof(__pyx_k17)},
  {&__pyx_n__update_from_other_parents, 1, __pyx_k18, sizeof(__pyx_k18)},
  {&__pyx_n_annotate, 1, __pyx_k9, sizeof(__pyx_k9)},
  {&__pyx_n_annotate_flat, 1, __pyx_k19, sizeof(__pyx_k19)},
  {&__pyx_n_bzrlib, 1, __pyx_k8, sizeof(__pyx_k8)},
  {&__pyx_n_heads, 1, __pyx_k12, sizeof(__pyx_k12)},
  {&__pyx_k1p, 0, __pyx_k1, sizeof(__pyx_k1)},
  {&__pyx_k2p, 0, __pyx_k2, sizeof(__pyx_k2)},
  {&__pyx_k3p, 0, __pyx_k3, sizeof(__pyx_k3)},
  {&__pyx_k4p, 0, __pyx_k4, sizeof(__pyx_k4)},
  {&__pyx_k5p, 0, __pyx_k5, sizeof(__pyx_k5)},
  {&__pyx_k6p, 0, __pyx_k6, sizeof(__pyx_k6)},
  {&__pyx_k16p, 0, __pyx_k16, sizeof(__pyx_k16)},
  {0, 0, 0, 0}
};



/* Implementation of bzrlib._annotator_pyx */

static int __pyx_f_6bzrlib_14_annotator_pyx__check_annotations_are_lists(PyObject *__pyx_v_annotations,PyObject *__pyx_v_parent_annotations) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_annotations);
  Py_INCREF(__pyx_v_parent_annotations);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":63 */
  __pyx_1 = (!PyList_CheckExact(__pyx_v_annotations));
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
    Py_INCREF(__pyx_k1p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k1p);
    __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":65 */
  __pyx_1 = (!PyList_CheckExact(__pyx_v_parent_annotations));
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
    Py_INCREF(__pyx_k2p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k2p);
    __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":67 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._annotator_pyx._check_annotations_are_lists");
  __pyx_r = (-1);
  __pyx_L0:;
  Py_DECREF(__pyx_v_annotations);
  Py_DECREF(__pyx_v_parent_annotations);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_14_annotator_pyx__check_match_ranges(PyObject *__pyx_v_parent_annotations,PyObject *__pyx_v_annotations,Py_ssize_t __pyx_v_parent_idx,Py_ssize_t __pyx_v_lines_idx,Py_ssize_t __pyx_v_match_len) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_parent_annotations);
  Py_INCREF(__pyx_v_annotations);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":73 */
  __pyx_1 = ((__pyx_v_parent_idx + __pyx_v_match_len) > PyList_GET_SIZE(__pyx_v_parent_annotations));
  if (__pyx_1) {
    __pyx_2 = PyInt_FromSsize_t((__pyx_v_parent_idx + __pyx_v_match_len)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; goto __pyx_L1;}
    __pyx_3 = PyInt_FromSsize_t(PyList_GET_SIZE(__pyx_v_parent_annotations)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
    __pyx_2 = 0;
    __pyx_3 = 0;
    __pyx_2 = PyNumber_Remainder(__pyx_k3p, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":78 */
  __pyx_1 = ((__pyx_v_lines_idx + __pyx_v_match_len) > PyList_GET_SIZE(__pyx_v_annotations));
  if (__pyx_1) {
    __pyx_2 = PyInt_FromSsize_t((__pyx_v_lines_idx + __pyx_v_match_len)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;}
    __pyx_3 = PyInt_FromSsize_t(PyList_GET_SIZE(__pyx_v_annotations)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
    __pyx_2 = 0;
    __pyx_3 = 0;
    __pyx_2 = PyNumber_Remainder(__pyx_k4p, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":83 */
  __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("bzrlib._annotator_pyx._check_match_ranges");
  __pyx_r = (-1);
  __pyx_L0:;
  Py_DECREF(__pyx_v_parent_annotations);
  Py_DECREF(__pyx_v_annotations);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(PyObject *__pyx_v_tpl,Py_ssize_t *__pyx_v_pos) {
  PyObject *__pyx_r;
  int __pyx_1;
  Py_INCREF(__pyx_v_tpl);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":94 */
  (__pyx_v_pos[0]) = ((__pyx_v_pos[0]) + 1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":95 */
  __pyx_1 = ((__pyx_v_pos[0]) >= PyTuple_GET_SIZE(__pyx_v_tpl));
  if (__pyx_1) {
    __pyx_r = NULL;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":97 */
  __pyx_r = PyTuple_GET_ITEM(__pyx_v_tpl,(__pyx_v_pos[0]));
  goto __pyx_L0;

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

static PyObject *__pyx_f_6bzrlib_14_annotator_pyx__combine_annotations(PyObject *__pyx_v_ann_one,PyObject *__pyx_v_ann_two,PyObject *__pyx_v_cache) {
  Py_ssize_t __pyx_v_pos_one;
  Py_ssize_t __pyx_v_pos_two;
  Py_ssize_t __pyx_v_out_pos;
  PyObject *__pyx_v_temp;
  PyObject *__pyx_v_left;
  PyObject *__pyx_v_right;
  PyObject *__pyx_v_cache_key;
  PyObject *__pyx_v_new_ann;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_ann_one);
  Py_INCREF(__pyx_v_ann_two);
  Py_INCREF(__pyx_v_cache);
  __pyx_v_cache_key = Py_None; Py_INCREF(Py_None);
  __pyx_v_new_ann = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":106 */
  __pyx_1 = PyObject_RichCompareBool(__pyx_v_ann_one,__pyx_v_ann_two,Py_LT); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;}
    Py_INCREF(__pyx_v_ann_one);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_ann_one);
    Py_INCREF(__pyx_v_ann_two);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_ann_two);
    Py_DECREF(__pyx_v_cache_key);
    __pyx_v_cache_key = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_INCREF(__pyx_v_ann_two);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_ann_two);
    Py_INCREF(__pyx_v_ann_one);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_ann_one);
    Py_DECREF(__pyx_v_cache_key);
    __pyx_v_cache_key = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":110 */
  __pyx_v_temp = PyDict_GetItem(__pyx_v_cache,__pyx_v_cache_key);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":111 */
  __pyx_1 = (__pyx_v_temp != NULL);
  if (__pyx_1) {
    Py_INCREF(((PyObject *)__pyx_v_temp));
    __pyx_r = ((PyObject *)__pyx_v_temp);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":114 */
  __pyx_1 = (!PyTuple_CheckExact(__pyx_v_ann_one));
  if (!__pyx_1) {
    __pyx_1 = (!PyTuple_CheckExact(__pyx_v_ann_two));
  }
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}
    Py_INCREF(__pyx_k5p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k5p);
    __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":118 */
  __pyx_v_pos_one = (-1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":119 */
  __pyx_v_pos_two = (-1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":120 */
  __pyx_v_out_pos = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":121 */
  __pyx_v_left = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_one,(&__pyx_v_pos_one));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":122 */
  __pyx_v_right = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_two,(&__pyx_v_pos_two));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":123 */
  __pyx_2 = PyTuple_New((PyTuple_GET_SIZE(__pyx_v_ann_one) + PyTuple_GET_SIZE(__pyx_v_ann_two))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
  Py_DECREF(__pyx_v_new_ann);
  __pyx_v_new_ann = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":125 */
  while (1) {
    __pyx_1 = (__pyx_v_left != NULL);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_right != NULL);
    }
    if (!__pyx_1) break;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":129 */
    __pyx_1 = (__pyx_v_left == __pyx_v_right);
    if (!__pyx_1) {
      __pyx_1 = PyObject_RichCompareBool(__pyx_v_left,__pyx_v_right,Py_EQ);
    }
    if (__pyx_1) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":132 */
      Py_INCREF(__pyx_v_left);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":133 */
      PyTuple_SET_ITEM(__pyx_v_new_ann,__pyx_v_out_pos,__pyx_v_left);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":134 */
      __pyx_v_left = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_one,(&__pyx_v_pos_one));

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":135 */
      __pyx_v_right = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_two,(&__pyx_v_pos_two));
      goto __pyx_L7;
    }
    __pyx_1 = PyObject_RichCompareBool(__pyx_v_left,__pyx_v_right,Py_LT);
    if (__pyx_1) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":138 */
      Py_INCREF(__pyx_v_left);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":139 */
      PyTuple_SET_ITEM(__pyx_v_new_ann,__pyx_v_out_pos,__pyx_v_left);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":140 */
      __pyx_v_left = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_one,(&__pyx_v_pos_one));
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":142 */
      Py_INCREF(__pyx_v_right);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":143 */
      PyTuple_SET_ITEM(__pyx_v_new_ann,__pyx_v_out_pos,__pyx_v_right);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":144 */
      __pyx_v_right = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_two,(&__pyx_v_pos_two));
    }
    __pyx_L7:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":145 */
    __pyx_v_out_pos = (__pyx_v_out_pos + 1);
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":146 */
  while (1) {
    __pyx_1 = (__pyx_v_left != NULL);
    if (!__pyx_1) break;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":147 */
    Py_INCREF(__pyx_v_left);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":148 */
    PyTuple_SET_ITEM(__pyx_v_new_ann,__pyx_v_out_pos,__pyx_v_left);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":149 */
    __pyx_v_left = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_one,(&__pyx_v_pos_one));

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":150 */
    __pyx_v_out_pos = (__pyx_v_out_pos + 1);
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":151 */
  while (1) {
    __pyx_1 = (__pyx_v_right != NULL);
    if (!__pyx_1) break;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":152 */
    Py_INCREF(__pyx_v_right);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":153 */
    PyTuple_SET_ITEM(__pyx_v_new_ann,__pyx_v_out_pos,__pyx_v_right);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":154 */
    __pyx_v_right = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_two,(&__pyx_v_pos_two));

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":155 */
    __pyx_v_out_pos = (__pyx_v_out_pos + 1);
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":156 */
  __pyx_1 = (__pyx_v_out_pos != PyTuple_GET_SIZE(__pyx_v_new_ann));
  if (__pyx_1) {
    __pyx_3 = PySequence_GetSlice(__pyx_v_new_ann, 0, __pyx_v_out_pos); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}
    Py_DECREF(__pyx_v_new_ann);
    __pyx_v_new_ann = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":160 */
  __pyx_1 = PyDict_SetItem(__pyx_v_cache,__pyx_v_cache_key,__pyx_v_new_ann); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":161 */
  Py_INCREF(__pyx_v_new_ann);
  __pyx_r = __pyx_v_new_ann;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._annotator_pyx._combine_annotations");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_cache_key);
  Py_DECREF(__pyx_v_new_ann);
  Py_DECREF(__pyx_v_ann_one);
  Py_DECREF(__pyx_v_ann_two);
  Py_DECREF(__pyx_v_cache);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_14_annotator_pyx__apply_parent_annotations(PyObject *__pyx_v_annotations,PyObject *__pyx_v_parent_annotations,PyObject *__pyx_v_matching_blocks) {
  Py_ssize_t __pyx_v_parent_idx;
  Py_ssize_t __pyx_v_lines_idx;
  Py_ssize_t __pyx_v_match_len;
  Py_ssize_t __pyx_v_idx;
  PyListObject *__pyx_v_par_list;
  PyListObject *__pyx_v_ann_list;
  PyObject **__pyx_v_par_temp;
  PyObject **__pyx_v_ann_temp;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_ssize_t __pyx_5;
  Py_INCREF(__pyx_v_annotations);
  Py_INCREF(__pyx_v_parent_annotations);
  Py_INCREF(__pyx_v_matching_blocks);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":174 */
  __pyx_1 = __pyx_f_6bzrlib_14_annotator_pyx__check_annotations_are_lists(__pyx_v_annotations,__pyx_v_parent_annotations); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":175 */
  __pyx_v_par_list = ((PyListObject *)__pyx_v_parent_annotations);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":176 */
  __pyx_v_ann_list = ((PyListObject *)__pyx_v_annotations);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":181 */
  __pyx_2 = PyObject_GetIter(__pyx_v_matching_blocks); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}
  for (;;) {
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}
      break;
    }
    __pyx_4 = PyObject_GetIter(__pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}
    __pyx_5 = PyInt_AsSsize_t(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_parent_idx = __pyx_5;
    __pyx_3 = __Pyx_UnpackItem(__pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}
    __pyx_5 = PyInt_AsSsize_t(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_lines_idx = __pyx_5;
    __pyx_3 = __Pyx_UnpackItem(__pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}
    __pyx_5 = PyInt_AsSsize_t(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_match_len = __pyx_5;
    if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":182 */
    __pyx_1 = __pyx_f_6bzrlib_14_annotator_pyx__check_match_ranges(__pyx_v_parent_annotations,__pyx_v_annotations,__pyx_v_parent_idx,__pyx_v_lines_idx,__pyx_v_match_len); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":184 */
    __pyx_v_par_temp = (__pyx_v_par_list->ob_item + __pyx_v_parent_idx);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":185 */
    __pyx_v_ann_temp = (__pyx_v_ann_list->ob_item + __pyx_v_lines_idx);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":186 */
    for (__pyx_v_idx = 0; __pyx_v_idx < __pyx_v_match_len; ++__pyx_v_idx) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":187 */
      Py_INCREF((__pyx_v_par_temp[__pyx_v_idx]));

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":188 */
      Py_DECREF((__pyx_v_ann_temp[__pyx_v_idx]));

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":189 */
      (__pyx_v_ann_temp[__pyx_v_idx]) = (__pyx_v_par_temp[__pyx_v_idx]);
    }
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":190 */
  __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("bzrlib._annotator_pyx._apply_parent_annotations");
  __pyx_r = (-1);
  __pyx_L0:;
  Py_DECREF(__pyx_v_annotations);
  Py_DECREF(__pyx_v_parent_annotations);
  Py_DECREF(__pyx_v_matching_blocks);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_14_annotator_pyx__merge_annotations(PyObject *__pyx_v_this_annotation,PyObject *__pyx_v_annotations,PyObject *__pyx_v_parent_annotations,PyObject *__pyx_v_matching_blocks,PyObject *__pyx_v_ann_cache) {
  Py_ssize_t __pyx_v_parent_idx;
  Py_ssize_t __pyx_v_ann_idx;
  Py_ssize_t __pyx_v_lines_idx;
  Py_ssize_t __pyx_v_match_len;
  Py_ssize_t __pyx_v_idx;
  PyObject *__pyx_v_ann_temp;
  PyObject *__pyx_v_par_temp;
  PyObject *__pyx_v_last_ann;
  PyObject *__pyx_v_last_parent;
  PyObject *__pyx_v_last_res;
  PyObject *__pyx_v_par_ann;
  PyObject *__pyx_v_ann;
  PyObject *__pyx_v_new_ann;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_ssize_t __pyx_5;
  Py_INCREF(__pyx_v_this_annotation);
  Py_INCREF(__pyx_v_annotations);
  Py_INCREF(__pyx_v_parent_annotations);
  Py_INCREF(__pyx_v_matching_blocks);
  Py_INCREF(__pyx_v_ann_cache);
  __pyx_v_last_ann = Py_None; Py_INCREF(Py_None);
  __pyx_v_last_parent = Py_None; Py_INCREF(Py_None);
  __pyx_v_last_res = Py_None; Py_INCREF(Py_None);
  __pyx_v_par_ann = Py_None; Py_INCREF(Py_None);
  __pyx_v_ann = Py_None; Py_INCREF(Py_None);
  __pyx_v_new_ann = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":199 */
  __pyx_1 = __pyx_f_6bzrlib_14_annotator_pyx__check_annotations_are_lists(__pyx_v_annotations,__pyx_v_parent_annotations); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":200 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_last_ann);
  __pyx_v_last_ann = Py_None;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":201 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_last_parent);
  __pyx_v_last_parent = Py_None;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":202 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_last_res);
  __pyx_v_last_res = Py_None;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":203 */
  __pyx_2 = PyObject_GetIter(__pyx_v_matching_blocks); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
  for (;;) {
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
      break;
    }
    __pyx_4 = PyObject_GetIter(__pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    __pyx_5 = PyInt_AsSsize_t(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_parent_idx = __pyx_5;
    __pyx_3 = __Pyx_UnpackItem(__pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    __pyx_5 = PyInt_AsSsize_t(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_lines_idx = __pyx_5;
    __pyx_3 = __Pyx_UnpackItem(__pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    __pyx_5 = PyInt_AsSsize_t(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_match_len = __pyx_5;
    if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":204 */
    __pyx_1 = __pyx_f_6bzrlib_14_annotator_pyx__check_match_ranges(__pyx_v_parent_annotations,__pyx_v_annotations,__pyx_v_parent_idx,__pyx_v_lines_idx,__pyx_v_match_len); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;}

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":208 */
    for (__pyx_v_idx = 0; __pyx_v_idx < __pyx_v_match_len; ++__pyx_v_idx) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":209 */
      __pyx_v_ann_idx = (__pyx_v_lines_idx + __pyx_v_idx);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":210 */
      __pyx_v_ann_temp = PyList_GET_ITEM(__pyx_v_annotations,__pyx_v_ann_idx);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":211 */
      __pyx_v_par_temp = PyList_GET_ITEM(__pyx_v_parent_annotations,(__pyx_v_parent_idx + __pyx_v_idx));

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":212 */
      __pyx_1 = (__pyx_v_ann_temp == __pyx_v_par_temp);
      if (__pyx_1) {
        goto __pyx_L4;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":221 */
      Py_INCREF(((PyObject *)__pyx_v_par_temp));
      Py_DECREF(__pyx_v_par_ann);
      __pyx_v_par_ann = ((PyObject *)__pyx_v_par_temp);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":222 */
      Py_INCREF(((PyObject *)__pyx_v_ann_temp));
      Py_DECREF(__pyx_v_ann);
      __pyx_v_ann = ((PyObject *)__pyx_v_ann_temp);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":223 */
      __pyx_1 = __pyx_v_ann == __pyx_v_this_annotation;
      if (__pyx_1) {

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":226 */
        Py_INCREF(__pyx_v_par_ann);

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":227 */
        __pyx_1 = PyList_SetItem(__pyx_v_annotations,__pyx_v_ann_idx,__pyx_v_par_ann); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;}

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":228 */
        goto __pyx_L4;
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":231 */
      __pyx_1 = __pyx_v_ann == __pyx_v_last_ann;
      if (__pyx_1) {
        __pyx_1 = __pyx_v_par_ann == __pyx_v_last_parent;
      }
      if (__pyx_1) {

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":232 */
        Py_INCREF(__pyx_v_last_res);

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":233 */
        __pyx_1 = PyList_SetItem(__pyx_v_annotations,__pyx_v_ann_idx,__pyx_v_last_res); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
        goto __pyx_L8;
      }
      /*else*/ {

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":235 */
        __pyx_3 = __pyx_f_6bzrlib_14_annotator_pyx__combine_annotations(__pyx_v_ann,__pyx_v_par_ann,__pyx_v_ann_cache); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;}
        Py_DECREF(__pyx_v_new_ann);
        __pyx_v_new_ann = __pyx_3;
        __pyx_3 = 0;

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":236 */
        Py_INCREF(__pyx_v_new_ann);

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":237 */
        __pyx_1 = PyList_SetItem(__pyx_v_annotations,__pyx_v_ann_idx,__pyx_v_new_ann); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; goto __pyx_L1;}

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":238 */
        Py_INCREF(__pyx_v_ann);
        Py_DECREF(__pyx_v_last_ann);
        __pyx_v_last_ann = __pyx_v_ann;

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":239 */
        Py_INCREF(__pyx_v_par_ann);
        Py_DECREF(__pyx_v_last_parent);
        __pyx_v_last_parent = __pyx_v_par_ann;

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":240 */
        Py_INCREF(__pyx_v_new_ann);
        Py_DECREF(__pyx_v_last_res);
        __pyx_v_last_res = __pyx_v_new_ann;
      }
      __pyx_L8:;
      __pyx_L4:;
    }
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":241 */
  __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("bzrlib._annotator_pyx._merge_annotations");
  __pyx_r = (-1);
  __pyx_L0:;
  Py_DECREF(__pyx_v_last_ann);
  Py_DECREF(__pyx_v_last_parent);
  Py_DECREF(__pyx_v_last_res);
  Py_DECREF(__pyx_v_par_ann);
  Py_DECREF(__pyx_v_ann);
  Py_DECREF(__pyx_v_new_ann);
  Py_DECREF(__pyx_v_this_annotation);
  Py_DECREF(__pyx_v_annotations);
  Py_DECREF(__pyx_v_parent_annotations);
  Py_DECREF(__pyx_v_matching_blocks);
  Py_DECREF(__pyx_v_ann_cache);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent[] = "Reannotate this text relative to its first parent.";
static PyMethodDef __pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent = {"_update_from_first_parent", (PyCFunction)__pyx_f_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent};
static PyObject *__pyx_f_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_annotations = 0;
  PyObject *__pyx_v_lines = 0;
  PyObject *__pyx_v_parent_key = 0;
  PyObject *__pyx_v_parent_annotations;
  PyObject *__pyx_v_matching_blocks;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"self","key","annotations","lines","parent_key",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOO", __pyx_argnames, &__pyx_v_self, &__pyx_v_key, &__pyx_v_annotations, &__pyx_v_lines, &__pyx_v_parent_key)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_key);
  Py_INCREF(__pyx_v_annotations);
  Py_INCREF(__pyx_v_lines);
  Py_INCREF(__pyx_v_parent_key);
  __pyx_v_parent_annotations = Py_None; Py_INCREF(Py_None);
  __pyx_v_matching_blocks = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":250 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_k6p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;}
  Py_INCREF(__pyx_v_key);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_key);
  Py_INCREF(__pyx_v_lines);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_lines);
  Py_INCREF(__pyx_v_parent_key);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_parent_key);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyObject_GetIter(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_v_parent_annotations);
  __pyx_v_parent_annotations = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_v_matching_blocks);
  __pyx_v_matching_blocks = __pyx_3;
  __pyx_3 = 0;
  if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":253 */
  __pyx_4 = __pyx_f_6bzrlib_14_annotator_pyx__apply_parent_annotations(__pyx_v_annotations,__pyx_v_parent_annotations,__pyx_v_matching_blocks); if (__pyx_4 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._annotator_pyx.Annotator._update_from_first_parent");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_parent_annotations);
  Py_DECREF(__pyx_v_matching_blocks);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_key);
  Py_DECREF(__pyx_v_annotations);
  Py_DECREF(__pyx_v_lines);
  Py_DECREF(__pyx_v_parent_key);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_14_annotator_pyx_9Annotator__update_from_other_parents(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_14_annotator_pyx_9Annotator__update_from_other_parents[] = "Reannotate this text relative to a second (or more) parent.";
static PyMethodDef __pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator__update_from_other_parents = {"_update_from_other_parents", (PyCFunction)__pyx_f_6bzrlib_14_annotator_pyx_9Annotator__update_from_other_parents, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6bzrlib_14_annotator_pyx_9Annotator__update_from_other_parents};
static PyObject *__pyx_f_6bzrlib_14_annotator_pyx_9Annotator__update_from_other_parents(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_annotations = 0;
  PyObject *__pyx_v_lines = 0;
  PyObject *__pyx_v_this_annotation = 0;
  PyObject *__pyx_v_parent_key = 0;
  PyObject *__pyx_v_parent_annotations;
  PyObject *__pyx_v_matching_blocks;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"self","key","annotations","lines","this_annotation","parent_key",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOO", __pyx_argnames, &__pyx_v_self, &__pyx_v_key, &__pyx_v_annotations, &__pyx_v_lines, &__pyx_v_this_annotation, &__pyx_v_parent_key)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_key);
  Py_INCREF(__pyx_v_annotations);
  Py_INCREF(__pyx_v_lines);
  Py_INCREF(__pyx_v_this_annotation);
  Py_INCREF(__pyx_v_parent_key);
  __pyx_v_parent_annotations = Py_None; Py_INCREF(Py_None);
  __pyx_v_matching_blocks = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":260 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_k6p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;}
  Py_INCREF(__pyx_v_key);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_key);
  Py_INCREF(__pyx_v_lines);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_lines);
  Py_INCREF(__pyx_v_parent_key);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_parent_key);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyObject_GetIter(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; goto __pyx_L1;}
  Py_DECREF(__pyx_v_parent_annotations);
  __pyx_v_parent_annotations = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; goto __pyx_L1;}
  Py_DECREF(__pyx_v_matching_blocks);
  __pyx_v_matching_blocks = __pyx_3;
  __pyx_3 = 0;
  if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":262 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n__ann_tuple_cache); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; goto __pyx_L1;}
  __pyx_4 = __pyx_f_6bzrlib_14_annotator_pyx__merge_annotations(__pyx_v_this_annotation,__pyx_v_annotations,__pyx_v_parent_annotations,__pyx_v_matching_blocks,__pyx_2); if (__pyx_4 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; 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("bzrlib._annotator_pyx.Annotator._update_from_other_parents");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_parent_annotations);
  Py_DECREF(__pyx_v_matching_blocks);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_key);
  Py_DECREF(__pyx_v_annotations);
  Py_DECREF(__pyx_v_lines);
  Py_DECREF(__pyx_v_this_annotation);
  Py_DECREF(__pyx_v_parent_key);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_14_annotator_pyx_9Annotator_annotate_flat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_14_annotator_pyx_9Annotator_annotate_flat[] = "Determine the single-best-revision to source for each line.\n\n        This is meant as a compatibility thunk to how annotate() used to work.\n        ";
static PyMethodDef __pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator_annotate_flat = {"annotate_flat", (PyCFunction)__pyx_f_6bzrlib_14_annotator_pyx_9Annotator_annotate_flat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6bzrlib_14_annotator_pyx_9Annotator_annotate_flat};
static PyObject *__pyx_f_6bzrlib_14_annotator_pyx_9Annotator_annotate_flat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_key = 0;
  Py_ssize_t __pyx_v_pos;
  Py_ssize_t __pyx_v_num_lines;
  PyObject *__pyx_v_annotate;
  PyObject *__pyx_v_custom_tiebreaker;
  PyObject *__pyx_v_annotations;
  PyObject *__pyx_v_lines;
  PyObject *__pyx_v_out;
  PyObject *__pyx_v_heads;
  PyObject *__pyx_v_annotation;
  PyObject *__pyx_v_line;
  PyObject *__pyx_v_head;
  PyObject *__pyx_v_the_heads;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_ssize_t __pyx_4;
  int __pyx_5;
  static char *__pyx_argnames[] = {"self","key",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_self, &__pyx_v_key)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_key);
  __pyx_v_annotate = Py_None; Py_INCREF(Py_None);
  __pyx_v_custom_tiebreaker = Py_None; Py_INCREF(Py_None);
  __pyx_v_annotations = Py_None; Py_INCREF(Py_None);
  __pyx_v_lines = Py_None; Py_INCREF(Py_None);
  __pyx_v_out = Py_None; Py_INCREF(Py_None);
  __pyx_v_heads = Py_None; Py_INCREF(Py_None);
  __pyx_v_annotation = Py_None; Py_INCREF(Py_None);
  __pyx_v_line = Py_None; Py_INCREF(Py_None);
  __pyx_v_head = Py_None; Py_INCREF(Py_None);
  __pyx_v_the_heads = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":272 */
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; goto __pyx_L1;}
  Py_INCREF(__pyx_n_annotate);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_n_annotate);
  __pyx_2 = __Pyx_Import(__pyx_n_bzrlib, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_annotate); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; goto __pyx_L1;}
  Py_DECREF(__pyx_v_annotate);
  __pyx_v_annotate = __pyx_1;
  __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":274 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_annotate, __pyx_n__break_annotation_tie); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; goto __pyx_L1;}
  Py_DECREF(__pyx_v_custom_tiebreaker);
  __pyx_v_custom_tiebreaker = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":275 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_annotate); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  Py_INCREF(__pyx_v_key);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_key);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyObject_GetIter(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  Py_DECREF(__pyx_v_annotations);
  __pyx_v_annotations = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  Py_DECREF(__pyx_v_lines);
  __pyx_v_lines = __pyx_3;
  __pyx_3 = 0;
  if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":276 */
  __pyx_4 = PyObject_Length(__pyx_v_lines); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}
  __pyx_v_num_lines = __pyx_4;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":277 */
  __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;}
  Py_DECREF(__pyx_v_out);
  __pyx_v_out = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":278 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n__get_heads_provider); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_heads); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_heads);
  __pyx_v_heads = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":279 */
  for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_v_num_lines; ++__pyx_v_pos) {

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":280 */
    __pyx_3 = __Pyx_GetItemInt(__pyx_v_annotations, __pyx_v_pos); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;}
    Py_DECREF(__pyx_v_annotation);
    __pyx_v_annotation = __pyx_3;
    __pyx_3 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":281 */
    __pyx_1 = __Pyx_GetItemInt(__pyx_v_lines, __pyx_v_pos); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; goto __pyx_L1;}
    Py_DECREF(__pyx_v_line);
    __pyx_v_line = __pyx_1;
    __pyx_1 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":282 */
    __pyx_4 = PyObject_Length(__pyx_v_annotation); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; goto __pyx_L1;}
    __pyx_5 = (__pyx_4 == 1);
    if (__pyx_5) {
      __pyx_2 = __Pyx_GetItemInt(__pyx_v_annotation, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; goto __pyx_L1;}
      Py_DECREF(__pyx_v_head);
      __pyx_v_head = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":285 */
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;}
      Py_INCREF(__pyx_v_annotation);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_annotation);
      __pyx_1 = PyObject_CallObject(__pyx_v_heads, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_v_the_heads);
      __pyx_v_the_heads = __pyx_1;
      __pyx_1 = 0;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":286 */
      __pyx_4 = PyObject_Length(__pyx_v_the_heads); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;}
      __pyx_5 = (__pyx_4 == 1);
      if (__pyx_5) {
        __pyx_2 = PyObject_GetIter(__pyx_v_the_heads); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
        for (;;) {
          __pyx_3 = PyIter_Next(__pyx_2);
          if (!__pyx_3) {
            if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
            break;
          }
          Py_DECREF(__pyx_v_head);
          __pyx_v_head = __pyx_3;
          __pyx_3 = 0;
          goto __pyx_L7;
        }
        __pyx_L7:;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        goto __pyx_L5;
      }
      /*else*/ {
        __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n__resolve_annotation_tie); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;}
        Py_INCREF(__pyx_v_the_heads);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_the_heads);
        Py_INCREF(__pyx_v_line);
        PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_line);
        Py_INCREF(__pyx_v_custom_tiebreaker);
        PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_custom_tiebreaker);
        __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_v_head);
        __pyx_v_head = __pyx_2;
        __pyx_2 = 0;
      }
      __pyx_L5:;
    }
    __pyx_L4:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":293 */
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
    Py_INCREF(__pyx_v_head);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_head);
    Py_INCREF(__pyx_v_line);
    PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_line);
    __pyx_5 = PyList_Append(__pyx_v_out,__pyx_1); if (__pyx_5 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":294 */
  Py_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  __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("bzrlib._annotator_pyx.Annotator.annotate_flat");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_annotate);
  Py_DECREF(__pyx_v_custom_tiebreaker);
  Py_DECREF(__pyx_v_annotations);
  Py_DECREF(__pyx_v_lines);
  Py_DECREF(__pyx_v_out);
  Py_DECREF(__pyx_v_heads);
  Py_DECREF(__pyx_v_annotation);
  Py_DECREF(__pyx_v_line);
  Py_DECREF(__pyx_v_head);
  Py_DECREF(__pyx_v_the_heads);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_key);
  return __pyx_r;
}

static struct PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

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

PyMODINIT_FUNC init_annotator_pyx(void); /*proto*/
PyMODINIT_FUNC init_annotator_pyx(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("_annotator_pyx", __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_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":58 */
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;}
  Py_INCREF(__pyx_n__annotator_py);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_n__annotator_py);
  __pyx_2 = __Pyx_Import(__pyx_n_bzrlib, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n__annotator_py); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n__annotator_py, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":244 */
  __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__annotator_py); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_Annotator); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
  __pyx_3 = 0;
  if (PyDict_SetItemString(__pyx_2, "__doc__", __pyx_k16p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;}
  __pyx_3 = __Pyx_CreateClass(__pyx_1, __pyx_2, __pyx_n_Annotator, "bzrlib._annotator_pyx"); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":247 */
  __pyx_1 = PyCFunction_New(&__pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}
  __pyx_4 = PyMethod_New(__pyx_1, 0, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_3, __pyx_n__update_from_first_parent, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":256 */
  __pyx_1 = PyCFunction_New(&__pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator__update_from_other_parents, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;}
  __pyx_4 = PyMethod_New(__pyx_1, 0, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_3, __pyx_n__update_from_other_parents, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_annotator_pyx.pyx":265 */
  __pyx_1 = PyCFunction_New(&__pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator_annotate_flat, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;}
  __pyx_4 = PyMethod_New(__pyx_1, 0, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_3, __pyx_n_annotate_flat, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Annotator, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("bzrlib._annotator_pyx");
}

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

/* Runtime support code */

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

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

static void __Pyx_UnpackError(void) {
    PyErr_SetString(PyExc_ValueError, "unpack sequence of wrong size");
}

static PyObject *__Pyx_UnpackItem(PyObject *iter) {
    PyObject *item;
    if (!(item = PyIter_Next(iter))) {
        if (!PyErr_Occurred())
            __Pyx_UnpackError();
    }
    return item;
}

static int __Pyx_EndUnpack(PyObject *iter) {
    PyObject *item;
    if ((item = PyIter_Next(iter))) {
        Py_DECREF(item);
        __Pyx_UnpackError();
        return -1;
    }
    else if (!PyErr_Occurred())
        return 0;
    else
        return -1;
}

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_GetItemInt(PyObject *o, Py_ssize_t i) {
    PyTypeObject *t = o->ob_type;
    PyObject *r;
    if (t->tp_as_sequence && t->tp_as_sequence->sq_item)
        r = PySequence_GetItem(o, i);
    else {
        PyObject *j = PyInt_FromLong(i);
        if (!j)
            return 0;
        r = PyObject_GetItem(o, j);
        Py_DECREF(j);
    }
    return r;
}

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

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 PyObject *__Pyx_CreateClass(
    PyObject *bases, PyObject *dict, PyObject *name, char *modname)
{
    PyObject *py_modname;
    PyObject *result = 0;
    
    py_modname = PyString_FromString(modname);
    if (!py_modname)
        goto bad;
    if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
        goto bad;
    result = PyClass_New(bases, dict, name);
bad:
    Py_XDECREF(py_modname);
    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);
}
