~ubuntu-branches/ubuntu/vivid/bzr/vivid

« back to all changes in this revision

Viewing changes to bzrlib/_annotator_pyx.c

  • Committer: Jelmer Vernooij
  • Date: 2012-02-25 15:54:11 UTC
  • mfrom: (3930.3.71 unstable-2.5)
  • Revision ID: jelmer@samba.org-20120225155411-7nkz73y3xmshn2n8
Tags: 2.5.0-1ubuntu1
releasing version 2.5.0-1ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Generated by Cython 0.14.1 on Mon Jan 16 15:59:23 2012 */
 
2
 
 
3
#define PY_SSIZE_T_CLEAN
 
4
#include "Python.h"
 
5
#ifndef Py_PYTHON_H
 
6
    #error Python headers needed to compile C extensions, please install development version of Python.
 
7
#else
 
8
 
 
9
#include <stddef.h> /* For offsetof */
 
10
#ifndef offsetof
 
11
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
 
12
#endif
 
13
 
 
14
#if !defined(WIN32) && !defined(MS_WINDOWS)
 
15
  #ifndef __stdcall
 
16
    #define __stdcall
 
17
  #endif
 
18
  #ifndef __cdecl
 
19
    #define __cdecl
 
20
  #endif
 
21
  #ifndef __fastcall
 
22
    #define __fastcall
 
23
  #endif
 
24
#endif
 
25
 
 
26
#ifndef DL_IMPORT
 
27
  #define DL_IMPORT(t) t
 
28
#endif
 
29
#ifndef DL_EXPORT
 
30
  #define DL_EXPORT(t) t
 
31
#endif
 
32
 
 
33
#ifndef PY_LONG_LONG
 
34
  #define PY_LONG_LONG LONG_LONG
 
35
#endif
 
36
 
 
37
#if PY_VERSION_HEX < 0x02040000
 
38
  #define METH_COEXIST 0
 
39
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
 
40
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
 
41
#endif
 
42
 
 
43
#if PY_VERSION_HEX < 0x02050000
 
44
  typedef int Py_ssize_t;
 
45
  #define PY_SSIZE_T_MAX INT_MAX
 
46
  #define PY_SSIZE_T_MIN INT_MIN
 
47
  #define PY_FORMAT_SIZE_T ""
 
48
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
 
49
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
 
50
  #define PyNumber_Index(o)    PyNumber_Int(o)
 
51
  #define PyIndex_Check(o)     PyNumber_Check(o)
 
52
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
 
53
#endif
 
54
 
 
55
#if PY_VERSION_HEX < 0x02060000
 
56
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
 
57
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
 
58
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
 
59
  #define PyVarObject_HEAD_INIT(type, size) \
 
60
          PyObject_HEAD_INIT(type) size,
 
61
  #define PyType_Modified(t)
 
62
 
 
63
  typedef struct {
 
64
     void *buf;
 
65
     PyObject *obj;
 
66
     Py_ssize_t len;
 
67
     Py_ssize_t itemsize;
 
68
     int readonly;
 
69
     int ndim;
 
70
     char *format;
 
71
     Py_ssize_t *shape;
 
72
     Py_ssize_t *strides;
 
73
     Py_ssize_t *suboffsets;
 
74
     void *internal;
 
75
  } Py_buffer;
 
76
 
 
77
  #define PyBUF_SIMPLE 0
 
78
  #define PyBUF_WRITABLE 0x0001
 
79
  #define PyBUF_FORMAT 0x0004
 
80
  #define PyBUF_ND 0x0008
 
81
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
 
82
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
 
83
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
 
84
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
 
85
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
 
86
 
 
87
#endif
 
88
 
 
89
#if PY_MAJOR_VERSION < 3
 
90
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
 
91
#else
 
92
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
 
93
#endif
 
94
 
 
95
#if PY_MAJOR_VERSION >= 3
 
96
  #define Py_TPFLAGS_CHECKTYPES 0
 
97
  #define Py_TPFLAGS_HAVE_INDEX 0
 
98
#endif
 
99
 
 
100
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
 
101
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
 
102
#endif
 
103
 
 
104
#if PY_MAJOR_VERSION >= 3
 
105
  #define PyBaseString_Type            PyUnicode_Type
 
106
  #define PyStringObject               PyUnicodeObject
 
107
  #define PyString_Type                PyUnicode_Type
 
108
  #define PyString_Check               PyUnicode_Check
 
109
  #define PyString_CheckExact          PyUnicode_CheckExact
 
110
#endif
 
111
 
 
112
#if PY_VERSION_HEX < 0x02060000
 
113
  #define PyBytesObject                PyStringObject
 
114
  #define PyBytes_Type                 PyString_Type
 
115
  #define PyBytes_Check                PyString_Check
 
116
  #define PyBytes_CheckExact           PyString_CheckExact
 
117
  #define PyBytes_FromString           PyString_FromString
 
118
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
 
119
  #define PyBytes_FromFormat           PyString_FromFormat
 
120
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
 
121
  #define PyBytes_AsString             PyString_AsString
 
122
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
 
123
  #define PyBytes_Size                 PyString_Size
 
124
  #define PyBytes_AS_STRING            PyString_AS_STRING
 
125
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
 
126
  #define PyBytes_Repr                 PyString_Repr
 
127
  #define PyBytes_Concat               PyString_Concat
 
128
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
 
129
#endif
 
130
 
 
131
#if PY_VERSION_HEX < 0x02060000
 
132
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
 
133
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
 
134
#endif
 
135
#ifndef PySet_CheckExact
 
136
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
 
137
#endif
 
138
 
 
139
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
 
140
 
 
141
#if PY_MAJOR_VERSION >= 3
 
142
  #define PyIntObject                  PyLongObject
 
143
  #define PyInt_Type                   PyLong_Type
 
144
  #define PyInt_Check(op)              PyLong_Check(op)
 
145
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
 
146
  #define PyInt_FromString             PyLong_FromString
 
147
  #define PyInt_FromUnicode            PyLong_FromUnicode
 
148
  #define PyInt_FromLong               PyLong_FromLong
 
149
  #define PyInt_FromSize_t             PyLong_FromSize_t
 
150
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
 
151
  #define PyInt_AsLong                 PyLong_AsLong
 
152
  #define PyInt_AS_LONG                PyLong_AS_LONG
 
153
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
 
154
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
 
155
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
 
156
#endif
 
157
 
 
158
#if PY_MAJOR_VERSION >= 3
 
159
  #define PyBoolObject                 PyLongObject
 
160
#endif
 
161
 
 
162
 
 
163
#if PY_MAJOR_VERSION >= 3
 
164
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
 
165
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
 
166
#else
 
167
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
 
168
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
 
169
#endif
 
170
 
 
171
#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
 
172
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
 
173
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
 
174
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
 
175
#else
 
176
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
 
177
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
 
178
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
 
179
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
 
180
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
 
181
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
 
182
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
 
183
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
 
184
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
 
185
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
 
186
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
 
187
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
 
188
#endif
 
189
 
 
190
#if PY_MAJOR_VERSION >= 3
 
191
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
 
192
#endif
 
193
 
 
194
#if PY_VERSION_HEX < 0x02050000
 
195
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
 
196
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
 
197
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
 
198
#else
 
199
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
 
200
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
 
201
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
 
202
#endif
 
203
 
 
204
#if PY_VERSION_HEX < 0x02050000
 
205
  #define __Pyx_NAMESTR(n) ((char *)(n))
 
206
  #define __Pyx_DOCSTR(n)  ((char *)(n))
 
207
#else
 
208
  #define __Pyx_NAMESTR(n) (n)
 
209
  #define __Pyx_DOCSTR(n)  (n)
 
210
#endif
 
211
 
 
212
#ifdef __cplusplus
 
213
#define __PYX_EXTERN_C extern "C"
 
214
#else
 
215
#define __PYX_EXTERN_C extern
 
216
#endif
 
217
 
 
218
#if defined(WIN32) || defined(MS_WINDOWS)
 
219
#define _USE_MATH_DEFINES
 
220
#endif
 
221
#include <math.h>
 
222
#define __PYX_HAVE_API__bzrlib___annotator_pyx
 
223
#include "python-compat.h"
 
224
 
 
225
#ifdef PYREX_WITHOUT_ASSERTIONS
 
226
#define CYTHON_WITHOUT_ASSERTIONS
 
227
#endif
 
228
 
 
229
 
 
230
/* inline attribute */
 
231
#ifndef CYTHON_INLINE
 
232
  #if defined(__GNUC__)
 
233
    #define CYTHON_INLINE __inline__
 
234
  #elif defined(_MSC_VER)
 
235
    #define CYTHON_INLINE __inline
 
236
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
 
237
    #define CYTHON_INLINE inline
 
238
  #else
 
239
    #define CYTHON_INLINE
 
240
  #endif
 
241
#endif
 
242
 
 
243
/* unused attribute */
 
244
#ifndef CYTHON_UNUSED
 
245
# if defined(__GNUC__)
 
246
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
 
247
#     define CYTHON_UNUSED __attribute__ ((__unused__))
 
248
#   else
 
249
#     define CYTHON_UNUSED
 
250
#   endif
 
251
# elif defined(__ICC) || defined(__INTEL_COMPILER)
 
252
#   define CYTHON_UNUSED __attribute__ ((__unused__))
 
253
# else
 
254
#   define CYTHON_UNUSED
 
255
# endif
 
256
#endif
 
257
 
 
258
typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
 
259
 
 
260
 
 
261
/* Type Conversion Predeclarations */
 
262
 
 
263
#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
 
264
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))
 
265
 
 
266
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
 
267
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
 
268
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
 
269
 
 
270
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
 
271
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
 
272
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
 
273
 
 
274
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
 
275
 
 
276
 
 
277
#ifdef __GNUC__
 
278
/* Test for GCC > 2.95 */
 
279
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
 
280
#define likely(x)   __builtin_expect(!!(x), 1)
 
281
#define unlikely(x) __builtin_expect(!!(x), 0)
 
282
#else /* __GNUC__ > 2 ... */
 
283
#define likely(x)   (x)
 
284
#define unlikely(x) (x)
 
285
#endif /* __GNUC__ > 2 ... */
 
286
#else /* __GNUC__ */
 
287
#define likely(x)   (x)
 
288
#define unlikely(x) (x)
 
289
#endif /* __GNUC__ */
 
290
    
 
291
static PyObject *__pyx_m;
 
292
static PyObject *__pyx_b;
 
293
static PyObject *__pyx_empty_tuple;
 
294
static PyObject *__pyx_empty_bytes;
 
295
static int __pyx_lineno;
 
296
static int __pyx_clineno = 0;
 
297
static const char * __pyx_cfilenm= __FILE__;
 
298
static const char *__pyx_filename;
 
299
 
 
300
 
 
301
static const char *__pyx_f[] = {
 
302
  "_annotator_pyx.pyx",
 
303
};
 
304
 
 
305
/* Type declarations */
 
306
 
 
307
#ifndef CYTHON_REFNANNY
 
308
  #define CYTHON_REFNANNY 0
 
309
#endif
 
310
 
 
311
#if CYTHON_REFNANNY
 
312
  typedef struct {
 
313
    void (*INCREF)(void*, PyObject*, int);
 
314
    void (*DECREF)(void*, PyObject*, int);
 
315
    void (*GOTREF)(void*, PyObject*, int);
 
316
    void (*GIVEREF)(void*, PyObject*, int);
 
317
    void* (*SetupContext)(const char*, int, const char*);
 
318
    void (*FinishContext)(void**);
 
319
  } __Pyx_RefNannyAPIStruct;
 
320
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
 
321
  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
 
322
    PyObject *m = NULL, *p = NULL;
 
323
    void *r = NULL;
 
324
    m = PyImport_ImportModule((char *)modname);
 
325
    if (!m) goto end;
 
326
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
 
327
    if (!p) goto end;
 
328
    r = PyLong_AsVoidPtr(p);
 
329
  end:
 
330
    Py_XDECREF(p);
 
331
    Py_XDECREF(m);
 
332
    return (__Pyx_RefNannyAPIStruct *)r;
 
333
  }
 
334
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
 
335
  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
 
336
  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
337
  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
338
  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
339
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
340
  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
 
341
#else
 
342
  #define __Pyx_RefNannySetupContext(name)
 
343
  #define __Pyx_RefNannyFinishContext()
 
344
  #define __Pyx_INCREF(r) Py_INCREF(r)
 
345
  #define __Pyx_DECREF(r) Py_DECREF(r)
 
346
  #define __Pyx_GOTREF(r)
 
347
  #define __Pyx_GIVEREF(r)
 
348
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
 
349
#endif /* CYTHON_REFNANNY */
 
350
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
 
351
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
 
352
 
 
353
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
 
354
 
 
355
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 
356
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
 
357
 
 
358
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 
359
 
 
360
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
 
361
 
 
362
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
 
363
 
 
364
static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
 
365
static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/
 
366
 
 
367
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
 
368
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
 
369
 
 
370
static void __Pyx_RaiseDoubleKeywordsError(
 
371
    const char* func_name, PyObject* kw_name); /*proto*/
 
372
 
 
373
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
 
374
 
 
375
 
 
376
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
 
377
    PyObject *r;
 
378
    if (!j) return NULL;
 
379
    r = PyObject_GetItem(o, j);
 
380
    Py_DECREF(j);
 
381
    return r;
 
382
}
 
383
 
 
384
 
 
385
#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
 
386
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
 
387
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
 
388
 
 
389
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
 
390
    if (likely(o != Py_None)) {
 
391
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
 
392
            PyObject *r = PyList_GET_ITEM(o, i);
 
393
            Py_INCREF(r);
 
394
            return r;
 
395
        }
 
396
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
 
397
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
 
398
            Py_INCREF(r);
 
399
            return r;
 
400
        }
 
401
    }
 
402
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
 
403
}
 
404
 
 
405
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
 
406
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
 
407
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
 
408
 
 
409
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
 
410
    if (likely(o != Py_None)) {
 
411
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
 
412
            PyObject *r = PyTuple_GET_ITEM(o, i);
 
413
            Py_INCREF(r);
 
414
            return r;
 
415
        }
 
416
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
 
417
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
 
418
            Py_INCREF(r);
 
419
            return r;
 
420
        }
 
421
    }
 
422
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
 
423
}
 
424
 
 
425
 
 
426
#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
 
427
                                                    __Pyx_GetItemInt_Fast(o, i) : \
 
428
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
 
429
 
 
430
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
 
431
    PyObject *r;
 
432
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
 
433
        r = PyList_GET_ITEM(o, i);
 
434
        Py_INCREF(r);
 
435
    }
 
436
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
 
437
        r = PyTuple_GET_ITEM(o, i);
 
438
        Py_INCREF(r);
 
439
    }
 
440
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
 
441
        r = PySequence_GetItem(o, i);
 
442
    }
 
443
    else {
 
444
        r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
 
445
    }
 
446
    return r;
 
447
}
 
448
 
 
449
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
 
450
 
 
451
static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/
 
452
 
 
453
static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
 
454
                                   PyObject *modname); /*proto*/
 
455
 
 
456
#define __pyx_binding_PyCFunctionType_USED 1
 
457
 
 
458
typedef struct {
 
459
    PyCFunctionObject func;
 
460
} __pyx_binding_PyCFunctionType_object;
 
461
 
 
462
static PyTypeObject __pyx_binding_PyCFunctionType_type;
 
463
static PyTypeObject *__pyx_binding_PyCFunctionType = NULL;
 
464
 
 
465
static PyObject *__pyx_binding_PyCFunctionType_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module); /* proto */
 
466
#define __pyx_binding_PyCFunctionType_New(ml, self) __pyx_binding_PyCFunctionType_NewEx(ml, self, NULL)
 
467
 
 
468
static int __pyx_binding_PyCFunctionType_init(void); /* proto */
 
469
 
 
470
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
 
471
 
 
472
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
 
473
 
 
474
static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
 
475
 
 
476
static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
 
477
 
 
478
static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
 
479
 
 
480
static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
 
481
 
 
482
static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
 
483
 
 
484
static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
 
485
 
 
486
static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
 
487
 
 
488
static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
 
489
 
 
490
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
 
491
 
 
492
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
 
493
 
 
494
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
 
495
 
 
496
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
 
497
 
 
498
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
 
499
 
 
500
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
 
501
 
 
502
static void __Pyx_AddTraceback(const char *funcname); /*proto*/
 
503
 
 
504
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
 
505
/* Module declarations from bzrlib._annotator_pyx */
 
506
 
 
507
static int __pyx_f_6bzrlib_14_annotator_pyx__check_annotations_are_lists(PyObject *, PyObject *); /*proto*/
 
508
static int __pyx_f_6bzrlib_14_annotator_pyx__check_match_ranges(PyObject *, PyObject *, Py_ssize_t, Py_ssize_t, Py_ssize_t); /*proto*/
 
509
static PyObject *__pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(PyObject *, Py_ssize_t *); /*proto*/
 
510
static PyObject *__pyx_f_6bzrlib_14_annotator_pyx__combine_annotations(PyObject *, PyObject *, PyObject *); /*proto*/
 
511
static int __pyx_f_6bzrlib_14_annotator_pyx__apply_parent_annotations(PyObject *, PyObject *, PyObject *); /*proto*/
 
512
static int __pyx_f_6bzrlib_14_annotator_pyx__merge_annotations(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
 
513
#define __Pyx_MODULE_NAME "bzrlib._annotator_pyx"
 
514
static int __pyx_module_is_main_bzrlib___annotator_pyx = 0;
 
515
 
 
516
/* Implementation of bzrlib._annotator_pyx */
 
517
static PyObject *__pyx_builtin_TypeError;
 
518
static PyObject *__pyx_builtin_ValueError;
 
519
static char __pyx_k_1[] = "annotations must be a list";
 
520
static char __pyx_k_3[] = "parent_annotations must be a list";
 
521
static char __pyx_k_5[] = "Match length exceeds len of parent_annotations %s > %s";
 
522
static char __pyx_k_6[] = "Match length exceeds len of annotations %s > %s";
 
523
static char __pyx_k_7[] = "annotations must be tuples";
 
524
static char __pyx_k_9[] = "_get_parent_annotations_and_matches";
 
525
static char __pyx_k_10[] = "_break_annotation_tie";
 
526
static char __pyx_k_11[] = "_resolve_annotation_tie";
 
527
static char __pyx_k_12[] = "Functionality for doing annotations in the 'optimal' way";
 
528
static char __pyx_k_13[] = "bzrlib._annotator_pyx";
 
529
static char __pyx_k_14[] = "_update_from_first_parent";
 
530
static char __pyx_k_15[] = "_update_from_other_parents";
 
531
static char __pyx_k_16[] = "Class that drives performing annotations.";
 
532
static char __pyx_k__key[] = "key";
 
533
static char __pyx_k__self[] = "self";
 
534
static char __pyx_k__heads[] = "heads";
 
535
static char __pyx_k__lines[] = "lines";
 
536
static char __pyx_k__bzrlib[] = "bzrlib";
 
537
static char __pyx_k__ob_item[] = "ob_item";
 
538
static char __pyx_k____main__[] = "__main__";
 
539
static char __pyx_k____test__[] = "__test__";
 
540
static char __pyx_k__annotate[] = "annotate";
 
541
static char __pyx_k__Annotator[] = "Annotator";
 
542
static char __pyx_k__TypeError[] = "TypeError";
 
543
static char __pyx_k__ValueError[] = "ValueError";
 
544
static char __pyx_k__parent_key[] = "parent_key";
 
545
static char __pyx_k__annotations[] = "annotations";
 
546
static char __pyx_k___annotator_py[] = "_annotator_py";
 
547
static char __pyx_k__annotate_flat[] = "annotate_flat";
 
548
static char __pyx_k__this_annotation[] = "this_annotation";
 
549
static char __pyx_k___ann_tuple_cache[] = "_ann_tuple_cache";
 
550
static char __pyx_k___get_heads_provider[] = "_get_heads_provider";
 
551
static PyObject *__pyx_kp_s_1;
 
552
static PyObject *__pyx_n_s_10;
 
553
static PyObject *__pyx_n_s_11;
 
554
static PyObject *__pyx_n_s_13;
 
555
static PyObject *__pyx_n_s_14;
 
556
static PyObject *__pyx_n_s_15;
 
557
static PyObject *__pyx_kp_s_16;
 
558
static PyObject *__pyx_kp_s_3;
 
559
static PyObject *__pyx_kp_s_5;
 
560
static PyObject *__pyx_kp_s_6;
 
561
static PyObject *__pyx_kp_s_7;
 
562
static PyObject *__pyx_n_s_9;
 
563
static PyObject *__pyx_n_s__Annotator;
 
564
static PyObject *__pyx_n_s__TypeError;
 
565
static PyObject *__pyx_n_s__ValueError;
 
566
static PyObject *__pyx_n_s____main__;
 
567
static PyObject *__pyx_n_s____test__;
 
568
static PyObject *__pyx_n_s___ann_tuple_cache;
 
569
static PyObject *__pyx_n_s___annotator_py;
 
570
static PyObject *__pyx_n_s___get_heads_provider;
 
571
static PyObject *__pyx_n_s__annotate;
 
572
static PyObject *__pyx_n_s__annotate_flat;
 
573
static PyObject *__pyx_n_s__annotations;
 
574
static PyObject *__pyx_n_s__bzrlib;
 
575
static PyObject *__pyx_n_s__heads;
 
576
static PyObject *__pyx_n_s__key;
 
577
static PyObject *__pyx_n_s__lines;
 
578
static PyObject *__pyx_n_s__ob_item;
 
579
static PyObject *__pyx_n_s__parent_key;
 
580
static PyObject *__pyx_n_s__self;
 
581
static PyObject *__pyx_n_s__this_annotation;
 
582
static PyObject *__pyx_k_tuple_2;
 
583
static PyObject *__pyx_k_tuple_4;
 
584
static PyObject *__pyx_k_tuple_8;
 
585
 
 
586
/* "bzrlib/_annotator_pyx.pyx":61
 
587
 * 
 
588
 * 
 
589
 * cdef int _check_annotations_are_lists(annotations,             # <<<<<<<<<<<<<<
 
590
 *                                       parent_annotations) except -1:
 
591
 *     if not PyList_CheckExact(annotations):
 
592
 */
 
593
 
 
594
static  int __pyx_f_6bzrlib_14_annotator_pyx__check_annotations_are_lists(PyObject *__pyx_v_annotations, PyObject *__pyx_v_parent_annotations) {
 
595
  int __pyx_r;
 
596
  int __pyx_t_1;
 
597
  PyObject *__pyx_t_2 = NULL;
 
598
  __Pyx_RefNannySetupContext("_check_annotations_are_lists");
 
599
 
 
600
  /* "bzrlib/_annotator_pyx.pyx":63
 
601
 * cdef int _check_annotations_are_lists(annotations,
 
602
 *                                       parent_annotations) except -1:
 
603
 *     if not PyList_CheckExact(annotations):             # <<<<<<<<<<<<<<
 
604
 *         raise TypeError('annotations must be a list')
 
605
 *     if not PyList_CheckExact(parent_annotations):
 
606
 */
 
607
  __pyx_t_1 = (!PyList_CheckExact(__pyx_v_annotations));
 
608
  if (__pyx_t_1) {
 
609
 
 
610
    /* "bzrlib/_annotator_pyx.pyx":64
 
611
 *                                       parent_annotations) except -1:
 
612
 *     if not PyList_CheckExact(annotations):
 
613
 *         raise TypeError('annotations must be a list')             # <<<<<<<<<<<<<<
 
614
 *     if not PyList_CheckExact(parent_annotations):
 
615
 *         raise TypeError('parent_annotations must be a list')
 
616
 */
 
617
    __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
618
    __Pyx_GOTREF(__pyx_t_2);
 
619
    __Pyx_Raise(__pyx_t_2, 0, 0);
 
620
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
621
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
622
    goto __pyx_L3;
 
623
  }
 
624
  __pyx_L3:;
 
625
 
 
626
  /* "bzrlib/_annotator_pyx.pyx":65
 
627
 *     if not PyList_CheckExact(annotations):
 
628
 *         raise TypeError('annotations must be a list')
 
629
 *     if not PyList_CheckExact(parent_annotations):             # <<<<<<<<<<<<<<
 
630
 *         raise TypeError('parent_annotations must be a list')
 
631
 *     return 0
 
632
 */
 
633
  __pyx_t_1 = (!PyList_CheckExact(__pyx_v_parent_annotations));
 
634
  if (__pyx_t_1) {
 
635
 
 
636
    /* "bzrlib/_annotator_pyx.pyx":66
 
637
 *         raise TypeError('annotations must be a list')
 
638
 *     if not PyList_CheckExact(parent_annotations):
 
639
 *         raise TypeError('parent_annotations must be a list')             # <<<<<<<<<<<<<<
 
640
 *     return 0
 
641
 * 
 
642
 */
 
643
    __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
644
    __Pyx_GOTREF(__pyx_t_2);
 
645
    __Pyx_Raise(__pyx_t_2, 0, 0);
 
646
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
647
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
648
    goto __pyx_L4;
 
649
  }
 
650
  __pyx_L4:;
 
651
 
 
652
  /* "bzrlib/_annotator_pyx.pyx":67
 
653
 *     if not PyList_CheckExact(parent_annotations):
 
654
 *         raise TypeError('parent_annotations must be a list')
 
655
 *     return 0             # <<<<<<<<<<<<<<
 
656
 * 
 
657
 * 
 
658
 */
 
659
  __pyx_r = 0;
 
660
  goto __pyx_L0;
 
661
 
 
662
  __pyx_r = 0;
 
663
  goto __pyx_L0;
 
664
  __pyx_L1_error:;
 
665
  __Pyx_XDECREF(__pyx_t_2);
 
666
  __Pyx_AddTraceback("bzrlib._annotator_pyx._check_annotations_are_lists");
 
667
  __pyx_r = -1;
 
668
  __pyx_L0:;
 
669
  __Pyx_RefNannyFinishContext();
 
670
  return __pyx_r;
 
671
}
 
672
 
 
673
/* "bzrlib/_annotator_pyx.pyx":70
 
674
 * 
 
675
 * 
 
676
 * cdef int _check_match_ranges(parent_annotations, annotations,             # <<<<<<<<<<<<<<
 
677
 *                              Py_ssize_t parent_idx, Py_ssize_t lines_idx,
 
678
 *                              Py_ssize_t match_len) except -1:
 
679
 */
 
680
 
 
681
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) {
 
682
  int __pyx_r;
 
683
  int __pyx_t_1;
 
684
  PyObject *__pyx_t_2 = NULL;
 
685
  PyObject *__pyx_t_3 = NULL;
 
686
  PyObject *__pyx_t_4 = NULL;
 
687
  __Pyx_RefNannySetupContext("_check_match_ranges");
 
688
 
 
689
  /* "bzrlib/_annotator_pyx.pyx":73
 
690
 *                              Py_ssize_t parent_idx, Py_ssize_t lines_idx,
 
691
 *                              Py_ssize_t match_len) except -1:
 
692
 *     if parent_idx + match_len > PyList_GET_SIZE(parent_annotations):             # <<<<<<<<<<<<<<
 
693
 *         raise ValueError('Match length exceeds len of'
 
694
 *                          ' parent_annotations %s > %s'
 
695
 */
 
696
  __pyx_t_1 = ((__pyx_v_parent_idx + __pyx_v_match_len) > PyList_GET_SIZE(__pyx_v_parent_annotations));
 
697
  if (__pyx_t_1) {
 
698
 
 
699
    /* "bzrlib/_annotator_pyx.pyx":76
 
700
 *         raise ValueError('Match length exceeds len of'
 
701
 *                          ' parent_annotations %s > %s'
 
702
 *                          % (parent_idx + match_len,             # <<<<<<<<<<<<<<
 
703
 *                             PyList_GET_SIZE(parent_annotations)))
 
704
 *     if lines_idx + match_len > PyList_GET_SIZE(annotations):
 
705
 */
 
706
    __pyx_t_2 = PyInt_FromSsize_t((__pyx_v_parent_idx + __pyx_v_match_len)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
707
    __Pyx_GOTREF(__pyx_t_2);
 
708
 
 
709
    /* "bzrlib/_annotator_pyx.pyx":77
 
710
 *                          ' parent_annotations %s > %s'
 
711
 *                          % (parent_idx + match_len,
 
712
 *                             PyList_GET_SIZE(parent_annotations)))             # <<<<<<<<<<<<<<
 
713
 *     if lines_idx + match_len > PyList_GET_SIZE(annotations):
 
714
 *         raise ValueError('Match length exceeds len of'
 
715
 */
 
716
    __pyx_t_3 = PyInt_FromSsize_t(PyList_GET_SIZE(__pyx_v_parent_annotations)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
717
    __Pyx_GOTREF(__pyx_t_3);
 
718
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
719
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
 
720
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
 
721
    __Pyx_GIVEREF(__pyx_t_2);
 
722
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
 
723
    __Pyx_GIVEREF(__pyx_t_3);
 
724
    __pyx_t_2 = 0;
 
725
    __pyx_t_3 = 0;
 
726
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
727
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
728
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
 
729
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
730
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
 
731
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
 
732
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
 
733
    __pyx_t_3 = 0;
 
734
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
735
    __Pyx_GOTREF(__pyx_t_3);
 
736
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
 
737
    __Pyx_Raise(__pyx_t_3, 0, 0);
 
738
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
739
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
740
    goto __pyx_L3;
 
741
  }
 
742
  __pyx_L3:;
 
743
 
 
744
  /* "bzrlib/_annotator_pyx.pyx":78
 
745
 *                          % (parent_idx + match_len,
 
746
 *                             PyList_GET_SIZE(parent_annotations)))
 
747
 *     if lines_idx + match_len > PyList_GET_SIZE(annotations):             # <<<<<<<<<<<<<<
 
748
 *         raise ValueError('Match length exceeds len of'
 
749
 *                          ' annotations %s > %s'
 
750
 */
 
751
  __pyx_t_1 = ((__pyx_v_lines_idx + __pyx_v_match_len) > PyList_GET_SIZE(__pyx_v_annotations));
 
752
  if (__pyx_t_1) {
 
753
 
 
754
    /* "bzrlib/_annotator_pyx.pyx":81
 
755
 *         raise ValueError('Match length exceeds len of'
 
756
 *                          ' annotations %s > %s'
 
757
 *                          % (lines_idx + match_len,             # <<<<<<<<<<<<<<
 
758
 *                             PyList_GET_SIZE(annotations)))
 
759
 *     return 0
 
760
 */
 
761
    __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_lines_idx + __pyx_v_match_len)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
762
    __Pyx_GOTREF(__pyx_t_3);
 
763
 
 
764
    /* "bzrlib/_annotator_pyx.pyx":82
 
765
 *                          ' annotations %s > %s'
 
766
 *                          % (lines_idx + match_len,
 
767
 *                             PyList_GET_SIZE(annotations)))             # <<<<<<<<<<<<<<
 
768
 *     return 0
 
769
 * 
 
770
 */
 
771
    __pyx_t_4 = PyInt_FromSsize_t(PyList_GET_SIZE(__pyx_v_annotations)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
772
    __Pyx_GOTREF(__pyx_t_4);
 
773
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
774
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
775
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
 
776
    __Pyx_GIVEREF(__pyx_t_3);
 
777
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
 
778
    __Pyx_GIVEREF(__pyx_t_4);
 
779
    __pyx_t_3 = 0;
 
780
    __pyx_t_4 = 0;
 
781
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
782
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
 
783
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
784
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
785
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
786
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
 
787
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
 
788
    __pyx_t_4 = 0;
 
789
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
790
    __Pyx_GOTREF(__pyx_t_4);
 
791
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
792
    __Pyx_Raise(__pyx_t_4, 0, 0);
 
793
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
794
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
795
    goto __pyx_L4;
 
796
  }
 
797
  __pyx_L4:;
 
798
 
 
799
  /* "bzrlib/_annotator_pyx.pyx":83
 
800
 *                          % (lines_idx + match_len,
 
801
 *                             PyList_GET_SIZE(annotations)))
 
802
 *     return 0             # <<<<<<<<<<<<<<
 
803
 * 
 
804
 * 
 
805
 */
 
806
  __pyx_r = 0;
 
807
  goto __pyx_L0;
 
808
 
 
809
  __pyx_r = 0;
 
810
  goto __pyx_L0;
 
811
  __pyx_L1_error:;
 
812
  __Pyx_XDECREF(__pyx_t_2);
 
813
  __Pyx_XDECREF(__pyx_t_3);
 
814
  __Pyx_XDECREF(__pyx_t_4);
 
815
  __Pyx_AddTraceback("bzrlib._annotator_pyx._check_match_ranges");
 
816
  __pyx_r = -1;
 
817
  __pyx_L0:;
 
818
  __Pyx_RefNannyFinishContext();
 
819
  return __pyx_r;
 
820
}
 
821
 
 
822
/* "bzrlib/_annotator_pyx.pyx":86
 
823
 * 
 
824
 * 
 
825
 * cdef PyObject *_next_tuple_entry(object tpl, Py_ssize_t *pos): # cannot_raise             # <<<<<<<<<<<<<<
 
826
 *     """Return the next entry from this tuple.
 
827
 * 
 
828
 */
 
829
 
 
830
static  PyObject *__pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(PyObject *__pyx_v_tpl, Py_ssize_t *__pyx_v_pos) {
 
831
  PyObject *__pyx_r;
 
832
  int __pyx_t_1;
 
833
  __Pyx_RefNannySetupContext("_next_tuple_entry");
 
834
 
 
835
  /* "bzrlib/_annotator_pyx.pyx":94
 
836
 *     This cannot raise an exception, as it does no error checking.
 
837
 *     """
 
838
 *     pos[0] = pos[0] + 1             # <<<<<<<<<<<<<<
 
839
 *     if pos[0] >= PyTuple_GET_SIZE(tpl):
 
840
 *         return NULL
 
841
 */
 
842
  (__pyx_v_pos[0]) = ((__pyx_v_pos[0]) + 1);
 
843
 
 
844
  /* "bzrlib/_annotator_pyx.pyx":95
 
845
 *     """
 
846
 *     pos[0] = pos[0] + 1
 
847
 *     if pos[0] >= PyTuple_GET_SIZE(tpl):             # <<<<<<<<<<<<<<
 
848
 *         return NULL
 
849
 *     return PyTuple_GET_ITEM(tpl, pos[0])
 
850
 */
 
851
  __pyx_t_1 = ((__pyx_v_pos[0]) >= PyTuple_GET_SIZE(__pyx_v_tpl));
 
852
  if (__pyx_t_1) {
 
853
 
 
854
    /* "bzrlib/_annotator_pyx.pyx":96
 
855
 *     pos[0] = pos[0] + 1
 
856
 *     if pos[0] >= PyTuple_GET_SIZE(tpl):
 
857
 *         return NULL             # <<<<<<<<<<<<<<
 
858
 *     return PyTuple_GET_ITEM(tpl, pos[0])
 
859
 * 
 
860
 */
 
861
    __pyx_r = NULL;
 
862
    goto __pyx_L0;
 
863
    goto __pyx_L3;
 
864
  }
 
865
  __pyx_L3:;
 
866
 
 
867
  /* "bzrlib/_annotator_pyx.pyx":97
 
868
 *     if pos[0] >= PyTuple_GET_SIZE(tpl):
 
869
 *         return NULL
 
870
 *     return PyTuple_GET_ITEM(tpl, pos[0])             # <<<<<<<<<<<<<<
 
871
 * 
 
872
 * 
 
873
 */
 
874
  __pyx_r = PyTuple_GET_ITEM(__pyx_v_tpl, (__pyx_v_pos[0]));
 
875
  goto __pyx_L0;
 
876
 
 
877
  __pyx_r = 0;
 
878
  __pyx_L0:;
 
879
  __Pyx_RefNannyFinishContext();
 
880
  return __pyx_r;
 
881
}
 
882
 
 
883
/* "bzrlib/_annotator_pyx.pyx":100
 
884
 * 
 
885
 * 
 
886
 * cdef object _combine_annotations(ann_one, ann_two, cache):             # <<<<<<<<<<<<<<
 
887
 *     """Combine the annotations from both sides."""
 
888
 *     cdef Py_ssize_t pos_one, pos_two, len_one, len_two
 
889
 */
 
890
 
 
891
static  PyObject *__pyx_f_6bzrlib_14_annotator_pyx__combine_annotations(PyObject *__pyx_v_ann_one, PyObject *__pyx_v_ann_two, PyObject *__pyx_v_cache) {
 
892
  Py_ssize_t __pyx_v_pos_one;
 
893
  Py_ssize_t __pyx_v_pos_two;
 
894
  Py_ssize_t __pyx_v_out_pos;
 
895
  PyObject *__pyx_v_temp;
 
896
  PyObject *__pyx_v_left;
 
897
  PyObject *__pyx_v_right;
 
898
  PyObject *__pyx_v_cache_key;
 
899
  PyObject *__pyx_v_new_ann;
 
900
  PyObject *__pyx_r = NULL;
 
901
  int __pyx_t_1;
 
902
  PyObject *__pyx_t_2 = NULL;
 
903
  int __pyx_t_3;
 
904
  int __pyx_t_4;
 
905
  int __pyx_t_5;
 
906
  __Pyx_RefNannySetupContext("_combine_annotations");
 
907
  __pyx_v_cache_key = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
908
  __pyx_v_new_ann = Py_None; __Pyx_INCREF(Py_None);
 
909
 
 
910
  /* "bzrlib/_annotator_pyx.pyx":106
 
911
 *     cdef PyObject *temp, *left, *right
 
912
 * 
 
913
 *     if (PyObject_RichCompareBool(ann_one, ann_two, Py_LT)):             # <<<<<<<<<<<<<<
 
914
 *         cache_key = (ann_one, ann_two)
 
915
 *     else:
 
916
 */
 
917
  __pyx_t_1 = PyObject_RichCompareBool(__pyx_v_ann_one, __pyx_v_ann_two, Py_LT); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
918
  if (__pyx_t_1) {
 
919
 
 
920
    /* "bzrlib/_annotator_pyx.pyx":107
 
921
 * 
 
922
 *     if (PyObject_RichCompareBool(ann_one, ann_two, Py_LT)):
 
923
 *         cache_key = (ann_one, ann_two)             # <<<<<<<<<<<<<<
 
924
 *     else:
 
925
 *         cache_key = (ann_two, ann_one)
 
926
 */
 
927
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
928
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
929
    __Pyx_INCREF(__pyx_v_ann_one);
 
930
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_ann_one);
 
931
    __Pyx_GIVEREF(__pyx_v_ann_one);
 
932
    __Pyx_INCREF(__pyx_v_ann_two);
 
933
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_ann_two);
 
934
    __Pyx_GIVEREF(__pyx_v_ann_two);
 
935
    __Pyx_DECREF(((PyObject *)__pyx_v_cache_key));
 
936
    __pyx_v_cache_key = __pyx_t_2;
 
937
    __pyx_t_2 = 0;
 
938
    goto __pyx_L3;
 
939
  }
 
940
  /*else*/ {
 
941
 
 
942
    /* "bzrlib/_annotator_pyx.pyx":109
 
943
 *         cache_key = (ann_one, ann_two)
 
944
 *     else:
 
945
 *         cache_key = (ann_two, ann_one)             # <<<<<<<<<<<<<<
 
946
 *     temp = PyDict_GetItem(cache, cache_key)
 
947
 *     if temp != NULL:
 
948
 */
 
949
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
950
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
951
    __Pyx_INCREF(__pyx_v_ann_two);
 
952
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_ann_two);
 
953
    __Pyx_GIVEREF(__pyx_v_ann_two);
 
954
    __Pyx_INCREF(__pyx_v_ann_one);
 
955
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_ann_one);
 
956
    __Pyx_GIVEREF(__pyx_v_ann_one);
 
957
    __Pyx_DECREF(((PyObject *)__pyx_v_cache_key));
 
958
    __pyx_v_cache_key = __pyx_t_2;
 
959
    __pyx_t_2 = 0;
 
960
  }
 
961
  __pyx_L3:;
 
962
 
 
963
  /* "bzrlib/_annotator_pyx.pyx":110
 
964
 *     else:
 
965
 *         cache_key = (ann_two, ann_one)
 
966
 *     temp = PyDict_GetItem(cache, cache_key)             # <<<<<<<<<<<<<<
 
967
 *     if temp != NULL:
 
968
 *         return <object>temp
 
969
 */
 
970
  __pyx_v_temp = PyDict_GetItem(__pyx_v_cache, ((PyObject *)__pyx_v_cache_key));
 
971
 
 
972
  /* "bzrlib/_annotator_pyx.pyx":111
 
973
 *         cache_key = (ann_two, ann_one)
 
974
 *     temp = PyDict_GetItem(cache, cache_key)
 
975
 *     if temp != NULL:             # <<<<<<<<<<<<<<
 
976
 *         return <object>temp
 
977
 * 
 
978
 */
 
979
  __pyx_t_3 = (__pyx_v_temp != NULL);
 
980
  if (__pyx_t_3) {
 
981
 
 
982
    /* "bzrlib/_annotator_pyx.pyx":112
 
983
 *     temp = PyDict_GetItem(cache, cache_key)
 
984
 *     if temp != NULL:
 
985
 *         return <object>temp             # <<<<<<<<<<<<<<
 
986
 * 
 
987
 *     if not PyTuple_CheckExact(ann_one) or not PyTuple_CheckExact(ann_two):
 
988
 */
 
989
    __Pyx_XDECREF(__pyx_r);
 
990
    __Pyx_INCREF(((PyObject *)__pyx_v_temp));
 
991
    __pyx_r = ((PyObject *)__pyx_v_temp);
 
992
    goto __pyx_L0;
 
993
    goto __pyx_L4;
 
994
  }
 
995
  __pyx_L4:;
 
996
 
 
997
  /* "bzrlib/_annotator_pyx.pyx":114
 
998
 *         return <object>temp
 
999
 * 
 
1000
 *     if not PyTuple_CheckExact(ann_one) or not PyTuple_CheckExact(ann_two):             # <<<<<<<<<<<<<<
 
1001
 *         raise TypeError('annotations must be tuples')
 
1002
 *     # We know that annotations are tuples, and that both sides are already
 
1003
 */
 
1004
  __pyx_t_3 = (!PyTuple_CheckExact(__pyx_v_ann_one));
 
1005
  if (!__pyx_t_3) {
 
1006
    __pyx_t_4 = (!PyTuple_CheckExact(__pyx_v_ann_two));
 
1007
    __pyx_t_5 = __pyx_t_4;
 
1008
  } else {
 
1009
    __pyx_t_5 = __pyx_t_3;
 
1010
  }
 
1011
  if (__pyx_t_5) {
 
1012
 
 
1013
    /* "bzrlib/_annotator_pyx.pyx":115
 
1014
 * 
 
1015
 *     if not PyTuple_CheckExact(ann_one) or not PyTuple_CheckExact(ann_two):
 
1016
 *         raise TypeError('annotations must be tuples')             # <<<<<<<<<<<<<<
 
1017
 *     # We know that annotations are tuples, and that both sides are already
 
1018
 *     # sorted, so we can just walk and update a new list.
 
1019
 */
 
1020
    __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1021
    __Pyx_GOTREF(__pyx_t_2);
 
1022
    __Pyx_Raise(__pyx_t_2, 0, 0);
 
1023
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
1024
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1025
    goto __pyx_L5;
 
1026
  }
 
1027
  __pyx_L5:;
 
1028
 
 
1029
  /* "bzrlib/_annotator_pyx.pyx":118
 
1030
 *     # We know that annotations are tuples, and that both sides are already
 
1031
 *     # sorted, so we can just walk and update a new list.
 
1032
 *     pos_one = -1             # <<<<<<<<<<<<<<
 
1033
 *     pos_two = -1
 
1034
 *     out_pos = 0
 
1035
 */
 
1036
  __pyx_v_pos_one = -1;
 
1037
 
 
1038
  /* "bzrlib/_annotator_pyx.pyx":119
 
1039
 *     # sorted, so we can just walk and update a new list.
 
1040
 *     pos_one = -1
 
1041
 *     pos_two = -1             # <<<<<<<<<<<<<<
 
1042
 *     out_pos = 0
 
1043
 *     left = _next_tuple_entry(ann_one, &pos_one)
 
1044
 */
 
1045
  __pyx_v_pos_two = -1;
 
1046
 
 
1047
  /* "bzrlib/_annotator_pyx.pyx":120
 
1048
 *     pos_one = -1
 
1049
 *     pos_two = -1
 
1050
 *     out_pos = 0             # <<<<<<<<<<<<<<
 
1051
 *     left = _next_tuple_entry(ann_one, &pos_one)
 
1052
 *     right = _next_tuple_entry(ann_two, &pos_two)
 
1053
 */
 
1054
  __pyx_v_out_pos = 0;
 
1055
 
 
1056
  /* "bzrlib/_annotator_pyx.pyx":121
 
1057
 *     pos_two = -1
 
1058
 *     out_pos = 0
 
1059
 *     left = _next_tuple_entry(ann_one, &pos_one)             # <<<<<<<<<<<<<<
 
1060
 *     right = _next_tuple_entry(ann_two, &pos_two)
 
1061
 *     new_ann = PyTuple_New(PyTuple_GET_SIZE(ann_one)
 
1062
 */
 
1063
  __pyx_v_left = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_one, (&__pyx_v_pos_one));
 
1064
 
 
1065
  /* "bzrlib/_annotator_pyx.pyx":122
 
1066
 *     out_pos = 0
 
1067
 *     left = _next_tuple_entry(ann_one, &pos_one)
 
1068
 *     right = _next_tuple_entry(ann_two, &pos_two)             # <<<<<<<<<<<<<<
 
1069
 *     new_ann = PyTuple_New(PyTuple_GET_SIZE(ann_one)
 
1070
 *                           + PyTuple_GET_SIZE(ann_two))
 
1071
 */
 
1072
  __pyx_v_right = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_two, (&__pyx_v_pos_two));
 
1073
 
 
1074
  /* "bzrlib/_annotator_pyx.pyx":124
 
1075
 *     right = _next_tuple_entry(ann_two, &pos_two)
 
1076
 *     new_ann = PyTuple_New(PyTuple_GET_SIZE(ann_one)
 
1077
 *                           + PyTuple_GET_SIZE(ann_two))             # <<<<<<<<<<<<<<
 
1078
 *     while left != NULL and right != NULL:
 
1079
 *         # left == right is done by PyObject_RichCompareBool_ptr, however it
 
1080
 */
 
1081
  __pyx_t_2 = PyTuple_New((PyTuple_GET_SIZE(__pyx_v_ann_one) + PyTuple_GET_SIZE(__pyx_v_ann_two))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1082
  __Pyx_GOTREF(__pyx_t_2);
 
1083
  __Pyx_DECREF(__pyx_v_new_ann);
 
1084
  __pyx_v_new_ann = __pyx_t_2;
 
1085
  __pyx_t_2 = 0;
 
1086
 
 
1087
  /* "bzrlib/_annotator_pyx.pyx":125
 
1088
 *     new_ann = PyTuple_New(PyTuple_GET_SIZE(ann_one)
 
1089
 *                           + PyTuple_GET_SIZE(ann_two))
 
1090
 *     while left != NULL and right != NULL:             # <<<<<<<<<<<<<<
 
1091
 *         # left == right is done by PyObject_RichCompareBool_ptr, however it
 
1092
 *         # avoids a function call for a very common case. Drops 'time bzr
 
1093
 */
 
1094
  while (1) {
 
1095
    __pyx_t_5 = (__pyx_v_left != NULL);
 
1096
    if (__pyx_t_5) {
 
1097
      __pyx_t_3 = (__pyx_v_right != NULL);
 
1098
      __pyx_t_4 = __pyx_t_3;
 
1099
    } else {
 
1100
      __pyx_t_4 = __pyx_t_5;
 
1101
    }
 
1102
    if (!__pyx_t_4) break;
 
1103
 
 
1104
    /* "bzrlib/_annotator_pyx.pyx":130
 
1105
 *         # annotate NEWS' from 7.25s to 7.16s, so it *is* a visible impact.
 
1106
 *         if (left == right
 
1107
 *             or PyObject_RichCompareBool_ptr(left, right, Py_EQ)):             # <<<<<<<<<<<<<<
 
1108
 *             # Identical values, step both
 
1109
 *             Py_INCREF_ptr(left)
 
1110
 */
 
1111
    __pyx_t_4 = (__pyx_v_left == __pyx_v_right);
 
1112
    if (!__pyx_t_4) {
 
1113
      __pyx_t_5 = PyObject_RichCompareBool(__pyx_v_left, __pyx_v_right, Py_EQ);
 
1114
    } else {
 
1115
      __pyx_t_5 = __pyx_t_4;
 
1116
    }
 
1117
    if (__pyx_t_5) {
 
1118
 
 
1119
      /* "bzrlib/_annotator_pyx.pyx":132
 
1120
 *             or PyObject_RichCompareBool_ptr(left, right, Py_EQ)):
 
1121
 *             # Identical values, step both
 
1122
 *             Py_INCREF_ptr(left)             # <<<<<<<<<<<<<<
 
1123
 *             PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)
 
1124
 *             left = _next_tuple_entry(ann_one, &pos_one)
 
1125
 */
 
1126
      Py_INCREF(__pyx_v_left);
 
1127
 
 
1128
      /* "bzrlib/_annotator_pyx.pyx":133
 
1129
 *             # Identical values, step both
 
1130
 *             Py_INCREF_ptr(left)
 
1131
 *             PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)             # <<<<<<<<<<<<<<
 
1132
 *             left = _next_tuple_entry(ann_one, &pos_one)
 
1133
 *             right = _next_tuple_entry(ann_two, &pos_two)
 
1134
 */
 
1135
      PyTuple_SET_ITEM(__pyx_v_new_ann, __pyx_v_out_pos, __pyx_v_left);
 
1136
 
 
1137
      /* "bzrlib/_annotator_pyx.pyx":134
 
1138
 *             Py_INCREF_ptr(left)
 
1139
 *             PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)
 
1140
 *             left = _next_tuple_entry(ann_one, &pos_one)             # <<<<<<<<<<<<<<
 
1141
 *             right = _next_tuple_entry(ann_two, &pos_two)
 
1142
 *         elif (PyObject_RichCompareBool_ptr(left, right, Py_LT)):
 
1143
 */
 
1144
      __pyx_v_left = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_one, (&__pyx_v_pos_one));
 
1145
 
 
1146
      /* "bzrlib/_annotator_pyx.pyx":135
 
1147
 *             PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)
 
1148
 *             left = _next_tuple_entry(ann_one, &pos_one)
 
1149
 *             right = _next_tuple_entry(ann_two, &pos_two)             # <<<<<<<<<<<<<<
 
1150
 *         elif (PyObject_RichCompareBool_ptr(left, right, Py_LT)):
 
1151
 *             # left < right or right == NULL
 
1152
 */
 
1153
      __pyx_v_right = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_two, (&__pyx_v_pos_two));
 
1154
      goto __pyx_L8;
 
1155
    }
 
1156
 
 
1157
    /* "bzrlib/_annotator_pyx.pyx":136
 
1158
 *             left = _next_tuple_entry(ann_one, &pos_one)
 
1159
 *             right = _next_tuple_entry(ann_two, &pos_two)
 
1160
 *         elif (PyObject_RichCompareBool_ptr(left, right, Py_LT)):             # <<<<<<<<<<<<<<
 
1161
 *             # left < right or right == NULL
 
1162
 *             Py_INCREF_ptr(left)
 
1163
 */
 
1164
    __pyx_t_1 = PyObject_RichCompareBool(__pyx_v_left, __pyx_v_right, Py_LT);
 
1165
    if (__pyx_t_1) {
 
1166
 
 
1167
      /* "bzrlib/_annotator_pyx.pyx":138
 
1168
 *         elif (PyObject_RichCompareBool_ptr(left, right, Py_LT)):
 
1169
 *             # left < right or right == NULL
 
1170
 *             Py_INCREF_ptr(left)             # <<<<<<<<<<<<<<
 
1171
 *             PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)
 
1172
 *             left = _next_tuple_entry(ann_one, &pos_one)
 
1173
 */
 
1174
      Py_INCREF(__pyx_v_left);
 
1175
 
 
1176
      /* "bzrlib/_annotator_pyx.pyx":139
 
1177
 *             # left < right or right == NULL
 
1178
 *             Py_INCREF_ptr(left)
 
1179
 *             PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)             # <<<<<<<<<<<<<<
 
1180
 *             left = _next_tuple_entry(ann_one, &pos_one)
 
1181
 *         else: # right < left or left == NULL
 
1182
 */
 
1183
      PyTuple_SET_ITEM(__pyx_v_new_ann, __pyx_v_out_pos, __pyx_v_left);
 
1184
 
 
1185
      /* "bzrlib/_annotator_pyx.pyx":140
 
1186
 *             Py_INCREF_ptr(left)
 
1187
 *             PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)
 
1188
 *             left = _next_tuple_entry(ann_one, &pos_one)             # <<<<<<<<<<<<<<
 
1189
 *         else: # right < left or left == NULL
 
1190
 *             Py_INCREF_ptr(right)
 
1191
 */
 
1192
      __pyx_v_left = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_one, (&__pyx_v_pos_one));
 
1193
      goto __pyx_L8;
 
1194
    }
 
1195
    /*else*/ {
 
1196
 
 
1197
      /* "bzrlib/_annotator_pyx.pyx":142
 
1198
 *             left = _next_tuple_entry(ann_one, &pos_one)
 
1199
 *         else: # right < left or left == NULL
 
1200
 *             Py_INCREF_ptr(right)             # <<<<<<<<<<<<<<
 
1201
 *             PyTuple_SET_ITEM_ptr(new_ann, out_pos, right)
 
1202
 *             right = _next_tuple_entry(ann_two, &pos_two)
 
1203
 */
 
1204
      Py_INCREF(__pyx_v_right);
 
1205
 
 
1206
      /* "bzrlib/_annotator_pyx.pyx":143
 
1207
 *         else: # right < left or left == NULL
 
1208
 *             Py_INCREF_ptr(right)
 
1209
 *             PyTuple_SET_ITEM_ptr(new_ann, out_pos, right)             # <<<<<<<<<<<<<<
 
1210
 *             right = _next_tuple_entry(ann_two, &pos_two)
 
1211
 *         out_pos = out_pos + 1
 
1212
 */
 
1213
      PyTuple_SET_ITEM(__pyx_v_new_ann, __pyx_v_out_pos, __pyx_v_right);
 
1214
 
 
1215
      /* "bzrlib/_annotator_pyx.pyx":144
 
1216
 *             Py_INCREF_ptr(right)
 
1217
 *             PyTuple_SET_ITEM_ptr(new_ann, out_pos, right)
 
1218
 *             right = _next_tuple_entry(ann_two, &pos_two)             # <<<<<<<<<<<<<<
 
1219
 *         out_pos = out_pos + 1
 
1220
 *     while left != NULL:
 
1221
 */
 
1222
      __pyx_v_right = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_two, (&__pyx_v_pos_two));
 
1223
    }
 
1224
    __pyx_L8:;
 
1225
 
 
1226
    /* "bzrlib/_annotator_pyx.pyx":145
 
1227
 *             PyTuple_SET_ITEM_ptr(new_ann, out_pos, right)
 
1228
 *             right = _next_tuple_entry(ann_two, &pos_two)
 
1229
 *         out_pos = out_pos + 1             # <<<<<<<<<<<<<<
 
1230
 *     while left != NULL:
 
1231
 *         Py_INCREF_ptr(left)
 
1232
 */
 
1233
    __pyx_v_out_pos = (__pyx_v_out_pos + 1);
 
1234
  }
 
1235
 
 
1236
  /* "bzrlib/_annotator_pyx.pyx":146
 
1237
 *             right = _next_tuple_entry(ann_two, &pos_two)
 
1238
 *         out_pos = out_pos + 1
 
1239
 *     while left != NULL:             # <<<<<<<<<<<<<<
 
1240
 *         Py_INCREF_ptr(left)
 
1241
 *         PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)
 
1242
 */
 
1243
  while (1) {
 
1244
    __pyx_t_5 = (__pyx_v_left != NULL);
 
1245
    if (!__pyx_t_5) break;
 
1246
 
 
1247
    /* "bzrlib/_annotator_pyx.pyx":147
 
1248
 *         out_pos = out_pos + 1
 
1249
 *     while left != NULL:
 
1250
 *         Py_INCREF_ptr(left)             # <<<<<<<<<<<<<<
 
1251
 *         PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)
 
1252
 *         left = _next_tuple_entry(ann_one, &pos_one)
 
1253
 */
 
1254
    Py_INCREF(__pyx_v_left);
 
1255
 
 
1256
    /* "bzrlib/_annotator_pyx.pyx":148
 
1257
 *     while left != NULL:
 
1258
 *         Py_INCREF_ptr(left)
 
1259
 *         PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)             # <<<<<<<<<<<<<<
 
1260
 *         left = _next_tuple_entry(ann_one, &pos_one)
 
1261
 *         out_pos = out_pos + 1
 
1262
 */
 
1263
    PyTuple_SET_ITEM(__pyx_v_new_ann, __pyx_v_out_pos, __pyx_v_left);
 
1264
 
 
1265
    /* "bzrlib/_annotator_pyx.pyx":149
 
1266
 *         Py_INCREF_ptr(left)
 
1267
 *         PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)
 
1268
 *         left = _next_tuple_entry(ann_one, &pos_one)             # <<<<<<<<<<<<<<
 
1269
 *         out_pos = out_pos + 1
 
1270
 *     while right != NULL:
 
1271
 */
 
1272
    __pyx_v_left = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_one, (&__pyx_v_pos_one));
 
1273
 
 
1274
    /* "bzrlib/_annotator_pyx.pyx":150
 
1275
 *         PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)
 
1276
 *         left = _next_tuple_entry(ann_one, &pos_one)
 
1277
 *         out_pos = out_pos + 1             # <<<<<<<<<<<<<<
 
1278
 *     while right != NULL:
 
1279
 *         Py_INCREF_ptr(right)
 
1280
 */
 
1281
    __pyx_v_out_pos = (__pyx_v_out_pos + 1);
 
1282
  }
 
1283
 
 
1284
  /* "bzrlib/_annotator_pyx.pyx":151
 
1285
 *         left = _next_tuple_entry(ann_one, &pos_one)
 
1286
 *         out_pos = out_pos + 1
 
1287
 *     while right != NULL:             # <<<<<<<<<<<<<<
 
1288
 *         Py_INCREF_ptr(right)
 
1289
 *         PyTuple_SET_ITEM_ptr(new_ann, out_pos, right)
 
1290
 */
 
1291
  while (1) {
 
1292
    __pyx_t_5 = (__pyx_v_right != NULL);
 
1293
    if (!__pyx_t_5) break;
 
1294
 
 
1295
    /* "bzrlib/_annotator_pyx.pyx":152
 
1296
 *         out_pos = out_pos + 1
 
1297
 *     while right != NULL:
 
1298
 *         Py_INCREF_ptr(right)             # <<<<<<<<<<<<<<
 
1299
 *         PyTuple_SET_ITEM_ptr(new_ann, out_pos, right)
 
1300
 *         right = _next_tuple_entry(ann_two, &pos_two)
 
1301
 */
 
1302
    Py_INCREF(__pyx_v_right);
 
1303
 
 
1304
    /* "bzrlib/_annotator_pyx.pyx":153
 
1305
 *     while right != NULL:
 
1306
 *         Py_INCREF_ptr(right)
 
1307
 *         PyTuple_SET_ITEM_ptr(new_ann, out_pos, right)             # <<<<<<<<<<<<<<
 
1308
 *         right = _next_tuple_entry(ann_two, &pos_two)
 
1309
 *         out_pos = out_pos + 1
 
1310
 */
 
1311
    PyTuple_SET_ITEM(__pyx_v_new_ann, __pyx_v_out_pos, __pyx_v_right);
 
1312
 
 
1313
    /* "bzrlib/_annotator_pyx.pyx":154
 
1314
 *         Py_INCREF_ptr(right)
 
1315
 *         PyTuple_SET_ITEM_ptr(new_ann, out_pos, right)
 
1316
 *         right = _next_tuple_entry(ann_two, &pos_two)             # <<<<<<<<<<<<<<
 
1317
 *         out_pos = out_pos + 1
 
1318
 *     if out_pos != PyTuple_GET_SIZE(new_ann):
 
1319
 */
 
1320
    __pyx_v_right = __pyx_f_6bzrlib_14_annotator_pyx__next_tuple_entry(__pyx_v_ann_two, (&__pyx_v_pos_two));
 
1321
 
 
1322
    /* "bzrlib/_annotator_pyx.pyx":155
 
1323
 *         PyTuple_SET_ITEM_ptr(new_ann, out_pos, right)
 
1324
 *         right = _next_tuple_entry(ann_two, &pos_two)
 
1325
 *         out_pos = out_pos + 1             # <<<<<<<<<<<<<<
 
1326
 *     if out_pos != PyTuple_GET_SIZE(new_ann):
 
1327
 *         # Timing _PyTuple_Resize was not significantly faster that slicing
 
1328
 */
 
1329
    __pyx_v_out_pos = (__pyx_v_out_pos + 1);
 
1330
  }
 
1331
 
 
1332
  /* "bzrlib/_annotator_pyx.pyx":156
 
1333
 *         right = _next_tuple_entry(ann_two, &pos_two)
 
1334
 *         out_pos = out_pos + 1
 
1335
 *     if out_pos != PyTuple_GET_SIZE(new_ann):             # <<<<<<<<<<<<<<
 
1336
 *         # Timing _PyTuple_Resize was not significantly faster that slicing
 
1337
 *         # PyTuple_Resize((<PyObject **>new_ann), out_pos)
 
1338
 */
 
1339
  __pyx_t_5 = (__pyx_v_out_pos != PyTuple_GET_SIZE(__pyx_v_new_ann));
 
1340
  if (__pyx_t_5) {
 
1341
 
 
1342
    /* "bzrlib/_annotator_pyx.pyx":159
 
1343
 *         # Timing _PyTuple_Resize was not significantly faster that slicing
 
1344
 *         # PyTuple_Resize((<PyObject **>new_ann), out_pos)
 
1345
 *         new_ann = new_ann[0:out_pos]             # <<<<<<<<<<<<<<
 
1346
 *     PyDict_SetItem(cache, cache_key, new_ann)
 
1347
 *     return new_ann
 
1348
 */
 
1349
    __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_v_new_ann, 0, __pyx_v_out_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1350
    __Pyx_GOTREF(__pyx_t_2);
 
1351
    __Pyx_DECREF(__pyx_v_new_ann);
 
1352
    __pyx_v_new_ann = __pyx_t_2;
 
1353
    __pyx_t_2 = 0;
 
1354
    goto __pyx_L13;
 
1355
  }
 
1356
  __pyx_L13:;
 
1357
 
 
1358
  /* "bzrlib/_annotator_pyx.pyx":160
 
1359
 *         # PyTuple_Resize((<PyObject **>new_ann), out_pos)
 
1360
 *         new_ann = new_ann[0:out_pos]
 
1361
 *     PyDict_SetItem(cache, cache_key, new_ann)             # <<<<<<<<<<<<<<
 
1362
 *     return new_ann
 
1363
 * 
 
1364
 */
 
1365
  __pyx_t_1 = PyDict_SetItem(__pyx_v_cache, ((PyObject *)__pyx_v_cache_key), __pyx_v_new_ann); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1366
 
 
1367
  /* "bzrlib/_annotator_pyx.pyx":161
 
1368
 *         new_ann = new_ann[0:out_pos]
 
1369
 *     PyDict_SetItem(cache, cache_key, new_ann)
 
1370
 *     return new_ann             # <<<<<<<<<<<<<<
 
1371
 * 
 
1372
 * 
 
1373
 */
 
1374
  __Pyx_XDECREF(__pyx_r);
 
1375
  __Pyx_INCREF(__pyx_v_new_ann);
 
1376
  __pyx_r = __pyx_v_new_ann;
 
1377
  goto __pyx_L0;
 
1378
 
 
1379
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
1380
  goto __pyx_L0;
 
1381
  __pyx_L1_error:;
 
1382
  __Pyx_XDECREF(__pyx_t_2);
 
1383
  __Pyx_AddTraceback("bzrlib._annotator_pyx._combine_annotations");
 
1384
  __pyx_r = 0;
 
1385
  __pyx_L0:;
 
1386
  __Pyx_DECREF(__pyx_v_cache_key);
 
1387
  __Pyx_DECREF(__pyx_v_new_ann);
 
1388
  __Pyx_XGIVEREF(__pyx_r);
 
1389
  __Pyx_RefNannyFinishContext();
 
1390
  return __pyx_r;
 
1391
}
 
1392
 
 
1393
/* "bzrlib/_annotator_pyx.pyx":164
 
1394
 * 
 
1395
 * 
 
1396
 * cdef int _apply_parent_annotations(annotations, parent_annotations,             # <<<<<<<<<<<<<<
 
1397
 *                                    matching_blocks) except -1:
 
1398
 *     """Apply the annotations from parent_annotations into annotations.
 
1399
 */
 
1400
 
 
1401
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) {
 
1402
  Py_ssize_t __pyx_v_parent_idx;
 
1403
  Py_ssize_t __pyx_v_lines_idx;
 
1404
  Py_ssize_t __pyx_v_match_len;
 
1405
  Py_ssize_t __pyx_v_idx;
 
1406
  PyListObject *__pyx_v_par_list;
 
1407
  PyListObject *__pyx_v_ann_list;
 
1408
  PyObject **__pyx_v_par_temp;
 
1409
  PyObject **__pyx_v_ann_temp;
 
1410
  int __pyx_r;
 
1411
  int __pyx_t_1;
 
1412
  Py_ssize_t __pyx_t_2;
 
1413
  PyObject *__pyx_t_3 = NULL;
 
1414
  PyObject *__pyx_t_4 = NULL;
 
1415
  PyObject *__pyx_t_5 = NULL;
 
1416
  PyObject *__pyx_t_6 = NULL;
 
1417
  PyObject *__pyx_t_7 = NULL;
 
1418
  Py_ssize_t __pyx_t_8;
 
1419
  Py_ssize_t __pyx_t_9;
 
1420
  Py_ssize_t __pyx_t_10;
 
1421
  PyObject *__pyx_t_11 = NULL;
 
1422
  __Pyx_RefNannySetupContext("_apply_parent_annotations");
 
1423
 
 
1424
  /* "bzrlib/_annotator_pyx.pyx":174
 
1425
 *     cdef PyObject **par_temp, **ann_temp
 
1426
 * 
 
1427
 *     _check_annotations_are_lists(annotations, parent_annotations)             # <<<<<<<<<<<<<<
 
1428
 *     par_list = <PyListObject *>parent_annotations
 
1429
 *     ann_list = <PyListObject *>annotations
 
1430
 */
 
1431
  __pyx_t_1 = __pyx_f_6bzrlib_14_annotator_pyx__check_annotations_are_lists(__pyx_v_annotations, __pyx_v_parent_annotations); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1432
 
 
1433
  /* "bzrlib/_annotator_pyx.pyx":175
 
1434
 * 
 
1435
 *     _check_annotations_are_lists(annotations, parent_annotations)
 
1436
 *     par_list = <PyListObject *>parent_annotations             # <<<<<<<<<<<<<<
 
1437
 *     ann_list = <PyListObject *>annotations
 
1438
 *     # For NEWS and bzrlib/builtins.py, over 99% of the lines are simply copied
 
1439
 */
 
1440
  __pyx_v_par_list = ((PyListObject *)__pyx_v_parent_annotations);
 
1441
 
 
1442
  /* "bzrlib/_annotator_pyx.pyx":176
 
1443
 *     _check_annotations_are_lists(annotations, parent_annotations)
 
1444
 *     par_list = <PyListObject *>parent_annotations
 
1445
 *     ann_list = <PyListObject *>annotations             # <<<<<<<<<<<<<<
 
1446
 *     # For NEWS and bzrlib/builtins.py, over 99% of the lines are simply copied
 
1447
 *     # across from the parent entry. So this routine is heavily optimized for
 
1448
 */
 
1449
  __pyx_v_ann_list = ((PyListObject *)__pyx_v_annotations);
 
1450
 
 
1451
  /* "bzrlib/_annotator_pyx.pyx":181
 
1452
 *     # that. Would be interesting if we could use memcpy() but we have to incref
 
1453
 *     # and decref
 
1454
 *     for parent_idx, lines_idx, match_len in matching_blocks:             # <<<<<<<<<<<<<<
 
1455
 *         _check_match_ranges(parent_annotations, annotations,
 
1456
 *                             parent_idx, lines_idx, match_len)
 
1457
 */
 
1458
  if (PyList_CheckExact(__pyx_v_matching_blocks) || PyTuple_CheckExact(__pyx_v_matching_blocks)) {
 
1459
    __pyx_t_2 = 0; __pyx_t_3 = __pyx_v_matching_blocks; __Pyx_INCREF(__pyx_t_3);
 
1460
  } else {
 
1461
    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_matching_blocks); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1462
    __Pyx_GOTREF(__pyx_t_3);
 
1463
  }
 
1464
  for (;;) {
 
1465
    if (likely(PyList_CheckExact(__pyx_t_3))) {
 
1466
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
 
1467
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
 
1468
    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
 
1469
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
 
1470
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
 
1471
    } else {
 
1472
      __pyx_t_4 = PyIter_Next(__pyx_t_3);
 
1473
      if (!__pyx_t_4) {
 
1474
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1475
        break;
 
1476
      }
 
1477
      __Pyx_GOTREF(__pyx_t_4);
 
1478
    }
 
1479
    if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 3)) {
 
1480
      PyObject* tuple = __pyx_t_4;
 
1481
      __pyx_t_5 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_5);
 
1482
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1483
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
1484
      __pyx_t_6 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_6);
 
1485
      __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1486
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
1487
      __pyx_t_7 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_7);
 
1488
      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1489
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
1490
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
1491
      __pyx_v_parent_idx = __pyx_t_8;
 
1492
      __pyx_v_lines_idx = __pyx_t_9;
 
1493
      __pyx_v_match_len = __pyx_t_10;
 
1494
    } else {
 
1495
      __pyx_t_11 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1496
      __Pyx_GOTREF(__pyx_t_11);
 
1497
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
1498
      __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_11, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1499
      __Pyx_GOTREF(__pyx_t_5);
 
1500
      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1501
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
1502
      __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_11, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1503
      __Pyx_GOTREF(__pyx_t_6);
 
1504
      __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1505
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
1506
      __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_11, 2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1507
      __Pyx_GOTREF(__pyx_t_7);
 
1508
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1509
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
1510
      if (__Pyx_EndUnpack(__pyx_t_11, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1511
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
 
1512
      __pyx_v_parent_idx = __pyx_t_10;
 
1513
      __pyx_v_lines_idx = __pyx_t_9;
 
1514
      __pyx_v_match_len = __pyx_t_8;
 
1515
    }
 
1516
 
 
1517
    /* "bzrlib/_annotator_pyx.pyx":183
 
1518
 *     for parent_idx, lines_idx, match_len in matching_blocks:
 
1519
 *         _check_match_ranges(parent_annotations, annotations,
 
1520
 *                             parent_idx, lines_idx, match_len)             # <<<<<<<<<<<<<<
 
1521
 *         par_temp = par_list.ob_item + parent_idx
 
1522
 *         ann_temp = ann_list.ob_item + lines_idx
 
1523
 */
 
1524
    __pyx_t_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 (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1525
 
 
1526
    /* "bzrlib/_annotator_pyx.pyx":184
 
1527
 *         _check_match_ranges(parent_annotations, annotations,
 
1528
 *                             parent_idx, lines_idx, match_len)
 
1529
 *         par_temp = par_list.ob_item + parent_idx             # <<<<<<<<<<<<<<
 
1530
 *         ann_temp = ann_list.ob_item + lines_idx
 
1531
 *         for idx from 0 <= idx < match_len:
 
1532
 */
 
1533
    __pyx_v_par_temp = (__pyx_v_par_list->ob_item + __pyx_v_parent_idx);
 
1534
 
 
1535
    /* "bzrlib/_annotator_pyx.pyx":185
 
1536
 *                             parent_idx, lines_idx, match_len)
 
1537
 *         par_temp = par_list.ob_item + parent_idx
 
1538
 *         ann_temp = ann_list.ob_item + lines_idx             # <<<<<<<<<<<<<<
 
1539
 *         for idx from 0 <= idx < match_len:
 
1540
 *             Py_INCREF_ptr(par_temp[idx])
 
1541
 */
 
1542
    __pyx_v_ann_temp = (__pyx_v_ann_list->ob_item + __pyx_v_lines_idx);
 
1543
 
 
1544
    /* "bzrlib/_annotator_pyx.pyx":186
 
1545
 *         par_temp = par_list.ob_item + parent_idx
 
1546
 *         ann_temp = ann_list.ob_item + lines_idx
 
1547
 *         for idx from 0 <= idx < match_len:             # <<<<<<<<<<<<<<
 
1548
 *             Py_INCREF_ptr(par_temp[idx])
 
1549
 *             Py_DECREF_ptr(ann_temp[idx])
 
1550
 */
 
1551
    __pyx_t_8 = __pyx_v_match_len;
 
1552
    for (__pyx_v_idx = 0; __pyx_v_idx < __pyx_t_8; __pyx_v_idx++) {
 
1553
 
 
1554
      /* "bzrlib/_annotator_pyx.pyx":187
 
1555
 *         ann_temp = ann_list.ob_item + lines_idx
 
1556
 *         for idx from 0 <= idx < match_len:
 
1557
 *             Py_INCREF_ptr(par_temp[idx])             # <<<<<<<<<<<<<<
 
1558
 *             Py_DECREF_ptr(ann_temp[idx])
 
1559
 *             ann_temp[idx] = par_temp[idx]
 
1560
 */
 
1561
      Py_INCREF((__pyx_v_par_temp[__pyx_v_idx]));
 
1562
 
 
1563
      /* "bzrlib/_annotator_pyx.pyx":188
 
1564
 *         for idx from 0 <= idx < match_len:
 
1565
 *             Py_INCREF_ptr(par_temp[idx])
 
1566
 *             Py_DECREF_ptr(ann_temp[idx])             # <<<<<<<<<<<<<<
 
1567
 *             ann_temp[idx] = par_temp[idx]
 
1568
 *     return 0
 
1569
 */
 
1570
      Py_DECREF((__pyx_v_ann_temp[__pyx_v_idx]));
 
1571
 
 
1572
      /* "bzrlib/_annotator_pyx.pyx":189
 
1573
 *             Py_INCREF_ptr(par_temp[idx])
 
1574
 *             Py_DECREF_ptr(ann_temp[idx])
 
1575
 *             ann_temp[idx] = par_temp[idx]             # <<<<<<<<<<<<<<
 
1576
 *     return 0
 
1577
 * 
 
1578
 */
 
1579
      (__pyx_v_ann_temp[__pyx_v_idx]) = (__pyx_v_par_temp[__pyx_v_idx]);
 
1580
    }
 
1581
  }
 
1582
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
1583
 
 
1584
  /* "bzrlib/_annotator_pyx.pyx":190
 
1585
 *             Py_DECREF_ptr(ann_temp[idx])
 
1586
 *             ann_temp[idx] = par_temp[idx]
 
1587
 *     return 0             # <<<<<<<<<<<<<<
 
1588
 * 
 
1589
 * 
 
1590
 */
 
1591
  __pyx_r = 0;
 
1592
  goto __pyx_L0;
 
1593
 
 
1594
  __pyx_r = 0;
 
1595
  goto __pyx_L0;
 
1596
  __pyx_L1_error:;
 
1597
  __Pyx_XDECREF(__pyx_t_3);
 
1598
  __Pyx_XDECREF(__pyx_t_4);
 
1599
  __Pyx_XDECREF(__pyx_t_5);
 
1600
  __Pyx_XDECREF(__pyx_t_6);
 
1601
  __Pyx_XDECREF(__pyx_t_7);
 
1602
  __Pyx_XDECREF(__pyx_t_11);
 
1603
  __Pyx_AddTraceback("bzrlib._annotator_pyx._apply_parent_annotations");
 
1604
  __pyx_r = -1;
 
1605
  __pyx_L0:;
 
1606
  __Pyx_RefNannyFinishContext();
 
1607
  return __pyx_r;
 
1608
}
 
1609
 
 
1610
/* "bzrlib/_annotator_pyx.pyx":193
 
1611
 * 
 
1612
 * 
 
1613
 * cdef int _merge_annotations(this_annotation, annotations, parent_annotations,             # <<<<<<<<<<<<<<
 
1614
 *                             matching_blocks, ann_cache) except -1:
 
1615
 *     cdef Py_ssize_t parent_idx, ann_idx, lines_idx, match_len, idx
 
1616
 */
 
1617
 
 
1618
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) {
 
1619
  Py_ssize_t __pyx_v_parent_idx;
 
1620
  Py_ssize_t __pyx_v_ann_idx;
 
1621
  Py_ssize_t __pyx_v_lines_idx;
 
1622
  Py_ssize_t __pyx_v_match_len;
 
1623
  Py_ssize_t __pyx_v_idx;
 
1624
  PyObject *__pyx_v_ann_temp;
 
1625
  PyObject *__pyx_v_par_temp;
 
1626
  PyObject *__pyx_v_last_ann;
 
1627
  PyObject *__pyx_v_last_parent;
 
1628
  PyObject *__pyx_v_last_res;
 
1629
  PyObject *__pyx_v_par_ann;
 
1630
  PyObject *__pyx_v_ann;
 
1631
  PyObject *__pyx_v_new_ann;
 
1632
  int __pyx_r;
 
1633
  int __pyx_t_1;
 
1634
  Py_ssize_t __pyx_t_2;
 
1635
  PyObject *__pyx_t_3 = NULL;
 
1636
  PyObject *__pyx_t_4 = NULL;
 
1637
  PyObject *__pyx_t_5 = NULL;
 
1638
  PyObject *__pyx_t_6 = NULL;
 
1639
  PyObject *__pyx_t_7 = NULL;
 
1640
  Py_ssize_t __pyx_t_8;
 
1641
  Py_ssize_t __pyx_t_9;
 
1642
  Py_ssize_t __pyx_t_10;
 
1643
  PyObject *__pyx_t_11 = NULL;
 
1644
  int __pyx_t_12;
 
1645
  int __pyx_t_13;
 
1646
  int __pyx_t_14;
 
1647
  __Pyx_RefNannySetupContext("_merge_annotations");
 
1648
  __pyx_v_last_ann = Py_None; __Pyx_INCREF(Py_None);
 
1649
  __pyx_v_last_parent = Py_None; __Pyx_INCREF(Py_None);
 
1650
  __pyx_v_last_res = Py_None; __Pyx_INCREF(Py_None);
 
1651
  __pyx_v_par_ann = Py_None; __Pyx_INCREF(Py_None);
 
1652
  __pyx_v_ann = Py_None; __Pyx_INCREF(Py_None);
 
1653
  __pyx_v_new_ann = Py_None; __Pyx_INCREF(Py_None);
 
1654
 
 
1655
  /* "bzrlib/_annotator_pyx.pyx":199
 
1656
 *     cdef PyObject *ann_temp, *par_temp
 
1657
 * 
 
1658
 *     _check_annotations_are_lists(annotations, parent_annotations)             # <<<<<<<<<<<<<<
 
1659
 *     last_ann = None
 
1660
 *     last_parent = None
 
1661
 */
 
1662
  __pyx_t_1 = __pyx_f_6bzrlib_14_annotator_pyx__check_annotations_are_lists(__pyx_v_annotations, __pyx_v_parent_annotations); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1663
 
 
1664
  /* "bzrlib/_annotator_pyx.pyx":200
 
1665
 * 
 
1666
 *     _check_annotations_are_lists(annotations, parent_annotations)
 
1667
 *     last_ann = None             # <<<<<<<<<<<<<<
 
1668
 *     last_parent = None
 
1669
 *     last_res = None
 
1670
 */
 
1671
  __Pyx_INCREF(Py_None);
 
1672
  __Pyx_DECREF(__pyx_v_last_ann);
 
1673
  __pyx_v_last_ann = Py_None;
 
1674
 
 
1675
  /* "bzrlib/_annotator_pyx.pyx":201
 
1676
 *     _check_annotations_are_lists(annotations, parent_annotations)
 
1677
 *     last_ann = None
 
1678
 *     last_parent = None             # <<<<<<<<<<<<<<
 
1679
 *     last_res = None
 
1680
 *     for parent_idx, lines_idx, match_len in matching_blocks:
 
1681
 */
 
1682
  __Pyx_INCREF(Py_None);
 
1683
  __Pyx_DECREF(__pyx_v_last_parent);
 
1684
  __pyx_v_last_parent = Py_None;
 
1685
 
 
1686
  /* "bzrlib/_annotator_pyx.pyx":202
 
1687
 *     last_ann = None
 
1688
 *     last_parent = None
 
1689
 *     last_res = None             # <<<<<<<<<<<<<<
 
1690
 *     for parent_idx, lines_idx, match_len in matching_blocks:
 
1691
 *         _check_match_ranges(parent_annotations, annotations,
 
1692
 */
 
1693
  __Pyx_INCREF(Py_None);
 
1694
  __Pyx_DECREF(__pyx_v_last_res);
 
1695
  __pyx_v_last_res = Py_None;
 
1696
 
 
1697
  /* "bzrlib/_annotator_pyx.pyx":203
 
1698
 *     last_parent = None
 
1699
 *     last_res = None
 
1700
 *     for parent_idx, lines_idx, match_len in matching_blocks:             # <<<<<<<<<<<<<<
 
1701
 *         _check_match_ranges(parent_annotations, annotations,
 
1702
 *                             parent_idx, lines_idx, match_len)
 
1703
 */
 
1704
  if (PyList_CheckExact(__pyx_v_matching_blocks) || PyTuple_CheckExact(__pyx_v_matching_blocks)) {
 
1705
    __pyx_t_2 = 0; __pyx_t_3 = __pyx_v_matching_blocks; __Pyx_INCREF(__pyx_t_3);
 
1706
  } else {
 
1707
    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_matching_blocks); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1708
    __Pyx_GOTREF(__pyx_t_3);
 
1709
  }
 
1710
  for (;;) {
 
1711
    if (likely(PyList_CheckExact(__pyx_t_3))) {
 
1712
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
 
1713
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
 
1714
    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
 
1715
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
 
1716
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
 
1717
    } else {
 
1718
      __pyx_t_4 = PyIter_Next(__pyx_t_3);
 
1719
      if (!__pyx_t_4) {
 
1720
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1721
        break;
 
1722
      }
 
1723
      __Pyx_GOTREF(__pyx_t_4);
 
1724
    }
 
1725
    if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 3)) {
 
1726
      PyObject* tuple = __pyx_t_4;
 
1727
      __pyx_t_5 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_5);
 
1728
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1729
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
1730
      __pyx_t_6 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_6);
 
1731
      __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1732
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
1733
      __pyx_t_7 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_7);
 
1734
      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1735
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
1736
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
1737
      __pyx_v_parent_idx = __pyx_t_8;
 
1738
      __pyx_v_lines_idx = __pyx_t_9;
 
1739
      __pyx_v_match_len = __pyx_t_10;
 
1740
    } else {
 
1741
      __pyx_t_11 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1742
      __Pyx_GOTREF(__pyx_t_11);
 
1743
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
1744
      __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_11, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1745
      __Pyx_GOTREF(__pyx_t_5);
 
1746
      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1747
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
1748
      __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_11, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1749
      __Pyx_GOTREF(__pyx_t_6);
 
1750
      __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1751
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
1752
      __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_11, 2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1753
      __Pyx_GOTREF(__pyx_t_7);
 
1754
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1755
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
1756
      if (__Pyx_EndUnpack(__pyx_t_11, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1757
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
 
1758
      __pyx_v_parent_idx = __pyx_t_10;
 
1759
      __pyx_v_lines_idx = __pyx_t_9;
 
1760
      __pyx_v_match_len = __pyx_t_8;
 
1761
    }
 
1762
 
 
1763
    /* "bzrlib/_annotator_pyx.pyx":205
 
1764
 *     for parent_idx, lines_idx, match_len in matching_blocks:
 
1765
 *         _check_match_ranges(parent_annotations, annotations,
 
1766
 *                             parent_idx, lines_idx, match_len)             # <<<<<<<<<<<<<<
 
1767
 *         # For lines which match this parent, we will now resolve whether
 
1768
 *         # this parent wins over the current annotation
 
1769
 */
 
1770
    __pyx_t_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 (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1771
 
 
1772
    /* "bzrlib/_annotator_pyx.pyx":208
 
1773
 *         # For lines which match this parent, we will now resolve whether
 
1774
 *         # this parent wins over the current annotation
 
1775
 *         for idx from 0 <= idx < match_len:             # <<<<<<<<<<<<<<
 
1776
 *             ann_idx = lines_idx + idx
 
1777
 *             ann_temp = PyList_GET_ITEM(annotations, ann_idx)
 
1778
 */
 
1779
    __pyx_t_8 = __pyx_v_match_len;
 
1780
    for (__pyx_v_idx = 0; __pyx_v_idx < __pyx_t_8; __pyx_v_idx++) {
 
1781
 
 
1782
      /* "bzrlib/_annotator_pyx.pyx":209
 
1783
 *         # this parent wins over the current annotation
 
1784
 *         for idx from 0 <= idx < match_len:
 
1785
 *             ann_idx = lines_idx + idx             # <<<<<<<<<<<<<<
 
1786
 *             ann_temp = PyList_GET_ITEM(annotations, ann_idx)
 
1787
 *             par_temp = PyList_GET_ITEM(parent_annotations, parent_idx + idx)
 
1788
 */
 
1789
      __pyx_v_ann_idx = (__pyx_v_lines_idx + __pyx_v_idx);
 
1790
 
 
1791
      /* "bzrlib/_annotator_pyx.pyx":210
 
1792
 *         for idx from 0 <= idx < match_len:
 
1793
 *             ann_idx = lines_idx + idx
 
1794
 *             ann_temp = PyList_GET_ITEM(annotations, ann_idx)             # <<<<<<<<<<<<<<
 
1795
 *             par_temp = PyList_GET_ITEM(parent_annotations, parent_idx + idx)
 
1796
 *             if (ann_temp == par_temp):
 
1797
 */
 
1798
      __pyx_v_ann_temp = PyList_GET_ITEM(__pyx_v_annotations, __pyx_v_ann_idx);
 
1799
 
 
1800
      /* "bzrlib/_annotator_pyx.pyx":211
 
1801
 *             ann_idx = lines_idx + idx
 
1802
 *             ann_temp = PyList_GET_ITEM(annotations, ann_idx)
 
1803
 *             par_temp = PyList_GET_ITEM(parent_annotations, parent_idx + idx)             # <<<<<<<<<<<<<<
 
1804
 *             if (ann_temp == par_temp):
 
1805
 *                 # This is parent, do nothing
 
1806
 */
 
1807
      __pyx_v_par_temp = PyList_GET_ITEM(__pyx_v_parent_annotations, (__pyx_v_parent_idx + __pyx_v_idx));
 
1808
 
 
1809
      /* "bzrlib/_annotator_pyx.pyx":212
 
1810
 *             ann_temp = PyList_GET_ITEM(annotations, ann_idx)
 
1811
 *             par_temp = PyList_GET_ITEM(parent_annotations, parent_idx + idx)
 
1812
 *             if (ann_temp == par_temp):             # <<<<<<<<<<<<<<
 
1813
 *                 # This is parent, do nothing
 
1814
 *                 # Pointer comparison is fine here. Value comparison would
 
1815
 */
 
1816
      __pyx_t_12 = (__pyx_v_ann_temp == __pyx_v_par_temp);
 
1817
      if (__pyx_t_12) {
 
1818
 
 
1819
        /* "bzrlib/_annotator_pyx.pyx":220
 
1820
 *                 # PyObject_RichCompareBool using pointer comparison drops
 
1821
 *                 # timing from 215ms => 125ms
 
1822
 *                 continue             # <<<<<<<<<<<<<<
 
1823
 *             par_ann = <object>par_temp
 
1824
 *             ann = <object>ann_temp
 
1825
 */
 
1826
        goto __pyx_L5_continue;
 
1827
        goto __pyx_L7;
 
1828
      }
 
1829
      __pyx_L7:;
 
1830
 
 
1831
      /* "bzrlib/_annotator_pyx.pyx":221
 
1832
 *                 # timing from 215ms => 125ms
 
1833
 *                 continue
 
1834
 *             par_ann = <object>par_temp             # <<<<<<<<<<<<<<
 
1835
 *             ann = <object>ann_temp
 
1836
 *             if (ann is this_annotation):
 
1837
 */
 
1838
      __Pyx_INCREF(((PyObject *)__pyx_v_par_temp));
 
1839
      __Pyx_DECREF(__pyx_v_par_ann);
 
1840
      __pyx_v_par_ann = ((PyObject *)__pyx_v_par_temp);
 
1841
 
 
1842
      /* "bzrlib/_annotator_pyx.pyx":222
 
1843
 *                 continue
 
1844
 *             par_ann = <object>par_temp
 
1845
 *             ann = <object>ann_temp             # <<<<<<<<<<<<<<
 
1846
 *             if (ann is this_annotation):
 
1847
 *                 # Originally claimed 'this', but it was really in this
 
1848
 */
 
1849
      __Pyx_INCREF(((PyObject *)__pyx_v_ann_temp));
 
1850
      __Pyx_DECREF(__pyx_v_ann);
 
1851
      __pyx_v_ann = ((PyObject *)__pyx_v_ann_temp);
 
1852
 
 
1853
      /* "bzrlib/_annotator_pyx.pyx":223
 
1854
 *             par_ann = <object>par_temp
 
1855
 *             ann = <object>ann_temp
 
1856
 *             if (ann is this_annotation):             # <<<<<<<<<<<<<<
 
1857
 *                 # Originally claimed 'this', but it was really in this
 
1858
 *                 # parent
 
1859
 */
 
1860
      __pyx_t_12 = (__pyx_v_ann == __pyx_v_this_annotation);
 
1861
      if (__pyx_t_12) {
 
1862
 
 
1863
        /* "bzrlib/_annotator_pyx.pyx":226
 
1864
 *                 # Originally claimed 'this', but it was really in this
 
1865
 *                 # parent
 
1866
 *                 Py_INCREF(par_ann)             # <<<<<<<<<<<<<<
 
1867
 *                 PyList_SetItem(annotations, ann_idx, par_ann)
 
1868
 *                 continue
 
1869
 */
 
1870
        Py_INCREF(__pyx_v_par_ann);
 
1871
 
 
1872
        /* "bzrlib/_annotator_pyx.pyx":227
 
1873
 *                 # parent
 
1874
 *                 Py_INCREF(par_ann)
 
1875
 *                 PyList_SetItem(annotations, ann_idx, par_ann)             # <<<<<<<<<<<<<<
 
1876
 *                 continue
 
1877
 *             # Resolve the fact that both sides have a different value for
 
1878
 */
 
1879
        __pyx_t_1 = PyList_SetItem(__pyx_v_annotations, __pyx_v_ann_idx, __pyx_v_par_ann); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1880
 
 
1881
        /* "bzrlib/_annotator_pyx.pyx":228
 
1882
 *                 Py_INCREF(par_ann)
 
1883
 *                 PyList_SetItem(annotations, ann_idx, par_ann)
 
1884
 *                 continue             # <<<<<<<<<<<<<<
 
1885
 *             # Resolve the fact that both sides have a different value for
 
1886
 *             # last modified
 
1887
 */
 
1888
        goto __pyx_L5_continue;
 
1889
        goto __pyx_L8;
 
1890
      }
 
1891
      __pyx_L8:;
 
1892
 
 
1893
      /* "bzrlib/_annotator_pyx.pyx":231
 
1894
 *             # Resolve the fact that both sides have a different value for
 
1895
 *             # last modified
 
1896
 *             if (ann is last_ann and par_ann is last_parent):             # <<<<<<<<<<<<<<
 
1897
 *                 Py_INCREF(last_res)
 
1898
 *                 PyList_SetItem(annotations, ann_idx, last_res)
 
1899
 */
 
1900
      __pyx_t_12 = (__pyx_v_ann == __pyx_v_last_ann);
 
1901
      if (__pyx_t_12) {
 
1902
        __pyx_t_13 = (__pyx_v_par_ann == __pyx_v_last_parent);
 
1903
        __pyx_t_14 = __pyx_t_13;
 
1904
      } else {
 
1905
        __pyx_t_14 = __pyx_t_12;
 
1906
      }
 
1907
      if (__pyx_t_14) {
 
1908
 
 
1909
        /* "bzrlib/_annotator_pyx.pyx":232
 
1910
 *             # last modified
 
1911
 *             if (ann is last_ann and par_ann is last_parent):
 
1912
 *                 Py_INCREF(last_res)             # <<<<<<<<<<<<<<
 
1913
 *                 PyList_SetItem(annotations, ann_idx, last_res)
 
1914
 *             else:
 
1915
 */
 
1916
        Py_INCREF(__pyx_v_last_res);
 
1917
 
 
1918
        /* "bzrlib/_annotator_pyx.pyx":233
 
1919
 *             if (ann is last_ann and par_ann is last_parent):
 
1920
 *                 Py_INCREF(last_res)
 
1921
 *                 PyList_SetItem(annotations, ann_idx, last_res)             # <<<<<<<<<<<<<<
 
1922
 *             else:
 
1923
 *                 new_ann = _combine_annotations(ann, par_ann, ann_cache)
 
1924
 */
 
1925
        __pyx_t_1 = PyList_SetItem(__pyx_v_annotations, __pyx_v_ann_idx, __pyx_v_last_res); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1926
        goto __pyx_L9;
 
1927
      }
 
1928
      /*else*/ {
 
1929
 
 
1930
        /* "bzrlib/_annotator_pyx.pyx":235
 
1931
 *                 PyList_SetItem(annotations, ann_idx, last_res)
 
1932
 *             else:
 
1933
 *                 new_ann = _combine_annotations(ann, par_ann, ann_cache)             # <<<<<<<<<<<<<<
 
1934
 *                 Py_INCREF(new_ann)
 
1935
 *                 PyList_SetItem(annotations, ann_idx, new_ann)
 
1936
 */
 
1937
        __pyx_t_4 = __pyx_f_6bzrlib_14_annotator_pyx__combine_annotations(__pyx_v_ann, __pyx_v_par_ann, __pyx_v_ann_cache); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1938
        __Pyx_GOTREF(__pyx_t_4);
 
1939
        __Pyx_DECREF(__pyx_v_new_ann);
 
1940
        __pyx_v_new_ann = __pyx_t_4;
 
1941
        __pyx_t_4 = 0;
 
1942
 
 
1943
        /* "bzrlib/_annotator_pyx.pyx":236
 
1944
 *             else:
 
1945
 *                 new_ann = _combine_annotations(ann, par_ann, ann_cache)
 
1946
 *                 Py_INCREF(new_ann)             # <<<<<<<<<<<<<<
 
1947
 *                 PyList_SetItem(annotations, ann_idx, new_ann)
 
1948
 *                 last_ann = ann
 
1949
 */
 
1950
        Py_INCREF(__pyx_v_new_ann);
 
1951
 
 
1952
        /* "bzrlib/_annotator_pyx.pyx":237
 
1953
 *                 new_ann = _combine_annotations(ann, par_ann, ann_cache)
 
1954
 *                 Py_INCREF(new_ann)
 
1955
 *                 PyList_SetItem(annotations, ann_idx, new_ann)             # <<<<<<<<<<<<<<
 
1956
 *                 last_ann = ann
 
1957
 *                 last_parent = par_ann
 
1958
 */
 
1959
        __pyx_t_1 = PyList_SetItem(__pyx_v_annotations, __pyx_v_ann_idx, __pyx_v_new_ann); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1960
 
 
1961
        /* "bzrlib/_annotator_pyx.pyx":238
 
1962
 *                 Py_INCREF(new_ann)
 
1963
 *                 PyList_SetItem(annotations, ann_idx, new_ann)
 
1964
 *                 last_ann = ann             # <<<<<<<<<<<<<<
 
1965
 *                 last_parent = par_ann
 
1966
 *                 last_res = new_ann
 
1967
 */
 
1968
        __Pyx_INCREF(__pyx_v_ann);
 
1969
        __Pyx_DECREF(__pyx_v_last_ann);
 
1970
        __pyx_v_last_ann = __pyx_v_ann;
 
1971
 
 
1972
        /* "bzrlib/_annotator_pyx.pyx":239
 
1973
 *                 PyList_SetItem(annotations, ann_idx, new_ann)
 
1974
 *                 last_ann = ann
 
1975
 *                 last_parent = par_ann             # <<<<<<<<<<<<<<
 
1976
 *                 last_res = new_ann
 
1977
 *     return 0
 
1978
 */
 
1979
        __Pyx_INCREF(__pyx_v_par_ann);
 
1980
        __Pyx_DECREF(__pyx_v_last_parent);
 
1981
        __pyx_v_last_parent = __pyx_v_par_ann;
 
1982
 
 
1983
        /* "bzrlib/_annotator_pyx.pyx":240
 
1984
 *                 last_ann = ann
 
1985
 *                 last_parent = par_ann
 
1986
 *                 last_res = new_ann             # <<<<<<<<<<<<<<
 
1987
 *     return 0
 
1988
 * 
 
1989
 */
 
1990
        __Pyx_INCREF(__pyx_v_new_ann);
 
1991
        __Pyx_DECREF(__pyx_v_last_res);
 
1992
        __pyx_v_last_res = __pyx_v_new_ann;
 
1993
      }
 
1994
      __pyx_L9:;
 
1995
      __pyx_L5_continue:;
 
1996
    }
 
1997
  }
 
1998
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
1999
 
 
2000
  /* "bzrlib/_annotator_pyx.pyx":241
 
2001
 *                 last_parent = par_ann
 
2002
 *                 last_res = new_ann
 
2003
 *     return 0             # <<<<<<<<<<<<<<
 
2004
 * 
 
2005
 * 
 
2006
 */
 
2007
  __pyx_r = 0;
 
2008
  goto __pyx_L0;
 
2009
 
 
2010
  __pyx_r = 0;
 
2011
  goto __pyx_L0;
 
2012
  __pyx_L1_error:;
 
2013
  __Pyx_XDECREF(__pyx_t_3);
 
2014
  __Pyx_XDECREF(__pyx_t_4);
 
2015
  __Pyx_XDECREF(__pyx_t_5);
 
2016
  __Pyx_XDECREF(__pyx_t_6);
 
2017
  __Pyx_XDECREF(__pyx_t_7);
 
2018
  __Pyx_XDECREF(__pyx_t_11);
 
2019
  __Pyx_AddTraceback("bzrlib._annotator_pyx._merge_annotations");
 
2020
  __pyx_r = -1;
 
2021
  __pyx_L0:;
 
2022
  __Pyx_DECREF(__pyx_v_last_ann);
 
2023
  __Pyx_DECREF(__pyx_v_last_parent);
 
2024
  __Pyx_DECREF(__pyx_v_last_res);
 
2025
  __Pyx_DECREF(__pyx_v_par_ann);
 
2026
  __Pyx_DECREF(__pyx_v_ann);
 
2027
  __Pyx_DECREF(__pyx_v_new_ann);
 
2028
  __Pyx_RefNannyFinishContext();
 
2029
  return __pyx_r;
 
2030
}
 
2031
 
 
2032
/* "bzrlib/_annotator_pyx.pyx":247
 
2033
 *     """Class that drives performing annotations."""
 
2034
 * 
 
2035
 *     def _update_from_first_parent(self, key, annotations, lines, parent_key):             # <<<<<<<<<<<<<<
 
2036
 *         """Reannotate this text relative to its first parent."""
 
2037
 *         (parent_annotations,
 
2038
 */
 
2039
 
 
2040
static PyObject *__pyx_pf_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
2041
static char __pyx_doc_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent[] = "Reannotate this text relative to its first parent.";
 
2042
static PyMethodDef __pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent = {__Pyx_NAMESTR("_update_from_first_parent"), (PyCFunction)__pyx_pf_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent)};
 
2043
static PyObject *__pyx_pf_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
2044
  PyObject *__pyx_v_self = 0;
 
2045
  PyObject *__pyx_v_key = 0;
 
2046
  PyObject *__pyx_v_annotations = 0;
 
2047
  PyObject *__pyx_v_lines = 0;
 
2048
  PyObject *__pyx_v_parent_key = 0;
 
2049
  PyObject *__pyx_v_parent_annotations;
 
2050
  PyObject *__pyx_v_matching_blocks;
 
2051
  PyObject *__pyx_r = NULL;
 
2052
  PyObject *__pyx_t_1 = NULL;
 
2053
  PyObject *__pyx_t_2 = NULL;
 
2054
  PyObject *__pyx_t_3 = NULL;
 
2055
  PyObject *__pyx_t_4 = NULL;
 
2056
  int __pyx_t_5;
 
2057
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__key,&__pyx_n_s__annotations,&__pyx_n_s__lines,&__pyx_n_s__parent_key,0};
 
2058
  __Pyx_RefNannySetupContext("_update_from_first_parent");
 
2059
  __pyx_self = __pyx_self;
 
2060
  if (unlikely(__pyx_kwds)) {
 
2061
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
2062
    PyObject* values[5] = {0,0,0,0,0};
 
2063
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
2064
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
 
2065
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
 
2066
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
 
2067
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
 
2068
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
2069
      case  0: break;
 
2070
      default: goto __pyx_L5_argtuple_error;
 
2071
    }
 
2072
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
2073
      case  0:
 
2074
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
 
2075
      if (likely(values[0])) kw_args--;
 
2076
      else goto __pyx_L5_argtuple_error;
 
2077
      case  1:
 
2078
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
 
2079
      if (likely(values[1])) kw_args--;
 
2080
      else {
 
2081
        __Pyx_RaiseArgtupleInvalid("_update_from_first_parent", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2082
      }
 
2083
      case  2:
 
2084
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations);
 
2085
      if (likely(values[2])) kw_args--;
 
2086
      else {
 
2087
        __Pyx_RaiseArgtupleInvalid("_update_from_first_parent", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2088
      }
 
2089
      case  3:
 
2090
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lines);
 
2091
      if (likely(values[3])) kw_args--;
 
2092
      else {
 
2093
        __Pyx_RaiseArgtupleInvalid("_update_from_first_parent", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2094
      }
 
2095
      case  4:
 
2096
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parent_key);
 
2097
      if (likely(values[4])) kw_args--;
 
2098
      else {
 
2099
        __Pyx_RaiseArgtupleInvalid("_update_from_first_parent", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2100
      }
 
2101
    }
 
2102
    if (unlikely(kw_args > 0)) {
 
2103
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_update_from_first_parent") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2104
    }
 
2105
    __pyx_v_self = values[0];
 
2106
    __pyx_v_key = values[1];
 
2107
    __pyx_v_annotations = values[2];
 
2108
    __pyx_v_lines = values[3];
 
2109
    __pyx_v_parent_key = values[4];
 
2110
  } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
 
2111
    goto __pyx_L5_argtuple_error;
 
2112
  } else {
 
2113
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
 
2114
    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 1);
 
2115
    __pyx_v_annotations = PyTuple_GET_ITEM(__pyx_args, 2);
 
2116
    __pyx_v_lines = PyTuple_GET_ITEM(__pyx_args, 3);
 
2117
    __pyx_v_parent_key = PyTuple_GET_ITEM(__pyx_args, 4);
 
2118
  }
 
2119
  goto __pyx_L4_argument_unpacking_done;
 
2120
  __pyx_L5_argtuple_error:;
 
2121
  __Pyx_RaiseArgtupleInvalid("_update_from_first_parent", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2122
  __pyx_L3_error:;
 
2123
  __Pyx_AddTraceback("bzrlib._annotator_pyx.Annotator._update_from_first_parent");
 
2124
  __Pyx_RefNannyFinishContext();
 
2125
  return NULL;
 
2126
  __pyx_L4_argument_unpacking_done:;
 
2127
  __pyx_v_parent_annotations = Py_None; __Pyx_INCREF(Py_None);
 
2128
  __pyx_v_matching_blocks = Py_None; __Pyx_INCREF(Py_None);
 
2129
 
 
2130
  /* "bzrlib/_annotator_pyx.pyx":250
 
2131
 *         """Reannotate this text relative to its first parent."""
 
2132
 *         (parent_annotations,
 
2133
 *          matching_blocks) = self._get_parent_annotations_and_matches(             # <<<<<<<<<<<<<<
 
2134
 *                                 key, lines, parent_key)
 
2135
 * 
 
2136
 */
 
2137
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2138
  __Pyx_GOTREF(__pyx_t_1);
 
2139
 
 
2140
  /* "bzrlib/_annotator_pyx.pyx":251
 
2141
 *         (parent_annotations,
 
2142
 *          matching_blocks) = self._get_parent_annotations_and_matches(
 
2143
 *                                 key, lines, parent_key)             # <<<<<<<<<<<<<<
 
2144
 * 
 
2145
 *         _apply_parent_annotations(annotations, parent_annotations,
 
2146
 */
 
2147
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2148
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
2149
  __Pyx_INCREF(__pyx_v_key);
 
2150
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
 
2151
  __Pyx_GIVEREF(__pyx_v_key);
 
2152
  __Pyx_INCREF(__pyx_v_lines);
 
2153
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_lines);
 
2154
  __Pyx_GIVEREF(__pyx_v_lines);
 
2155
  __Pyx_INCREF(__pyx_v_parent_key);
 
2156
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_parent_key);
 
2157
  __Pyx_GIVEREF(__pyx_v_parent_key);
 
2158
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2159
  __Pyx_GOTREF(__pyx_t_3);
 
2160
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
2161
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
2162
  if (PyTuple_CheckExact(__pyx_t_3) && likely(PyTuple_GET_SIZE(__pyx_t_3) == 2)) {
 
2163
    PyObject* tuple = __pyx_t_3;
 
2164
    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
 
2165
    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
 
2166
 
 
2167
    /* "bzrlib/_annotator_pyx.pyx":249
 
2168
 *     def _update_from_first_parent(self, key, annotations, lines, parent_key):
 
2169
 *         """Reannotate this text relative to its first parent."""
 
2170
 *         (parent_annotations,             # <<<<<<<<<<<<<<
 
2171
 *          matching_blocks) = self._get_parent_annotations_and_matches(
 
2172
 *                                 key, lines, parent_key)
 
2173
 */
 
2174
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
2175
    __Pyx_DECREF(__pyx_v_parent_annotations);
 
2176
    __pyx_v_parent_annotations = __pyx_t_2;
 
2177
    __pyx_t_2 = 0;
 
2178
    __Pyx_DECREF(__pyx_v_matching_blocks);
 
2179
    __pyx_v_matching_blocks = __pyx_t_1;
 
2180
    __pyx_t_1 = 0;
 
2181
  } else {
 
2182
    __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2183
    __Pyx_GOTREF(__pyx_t_4);
 
2184
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
2185
    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_4, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2186
    __Pyx_GOTREF(__pyx_t_2);
 
2187
    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_4, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2188
    __Pyx_GOTREF(__pyx_t_1);
 
2189
    if (__Pyx_EndUnpack(__pyx_t_4, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2190
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
2191
    __Pyx_DECREF(__pyx_v_parent_annotations);
 
2192
    __pyx_v_parent_annotations = __pyx_t_2;
 
2193
    __pyx_t_2 = 0;
 
2194
    __Pyx_DECREF(__pyx_v_matching_blocks);
 
2195
    __pyx_v_matching_blocks = __pyx_t_1;
 
2196
    __pyx_t_1 = 0;
 
2197
  }
 
2198
 
 
2199
  /* "bzrlib/_annotator_pyx.pyx":254
 
2200
 * 
 
2201
 *         _apply_parent_annotations(annotations, parent_annotations,
 
2202
 *                                   matching_blocks)             # <<<<<<<<<<<<<<
 
2203
 * 
 
2204
 *     def _update_from_other_parents(self, key, annotations, lines,
 
2205
 */
 
2206
  __pyx_t_5 = __pyx_f_6bzrlib_14_annotator_pyx__apply_parent_annotations(__pyx_v_annotations, __pyx_v_parent_annotations, __pyx_v_matching_blocks); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2207
 
 
2208
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2209
  goto __pyx_L0;
 
2210
  __pyx_L1_error:;
 
2211
  __Pyx_XDECREF(__pyx_t_1);
 
2212
  __Pyx_XDECREF(__pyx_t_2);
 
2213
  __Pyx_XDECREF(__pyx_t_3);
 
2214
  __Pyx_XDECREF(__pyx_t_4);
 
2215
  __Pyx_AddTraceback("bzrlib._annotator_pyx.Annotator._update_from_first_parent");
 
2216
  __pyx_r = NULL;
 
2217
  __pyx_L0:;
 
2218
  __Pyx_DECREF(__pyx_v_parent_annotations);
 
2219
  __Pyx_DECREF(__pyx_v_matching_blocks);
 
2220
  __Pyx_XGIVEREF(__pyx_r);
 
2221
  __Pyx_RefNannyFinishContext();
 
2222
  return __pyx_r;
 
2223
}
 
2224
 
 
2225
/* "bzrlib/_annotator_pyx.pyx":256
 
2226
 *                                   matching_blocks)
 
2227
 * 
 
2228
 *     def _update_from_other_parents(self, key, annotations, lines,             # <<<<<<<<<<<<<<
 
2229
 *                                    this_annotation, parent_key):
 
2230
 *         """Reannotate this text relative to a second (or more) parent."""
 
2231
 */
 
2232
 
 
2233
static PyObject *__pyx_pf_6bzrlib_14_annotator_pyx_9Annotator_1_update_from_other_parents(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
2234
static char __pyx_doc_6bzrlib_14_annotator_pyx_9Annotator_1_update_from_other_parents[] = "Reannotate this text relative to a second (or more) parent.";
 
2235
static PyMethodDef __pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator_1_update_from_other_parents = {__Pyx_NAMESTR("_update_from_other_parents"), (PyCFunction)__pyx_pf_6bzrlib_14_annotator_pyx_9Annotator_1_update_from_other_parents, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6bzrlib_14_annotator_pyx_9Annotator_1_update_from_other_parents)};
 
2236
static PyObject *__pyx_pf_6bzrlib_14_annotator_pyx_9Annotator_1_update_from_other_parents(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
2237
  PyObject *__pyx_v_self = 0;
 
2238
  PyObject *__pyx_v_key = 0;
 
2239
  PyObject *__pyx_v_annotations = 0;
 
2240
  PyObject *__pyx_v_lines = 0;
 
2241
  PyObject *__pyx_v_this_annotation = 0;
 
2242
  PyObject *__pyx_v_parent_key = 0;
 
2243
  PyObject *__pyx_v_parent_annotations;
 
2244
  PyObject *__pyx_v_matching_blocks;
 
2245
  PyObject *__pyx_r = NULL;
 
2246
  PyObject *__pyx_t_1 = NULL;
 
2247
  PyObject *__pyx_t_2 = NULL;
 
2248
  PyObject *__pyx_t_3 = NULL;
 
2249
  PyObject *__pyx_t_4 = NULL;
 
2250
  int __pyx_t_5;
 
2251
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__key,&__pyx_n_s__annotations,&__pyx_n_s__lines,&__pyx_n_s__this_annotation,&__pyx_n_s__parent_key,0};
 
2252
  __Pyx_RefNannySetupContext("_update_from_other_parents");
 
2253
  __pyx_self = __pyx_self;
 
2254
  if (unlikely(__pyx_kwds)) {
 
2255
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
2256
    PyObject* values[6] = {0,0,0,0,0,0};
 
2257
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
2258
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
 
2259
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
 
2260
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
 
2261
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
 
2262
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
 
2263
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
2264
      case  0: break;
 
2265
      default: goto __pyx_L5_argtuple_error;
 
2266
    }
 
2267
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
2268
      case  0:
 
2269
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
 
2270
      if (likely(values[0])) kw_args--;
 
2271
      else goto __pyx_L5_argtuple_error;
 
2272
      case  1:
 
2273
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
 
2274
      if (likely(values[1])) kw_args--;
 
2275
      else {
 
2276
        __Pyx_RaiseArgtupleInvalid("_update_from_other_parents", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2277
      }
 
2278
      case  2:
 
2279
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations);
 
2280
      if (likely(values[2])) kw_args--;
 
2281
      else {
 
2282
        __Pyx_RaiseArgtupleInvalid("_update_from_other_parents", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2283
      }
 
2284
      case  3:
 
2285
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lines);
 
2286
      if (likely(values[3])) kw_args--;
 
2287
      else {
 
2288
        __Pyx_RaiseArgtupleInvalid("_update_from_other_parents", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2289
      }
 
2290
      case  4:
 
2291
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__this_annotation);
 
2292
      if (likely(values[4])) kw_args--;
 
2293
      else {
 
2294
        __Pyx_RaiseArgtupleInvalid("_update_from_other_parents", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2295
      }
 
2296
      case  5:
 
2297
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parent_key);
 
2298
      if (likely(values[5])) kw_args--;
 
2299
      else {
 
2300
        __Pyx_RaiseArgtupleInvalid("_update_from_other_parents", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2301
      }
 
2302
    }
 
2303
    if (unlikely(kw_args > 0)) {
 
2304
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_update_from_other_parents") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2305
    }
 
2306
    __pyx_v_self = values[0];
 
2307
    __pyx_v_key = values[1];
 
2308
    __pyx_v_annotations = values[2];
 
2309
    __pyx_v_lines = values[3];
 
2310
    __pyx_v_this_annotation = values[4];
 
2311
    __pyx_v_parent_key = values[5];
 
2312
  } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
 
2313
    goto __pyx_L5_argtuple_error;
 
2314
  } else {
 
2315
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
 
2316
    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 1);
 
2317
    __pyx_v_annotations = PyTuple_GET_ITEM(__pyx_args, 2);
 
2318
    __pyx_v_lines = PyTuple_GET_ITEM(__pyx_args, 3);
 
2319
    __pyx_v_this_annotation = PyTuple_GET_ITEM(__pyx_args, 4);
 
2320
    __pyx_v_parent_key = PyTuple_GET_ITEM(__pyx_args, 5);
 
2321
  }
 
2322
  goto __pyx_L4_argument_unpacking_done;
 
2323
  __pyx_L5_argtuple_error:;
 
2324
  __Pyx_RaiseArgtupleInvalid("_update_from_other_parents", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2325
  __pyx_L3_error:;
 
2326
  __Pyx_AddTraceback("bzrlib._annotator_pyx.Annotator._update_from_other_parents");
 
2327
  __Pyx_RefNannyFinishContext();
 
2328
  return NULL;
 
2329
  __pyx_L4_argument_unpacking_done:;
 
2330
  __pyx_v_parent_annotations = Py_None; __Pyx_INCREF(Py_None);
 
2331
  __pyx_v_matching_blocks = Py_None; __Pyx_INCREF(Py_None);
 
2332
 
 
2333
  /* "bzrlib/_annotator_pyx.pyx":260
 
2334
 *         """Reannotate this text relative to a second (or more) parent."""
 
2335
 *         (parent_annotations,
 
2336
 *          matching_blocks) = self._get_parent_annotations_and_matches(             # <<<<<<<<<<<<<<
 
2337
 *                                 key, lines, parent_key)
 
2338
 *         _merge_annotations(this_annotation, annotations, parent_annotations,
 
2339
 */
 
2340
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2341
  __Pyx_GOTREF(__pyx_t_1);
 
2342
 
 
2343
  /* "bzrlib/_annotator_pyx.pyx":261
 
2344
 *         (parent_annotations,
 
2345
 *          matching_blocks) = self._get_parent_annotations_and_matches(
 
2346
 *                                 key, lines, parent_key)             # <<<<<<<<<<<<<<
 
2347
 *         _merge_annotations(this_annotation, annotations, parent_annotations,
 
2348
 *                            matching_blocks, self._ann_tuple_cache)
 
2349
 */
 
2350
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2351
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
2352
  __Pyx_INCREF(__pyx_v_key);
 
2353
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
 
2354
  __Pyx_GIVEREF(__pyx_v_key);
 
2355
  __Pyx_INCREF(__pyx_v_lines);
 
2356
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_lines);
 
2357
  __Pyx_GIVEREF(__pyx_v_lines);
 
2358
  __Pyx_INCREF(__pyx_v_parent_key);
 
2359
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_parent_key);
 
2360
  __Pyx_GIVEREF(__pyx_v_parent_key);
 
2361
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2362
  __Pyx_GOTREF(__pyx_t_3);
 
2363
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
2364
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
2365
  if (PyTuple_CheckExact(__pyx_t_3) && likely(PyTuple_GET_SIZE(__pyx_t_3) == 2)) {
 
2366
    PyObject* tuple = __pyx_t_3;
 
2367
    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
 
2368
    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
 
2369
 
 
2370
    /* "bzrlib/_annotator_pyx.pyx":259
 
2371
 *                                    this_annotation, parent_key):
 
2372
 *         """Reannotate this text relative to a second (or more) parent."""
 
2373
 *         (parent_annotations,             # <<<<<<<<<<<<<<
 
2374
 *          matching_blocks) = self._get_parent_annotations_and_matches(
 
2375
 *                                 key, lines, parent_key)
 
2376
 */
 
2377
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
2378
    __Pyx_DECREF(__pyx_v_parent_annotations);
 
2379
    __pyx_v_parent_annotations = __pyx_t_2;
 
2380
    __pyx_t_2 = 0;
 
2381
    __Pyx_DECREF(__pyx_v_matching_blocks);
 
2382
    __pyx_v_matching_blocks = __pyx_t_1;
 
2383
    __pyx_t_1 = 0;
 
2384
  } else {
 
2385
    __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2386
    __Pyx_GOTREF(__pyx_t_4);
 
2387
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
2388
    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_4, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2389
    __Pyx_GOTREF(__pyx_t_2);
 
2390
    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_4, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2391
    __Pyx_GOTREF(__pyx_t_1);
 
2392
    if (__Pyx_EndUnpack(__pyx_t_4, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2393
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
2394
    __Pyx_DECREF(__pyx_v_parent_annotations);
 
2395
    __pyx_v_parent_annotations = __pyx_t_2;
 
2396
    __pyx_t_2 = 0;
 
2397
    __Pyx_DECREF(__pyx_v_matching_blocks);
 
2398
    __pyx_v_matching_blocks = __pyx_t_1;
 
2399
    __pyx_t_1 = 0;
 
2400
  }
 
2401
 
 
2402
  /* "bzrlib/_annotator_pyx.pyx":263
 
2403
 *                                 key, lines, parent_key)
 
2404
 *         _merge_annotations(this_annotation, annotations, parent_annotations,
 
2405
 *                            matching_blocks, self._ann_tuple_cache)             # <<<<<<<<<<<<<<
 
2406
 * 
 
2407
 *     def annotate_flat(self, key):
 
2408
 */
 
2409
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___ann_tuple_cache); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2410
  __Pyx_GOTREF(__pyx_t_3);
 
2411
  __pyx_t_5 = __pyx_f_6bzrlib_14_annotator_pyx__merge_annotations(__pyx_v_this_annotation, __pyx_v_annotations, __pyx_v_parent_annotations, __pyx_v_matching_blocks, __pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2412
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
2413
 
 
2414
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2415
  goto __pyx_L0;
 
2416
  __pyx_L1_error:;
 
2417
  __Pyx_XDECREF(__pyx_t_1);
 
2418
  __Pyx_XDECREF(__pyx_t_2);
 
2419
  __Pyx_XDECREF(__pyx_t_3);
 
2420
  __Pyx_XDECREF(__pyx_t_4);
 
2421
  __Pyx_AddTraceback("bzrlib._annotator_pyx.Annotator._update_from_other_parents");
 
2422
  __pyx_r = NULL;
 
2423
  __pyx_L0:;
 
2424
  __Pyx_DECREF(__pyx_v_parent_annotations);
 
2425
  __Pyx_DECREF(__pyx_v_matching_blocks);
 
2426
  __Pyx_XGIVEREF(__pyx_r);
 
2427
  __Pyx_RefNannyFinishContext();
 
2428
  return __pyx_r;
 
2429
}
 
2430
 
 
2431
/* "bzrlib/_annotator_pyx.pyx":265
 
2432
 *                            matching_blocks, self._ann_tuple_cache)
 
2433
 * 
 
2434
 *     def annotate_flat(self, key):             # <<<<<<<<<<<<<<
 
2435
 *         """Determine the single-best-revision to source for each line.
 
2436
 * 
 
2437
 */
 
2438
 
 
2439
static PyObject *__pyx_pf_6bzrlib_14_annotator_pyx_9Annotator_2annotate_flat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
2440
static char __pyx_doc_6bzrlib_14_annotator_pyx_9Annotator_2annotate_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        ";
 
2441
static PyMethodDef __pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator_2annotate_flat = {__Pyx_NAMESTR("annotate_flat"), (PyCFunction)__pyx_pf_6bzrlib_14_annotator_pyx_9Annotator_2annotate_flat, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6bzrlib_14_annotator_pyx_9Annotator_2annotate_flat)};
 
2442
static PyObject *__pyx_pf_6bzrlib_14_annotator_pyx_9Annotator_2annotate_flat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
2443
  PyObject *__pyx_v_self = 0;
 
2444
  PyObject *__pyx_v_key = 0;
 
2445
  Py_ssize_t __pyx_v_pos;
 
2446
  Py_ssize_t __pyx_v_num_lines;
 
2447
  PyObject *__pyx_v_annotate;
 
2448
  PyObject *__pyx_v_custom_tiebreaker;
 
2449
  PyObject *__pyx_v_annotations;
 
2450
  PyObject *__pyx_v_lines;
 
2451
  PyObject *__pyx_v_out;
 
2452
  PyObject *__pyx_v_heads;
 
2453
  PyObject *__pyx_v_annotation;
 
2454
  PyObject *__pyx_v_line;
 
2455
  PyObject *__pyx_v_head;
 
2456
  PyObject *__pyx_v_the_heads;
 
2457
  PyObject *__pyx_r = NULL;
 
2458
  PyObject *__pyx_t_1 = NULL;
 
2459
  PyObject *__pyx_t_2 = NULL;
 
2460
  PyObject *__pyx_t_3 = NULL;
 
2461
  PyObject *__pyx_t_4 = NULL;
 
2462
  Py_ssize_t __pyx_t_5;
 
2463
  Py_ssize_t __pyx_t_6;
 
2464
  int __pyx_t_7;
 
2465
  int __pyx_t_8;
 
2466
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__key,0};
 
2467
  __Pyx_RefNannySetupContext("annotate_flat");
 
2468
  __pyx_self = __pyx_self;
 
2469
  if (unlikely(__pyx_kwds)) {
 
2470
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
2471
    PyObject* values[2] = {0,0};
 
2472
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
2473
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
 
2474
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
2475
      case  0: break;
 
2476
      default: goto __pyx_L5_argtuple_error;
 
2477
    }
 
2478
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
2479
      case  0:
 
2480
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
 
2481
      if (likely(values[0])) kw_args--;
 
2482
      else goto __pyx_L5_argtuple_error;
 
2483
      case  1:
 
2484
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
 
2485
      if (likely(values[1])) kw_args--;
 
2486
      else {
 
2487
        __Pyx_RaiseArgtupleInvalid("annotate_flat", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2488
      }
 
2489
    }
 
2490
    if (unlikely(kw_args > 0)) {
 
2491
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "annotate_flat") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2492
    }
 
2493
    __pyx_v_self = values[0];
 
2494
    __pyx_v_key = values[1];
 
2495
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
 
2496
    goto __pyx_L5_argtuple_error;
 
2497
  } else {
 
2498
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
 
2499
    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 1);
 
2500
  }
 
2501
  goto __pyx_L4_argument_unpacking_done;
 
2502
  __pyx_L5_argtuple_error:;
 
2503
  __Pyx_RaiseArgtupleInvalid("annotate_flat", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2504
  __pyx_L3_error:;
 
2505
  __Pyx_AddTraceback("bzrlib._annotator_pyx.Annotator.annotate_flat");
 
2506
  __Pyx_RefNannyFinishContext();
 
2507
  return NULL;
 
2508
  __pyx_L4_argument_unpacking_done:;
 
2509
  __pyx_v_annotate = Py_None; __Pyx_INCREF(Py_None);
 
2510
  __pyx_v_custom_tiebreaker = Py_None; __Pyx_INCREF(Py_None);
 
2511
  __pyx_v_annotations = Py_None; __Pyx_INCREF(Py_None);
 
2512
  __pyx_v_lines = Py_None; __Pyx_INCREF(Py_None);
 
2513
  __pyx_v_out = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
2514
  __pyx_v_heads = Py_None; __Pyx_INCREF(Py_None);
 
2515
  __pyx_v_annotation = Py_None; __Pyx_INCREF(Py_None);
 
2516
  __pyx_v_line = Py_None; __Pyx_INCREF(Py_None);
 
2517
  __pyx_v_head = Py_None; __Pyx_INCREF(Py_None);
 
2518
  __pyx_v_the_heads = Py_None; __Pyx_INCREF(Py_None);
 
2519
 
 
2520
  /* "bzrlib/_annotator_pyx.pyx":272
 
2521
 *         cdef Py_ssize_t pos, num_lines
 
2522
 * 
 
2523
 *         from bzrlib import annotate             # <<<<<<<<<<<<<<
 
2524
 * 
 
2525
 *         custom_tiebreaker = annotate._break_annotation_tie
 
2526
 */
 
2527
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2528
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
2529
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotate));
 
2530
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__annotate));
 
2531
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotate));
 
2532
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__bzrlib), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2533
  __Pyx_GOTREF(__pyx_t_2);
 
2534
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
2535
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__annotate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2536
  __Pyx_GOTREF(__pyx_t_1);
 
2537
  __Pyx_INCREF(__pyx_t_1);
 
2538
  __Pyx_DECREF(__pyx_v_annotate);
 
2539
  __pyx_v_annotate = __pyx_t_1;
 
2540
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
2541
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
2542
 
 
2543
  /* "bzrlib/_annotator_pyx.pyx":274
 
2544
 *         from bzrlib import annotate
 
2545
 * 
 
2546
 *         custom_tiebreaker = annotate._break_annotation_tie             # <<<<<<<<<<<<<<
 
2547
 *         annotations, lines = self.annotate(key)
 
2548
 *         num_lines = len(lines)
 
2549
 */
 
2550
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_annotate, __pyx_n_s_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2551
  __Pyx_GOTREF(__pyx_t_2);
 
2552
  __Pyx_DECREF(__pyx_v_custom_tiebreaker);
 
2553
  __pyx_v_custom_tiebreaker = __pyx_t_2;
 
2554
  __pyx_t_2 = 0;
 
2555
 
 
2556
  /* "bzrlib/_annotator_pyx.pyx":275
 
2557
 * 
 
2558
 *         custom_tiebreaker = annotate._break_annotation_tie
 
2559
 *         annotations, lines = self.annotate(key)             # <<<<<<<<<<<<<<
 
2560
 *         num_lines = len(lines)
 
2561
 *         out = []
 
2562
 */
 
2563
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__annotate); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2564
  __Pyx_GOTREF(__pyx_t_2);
 
2565
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2566
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
2567
  __Pyx_INCREF(__pyx_v_key);
 
2568
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_key);
 
2569
  __Pyx_GIVEREF(__pyx_v_key);
 
2570
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2571
  __Pyx_GOTREF(__pyx_t_3);
 
2572
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
2573
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
2574
  if (PyTuple_CheckExact(__pyx_t_3) && likely(PyTuple_GET_SIZE(__pyx_t_3) == 2)) {
 
2575
    PyObject* tuple = __pyx_t_3;
 
2576
    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
 
2577
    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_2);
 
2578
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
2579
    __Pyx_DECREF(__pyx_v_annotations);
 
2580
    __pyx_v_annotations = __pyx_t_1;
 
2581
    __pyx_t_1 = 0;
 
2582
    __Pyx_DECREF(__pyx_v_lines);
 
2583
    __pyx_v_lines = __pyx_t_2;
 
2584
    __pyx_t_2 = 0;
 
2585
  } else {
 
2586
    __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2587
    __Pyx_GOTREF(__pyx_t_4);
 
2588
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
2589
    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_4, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2590
    __Pyx_GOTREF(__pyx_t_1);
 
2591
    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_4, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2592
    __Pyx_GOTREF(__pyx_t_2);
 
2593
    if (__Pyx_EndUnpack(__pyx_t_4, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2594
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
2595
    __Pyx_DECREF(__pyx_v_annotations);
 
2596
    __pyx_v_annotations = __pyx_t_1;
 
2597
    __pyx_t_1 = 0;
 
2598
    __Pyx_DECREF(__pyx_v_lines);
 
2599
    __pyx_v_lines = __pyx_t_2;
 
2600
    __pyx_t_2 = 0;
 
2601
  }
 
2602
 
 
2603
  /* "bzrlib/_annotator_pyx.pyx":276
 
2604
 *         custom_tiebreaker = annotate._break_annotation_tie
 
2605
 *         annotations, lines = self.annotate(key)
 
2606
 *         num_lines = len(lines)             # <<<<<<<<<<<<<<
 
2607
 *         out = []
 
2608
 *         heads = self._get_heads_provider().heads
 
2609
 */
 
2610
  __pyx_t_5 = PyObject_Length(__pyx_v_lines); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2611
  __pyx_v_num_lines = __pyx_t_5;
 
2612
 
 
2613
  /* "bzrlib/_annotator_pyx.pyx":277
 
2614
 *         annotations, lines = self.annotate(key)
 
2615
 *         num_lines = len(lines)
 
2616
 *         out = []             # <<<<<<<<<<<<<<
 
2617
 *         heads = self._get_heads_provider().heads
 
2618
 *         for pos from 0 <= pos < num_lines:
 
2619
 */
 
2620
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2621
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
2622
  __Pyx_DECREF(((PyObject *)__pyx_v_out));
 
2623
  __pyx_v_out = __pyx_t_3;
 
2624
  __pyx_t_3 = 0;
 
2625
 
 
2626
  /* "bzrlib/_annotator_pyx.pyx":278
 
2627
 *         num_lines = len(lines)
 
2628
 *         out = []
 
2629
 *         heads = self._get_heads_provider().heads             # <<<<<<<<<<<<<<
 
2630
 *         for pos from 0 <= pos < num_lines:
 
2631
 *             annotation = annotations[pos]
 
2632
 */
 
2633
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___get_heads_provider); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2634
  __Pyx_GOTREF(__pyx_t_3);
 
2635
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2636
  __Pyx_GOTREF(__pyx_t_2);
 
2637
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
2638
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__heads); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2639
  __Pyx_GOTREF(__pyx_t_3);
 
2640
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
2641
  __Pyx_DECREF(__pyx_v_heads);
 
2642
  __pyx_v_heads = __pyx_t_3;
 
2643
  __pyx_t_3 = 0;
 
2644
 
 
2645
  /* "bzrlib/_annotator_pyx.pyx":279
 
2646
 *         out = []
 
2647
 *         heads = self._get_heads_provider().heads
 
2648
 *         for pos from 0 <= pos < num_lines:             # <<<<<<<<<<<<<<
 
2649
 *             annotation = annotations[pos]
 
2650
 *             line = lines[pos]
 
2651
 */
 
2652
  __pyx_t_5 = __pyx_v_num_lines;
 
2653
  for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_5; __pyx_v_pos++) {
 
2654
 
 
2655
    /* "bzrlib/_annotator_pyx.pyx":280
 
2656
 *         heads = self._get_heads_provider().heads
 
2657
 *         for pos from 0 <= pos < num_lines:
 
2658
 *             annotation = annotations[pos]             # <<<<<<<<<<<<<<
 
2659
 *             line = lines[pos]
 
2660
 *             if len(annotation) == 1:
 
2661
 */
 
2662
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_annotations, __pyx_v_pos, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2663
    __Pyx_GOTREF(__pyx_t_3);
 
2664
    __Pyx_DECREF(__pyx_v_annotation);
 
2665
    __pyx_v_annotation = __pyx_t_3;
 
2666
    __pyx_t_3 = 0;
 
2667
 
 
2668
    /* "bzrlib/_annotator_pyx.pyx":281
 
2669
 *         for pos from 0 <= pos < num_lines:
 
2670
 *             annotation = annotations[pos]
 
2671
 *             line = lines[pos]             # <<<<<<<<<<<<<<
 
2672
 *             if len(annotation) == 1:
 
2673
 *                 head = annotation[0]
 
2674
 */
 
2675
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_lines, __pyx_v_pos, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2676
    __Pyx_GOTREF(__pyx_t_3);
 
2677
    __Pyx_DECREF(__pyx_v_line);
 
2678
    __pyx_v_line = __pyx_t_3;
 
2679
    __pyx_t_3 = 0;
 
2680
 
 
2681
    /* "bzrlib/_annotator_pyx.pyx":282
 
2682
 *             annotation = annotations[pos]
 
2683
 *             line = lines[pos]
 
2684
 *             if len(annotation) == 1:             # <<<<<<<<<<<<<<
 
2685
 *                 head = annotation[0]
 
2686
 *             else:
 
2687
 */
 
2688
    __pyx_t_6 = PyObject_Length(__pyx_v_annotation); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2689
    __pyx_t_7 = (__pyx_t_6 == 1);
 
2690
    if (__pyx_t_7) {
 
2691
 
 
2692
      /* "bzrlib/_annotator_pyx.pyx":283
 
2693
 *             line = lines[pos]
 
2694
 *             if len(annotation) == 1:
 
2695
 *                 head = annotation[0]             # <<<<<<<<<<<<<<
 
2696
 *             else:
 
2697
 *                 the_heads = heads(annotation)
 
2698
 */
 
2699
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_annotation, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2700
      __Pyx_GOTREF(__pyx_t_3);
 
2701
      __Pyx_DECREF(__pyx_v_head);
 
2702
      __pyx_v_head = __pyx_t_3;
 
2703
      __pyx_t_3 = 0;
 
2704
      goto __pyx_L8;
 
2705
    }
 
2706
    /*else*/ {
 
2707
 
 
2708
      /* "bzrlib/_annotator_pyx.pyx":285
 
2709
 *                 head = annotation[0]
 
2710
 *             else:
 
2711
 *                 the_heads = heads(annotation)             # <<<<<<<<<<<<<<
 
2712
 *                 if len(the_heads) == 1:
 
2713
 *                     for head in the_heads: break # get the item out of the set
 
2714
 */
 
2715
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2716
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
2717
      __Pyx_INCREF(__pyx_v_annotation);
 
2718
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_annotation);
 
2719
      __Pyx_GIVEREF(__pyx_v_annotation);
 
2720
      __pyx_t_2 = PyObject_Call(__pyx_v_heads, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2721
      __Pyx_GOTREF(__pyx_t_2);
 
2722
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
2723
      __Pyx_DECREF(__pyx_v_the_heads);
 
2724
      __pyx_v_the_heads = __pyx_t_2;
 
2725
      __pyx_t_2 = 0;
 
2726
 
 
2727
      /* "bzrlib/_annotator_pyx.pyx":286
 
2728
 *             else:
 
2729
 *                 the_heads = heads(annotation)
 
2730
 *                 if len(the_heads) == 1:             # <<<<<<<<<<<<<<
 
2731
 *                     for head in the_heads: break # get the item out of the set
 
2732
 *                 else:
 
2733
 */
 
2734
      __pyx_t_6 = PyObject_Length(__pyx_v_the_heads); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2735
      __pyx_t_7 = (__pyx_t_6 == 1);
 
2736
      if (__pyx_t_7) {
 
2737
 
 
2738
        /* "bzrlib/_annotator_pyx.pyx":287
 
2739
 *                 the_heads = heads(annotation)
 
2740
 *                 if len(the_heads) == 1:
 
2741
 *                     for head in the_heads: break # get the item out of the set             # <<<<<<<<<<<<<<
 
2742
 *                 else:
 
2743
 *                     # We need to resolve the ambiguity, for now just pick the
 
2744
 */
 
2745
        if (PyList_CheckExact(__pyx_v_the_heads) || PyTuple_CheckExact(__pyx_v_the_heads)) {
 
2746
          __pyx_t_6 = 0; __pyx_t_2 = __pyx_v_the_heads; __Pyx_INCREF(__pyx_t_2);
 
2747
        } else {
 
2748
          __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_the_heads); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2749
          __Pyx_GOTREF(__pyx_t_2);
 
2750
        }
 
2751
        for (;;) {
 
2752
          if (likely(PyList_CheckExact(__pyx_t_2))) {
 
2753
            if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
 
2754
            __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++;
 
2755
          } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
 
2756
            if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
 
2757
            __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++;
 
2758
          } else {
 
2759
            __pyx_t_3 = PyIter_Next(__pyx_t_2);
 
2760
            if (!__pyx_t_3) {
 
2761
              if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2762
              break;
 
2763
            }
 
2764
            __Pyx_GOTREF(__pyx_t_3);
 
2765
          }
 
2766
          __Pyx_DECREF(__pyx_v_head);
 
2767
          __pyx_v_head = __pyx_t_3;
 
2768
          __pyx_t_3 = 0;
 
2769
          goto __pyx_L11_break;
 
2770
        }
 
2771
        __pyx_L11_break:;
 
2772
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
2773
        goto __pyx_L9;
 
2774
      }
 
2775
      /*else*/ {
 
2776
 
 
2777
        /* "bzrlib/_annotator_pyx.pyx":291
 
2778
 *                     # We need to resolve the ambiguity, for now just pick the
 
2779
 *                     # sorted smallest
 
2780
 *                     head = self._resolve_annotation_tie(the_heads, line,             # <<<<<<<<<<<<<<
 
2781
 *                                                         custom_tiebreaker)
 
2782
 *             PyList_Append(out, (head, line))
 
2783
 */
 
2784
        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_11); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2785
        __Pyx_GOTREF(__pyx_t_2);
 
2786
 
 
2787
        /* "bzrlib/_annotator_pyx.pyx":292
 
2788
 *                     # sorted smallest
 
2789
 *                     head = self._resolve_annotation_tie(the_heads, line,
 
2790
 *                                                         custom_tiebreaker)             # <<<<<<<<<<<<<<
 
2791
 *             PyList_Append(out, (head, line))
 
2792
 *         return out
 
2793
 */
 
2794
        __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2795
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
2796
        __Pyx_INCREF(__pyx_v_the_heads);
 
2797
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_the_heads);
 
2798
        __Pyx_GIVEREF(__pyx_v_the_heads);
 
2799
        __Pyx_INCREF(__pyx_v_line);
 
2800
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_line);
 
2801
        __Pyx_GIVEREF(__pyx_v_line);
 
2802
        __Pyx_INCREF(__pyx_v_custom_tiebreaker);
 
2803
        PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_custom_tiebreaker);
 
2804
        __Pyx_GIVEREF(__pyx_v_custom_tiebreaker);
 
2805
        __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2806
        __Pyx_GOTREF(__pyx_t_1);
 
2807
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
2808
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
2809
        __Pyx_DECREF(__pyx_v_head);
 
2810
        __pyx_v_head = __pyx_t_1;
 
2811
        __pyx_t_1 = 0;
 
2812
      }
 
2813
      __pyx_L9:;
 
2814
    }
 
2815
    __pyx_L8:;
 
2816
 
 
2817
    /* "bzrlib/_annotator_pyx.pyx":293
 
2818
 *                     head = self._resolve_annotation_tie(the_heads, line,
 
2819
 *                                                         custom_tiebreaker)
 
2820
 *             PyList_Append(out, (head, line))             # <<<<<<<<<<<<<<
 
2821
 *         return out
 
2822
 */
 
2823
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2824
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
2825
    __Pyx_INCREF(__pyx_v_head);
 
2826
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_head);
 
2827
    __Pyx_GIVEREF(__pyx_v_head);
 
2828
    __Pyx_INCREF(__pyx_v_line);
 
2829
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_line);
 
2830
    __Pyx_GIVEREF(__pyx_v_line);
 
2831
    __pyx_t_8 = PyList_Append(((PyObject *)__pyx_v_out), ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2832
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
2833
  }
 
2834
 
 
2835
  /* "bzrlib/_annotator_pyx.pyx":294
 
2836
 *                                                         custom_tiebreaker)
 
2837
 *             PyList_Append(out, (head, line))
 
2838
 *         return out             # <<<<<<<<<<<<<<
 
2839
 */
 
2840
  __Pyx_XDECREF(__pyx_r);
 
2841
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
 
2842
  __pyx_r = ((PyObject *)__pyx_v_out);
 
2843
  goto __pyx_L0;
 
2844
 
 
2845
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2846
  goto __pyx_L0;
 
2847
  __pyx_L1_error:;
 
2848
  __Pyx_XDECREF(__pyx_t_1);
 
2849
  __Pyx_XDECREF(__pyx_t_2);
 
2850
  __Pyx_XDECREF(__pyx_t_3);
 
2851
  __Pyx_XDECREF(__pyx_t_4);
 
2852
  __Pyx_AddTraceback("bzrlib._annotator_pyx.Annotator.annotate_flat");
 
2853
  __pyx_r = NULL;
 
2854
  __pyx_L0:;
 
2855
  __Pyx_DECREF(__pyx_v_annotate);
 
2856
  __Pyx_DECREF(__pyx_v_custom_tiebreaker);
 
2857
  __Pyx_DECREF(__pyx_v_annotations);
 
2858
  __Pyx_DECREF(__pyx_v_lines);
 
2859
  __Pyx_DECREF(__pyx_v_out);
 
2860
  __Pyx_DECREF(__pyx_v_heads);
 
2861
  __Pyx_DECREF(__pyx_v_annotation);
 
2862
  __Pyx_DECREF(__pyx_v_line);
 
2863
  __Pyx_DECREF(__pyx_v_head);
 
2864
  __Pyx_DECREF(__pyx_v_the_heads);
 
2865
  __Pyx_XGIVEREF(__pyx_r);
 
2866
  __Pyx_RefNannyFinishContext();
 
2867
  return __pyx_r;
 
2868
}
 
2869
 
 
2870
static PyMethodDef __pyx_methods[] = {
 
2871
  {0, 0, 0, 0}
 
2872
};
 
2873
 
 
2874
#if PY_MAJOR_VERSION >= 3
 
2875
static struct PyModuleDef __pyx_moduledef = {
 
2876
    PyModuleDef_HEAD_INIT,
 
2877
    __Pyx_NAMESTR("_annotator_pyx"),
 
2878
    __Pyx_DOCSTR(__pyx_k_12), /* m_doc */
 
2879
    -1, /* m_size */
 
2880
    __pyx_methods /* m_methods */,
 
2881
    NULL, /* m_reload */
 
2882
    NULL, /* m_traverse */
 
2883
    NULL, /* m_clear */
 
2884
    NULL /* m_free */
 
2885
};
 
2886
#endif
 
2887
 
 
2888
static __Pyx_StringTabEntry __pyx_string_tab[] = {
 
2889
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
 
2890
  {&__pyx_n_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 1},
 
2891
  {&__pyx_n_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 1},
 
2892
  {&__pyx_n_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 1},
 
2893
  {&__pyx_n_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 1},
 
2894
  {&__pyx_n_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 1},
 
2895
  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
 
2896
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
 
2897
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
 
2898
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
 
2899
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
 
2900
  {&__pyx_n_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 1},
 
2901
  {&__pyx_n_s__Annotator, __pyx_k__Annotator, sizeof(__pyx_k__Annotator), 0, 0, 1, 1},
 
2902
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
 
2903
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
 
2904
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
 
2905
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
 
2906
  {&__pyx_n_s___ann_tuple_cache, __pyx_k___ann_tuple_cache, sizeof(__pyx_k___ann_tuple_cache), 0, 0, 1, 1},
 
2907
  {&__pyx_n_s___annotator_py, __pyx_k___annotator_py, sizeof(__pyx_k___annotator_py), 0, 0, 1, 1},
 
2908
  {&__pyx_n_s___get_heads_provider, __pyx_k___get_heads_provider, sizeof(__pyx_k___get_heads_provider), 0, 0, 1, 1},
 
2909
  {&__pyx_n_s__annotate, __pyx_k__annotate, sizeof(__pyx_k__annotate), 0, 0, 1, 1},
 
2910
  {&__pyx_n_s__annotate_flat, __pyx_k__annotate_flat, sizeof(__pyx_k__annotate_flat), 0, 0, 1, 1},
 
2911
  {&__pyx_n_s__annotations, __pyx_k__annotations, sizeof(__pyx_k__annotations), 0, 0, 1, 1},
 
2912
  {&__pyx_n_s__bzrlib, __pyx_k__bzrlib, sizeof(__pyx_k__bzrlib), 0, 0, 1, 1},
 
2913
  {&__pyx_n_s__heads, __pyx_k__heads, sizeof(__pyx_k__heads), 0, 0, 1, 1},
 
2914
  {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1},
 
2915
  {&__pyx_n_s__lines, __pyx_k__lines, sizeof(__pyx_k__lines), 0, 0, 1, 1},
 
2916
  {&__pyx_n_s__ob_item, __pyx_k__ob_item, sizeof(__pyx_k__ob_item), 0, 0, 1, 1},
 
2917
  {&__pyx_n_s__parent_key, __pyx_k__parent_key, sizeof(__pyx_k__parent_key), 0, 0, 1, 1},
 
2918
  {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
 
2919
  {&__pyx_n_s__this_annotation, __pyx_k__this_annotation, sizeof(__pyx_k__this_annotation), 0, 0, 1, 1},
 
2920
  {0, 0, 0, 0, 0, 0, 0}
 
2921
};
 
2922
static int __Pyx_InitCachedBuiltins(void) {
 
2923
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2924
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2925
  return 0;
 
2926
  __pyx_L1_error:;
 
2927
  return -1;
 
2928
}
 
2929
 
 
2930
static int __Pyx_InitCachedConstants(void) {
 
2931
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");
 
2932
 
 
2933
  /* "bzrlib/_annotator_pyx.pyx":64
 
2934
 *                                       parent_annotations) except -1:
 
2935
 *     if not PyList_CheckExact(annotations):
 
2936
 *         raise TypeError('annotations must be a list')             # <<<<<<<<<<<<<<
 
2937
 *     if not PyList_CheckExact(parent_annotations):
 
2938
 *         raise TypeError('parent_annotations must be a list')
 
2939
 */
 
2940
  __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2941
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_2));
 
2942
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
 
2943
  PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_kp_s_1));
 
2944
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
 
2945
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));
 
2946
 
 
2947
  /* "bzrlib/_annotator_pyx.pyx":66
 
2948
 *         raise TypeError('annotations must be a list')
 
2949
 *     if not PyList_CheckExact(parent_annotations):
 
2950
 *         raise TypeError('parent_annotations must be a list')             # <<<<<<<<<<<<<<
 
2951
 *     return 0
 
2952
 * 
 
2953
 */
 
2954
  __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2955
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_4));
 
2956
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
 
2957
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_kp_s_3));
 
2958
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
 
2959
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));
 
2960
 
 
2961
  /* "bzrlib/_annotator_pyx.pyx":115
 
2962
 * 
 
2963
 *     if not PyTuple_CheckExact(ann_one) or not PyTuple_CheckExact(ann_two):
 
2964
 *         raise TypeError('annotations must be tuples')             # <<<<<<<<<<<<<<
 
2965
 *     # We know that annotations are tuples, and that both sides are already
 
2966
 *     # sorted, so we can just walk and update a new list.
 
2967
 */
 
2968
  __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2969
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_8));
 
2970
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
 
2971
  PyTuple_SET_ITEM(__pyx_k_tuple_8, 0, ((PyObject *)__pyx_kp_s_7));
 
2972
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
 
2973
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8));
 
2974
  __Pyx_RefNannyFinishContext();
 
2975
  return 0;
 
2976
  __pyx_L1_error:;
 
2977
  __Pyx_RefNannyFinishContext();
 
2978
  return -1;
 
2979
}
 
2980
 
 
2981
static int __Pyx_InitGlobals(void) {
 
2982
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
2983
  return 0;
 
2984
  __pyx_L1_error:;
 
2985
  return -1;
 
2986
}
 
2987
 
 
2988
#if PY_MAJOR_VERSION < 3
 
2989
PyMODINIT_FUNC init_annotator_pyx(void); /*proto*/
 
2990
PyMODINIT_FUNC init_annotator_pyx(void)
 
2991
#else
 
2992
PyMODINIT_FUNC PyInit__annotator_pyx(void); /*proto*/
 
2993
PyMODINIT_FUNC PyInit__annotator_pyx(void)
 
2994
#endif
 
2995
{
 
2996
  PyObject *__pyx_t_1 = NULL;
 
2997
  PyObject *__pyx_t_2 = NULL;
 
2998
  PyObject *__pyx_t_3 = NULL;
 
2999
  #if CYTHON_REFNANNY
 
3000
  void* __pyx_refnanny = NULL;
 
3001
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
 
3002
  if (!__Pyx_RefNanny) {
 
3003
      PyErr_Clear();
 
3004
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
 
3005
      if (!__Pyx_RefNanny)
 
3006
          Py_FatalError("failed to import 'refnanny' module");
 
3007
  }
 
3008
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit__annotator_pyx(void)", __LINE__, __FILE__);
 
3009
  #endif
 
3010
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3011
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3012
  #ifdef __pyx_binding_PyCFunctionType_USED
 
3013
  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3014
  #endif
 
3015
  /*--- Library function declarations ---*/
 
3016
  /*--- Threads initialization code ---*/
 
3017
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
 
3018
  #ifdef WITH_THREAD /* Python build with threading support? */
 
3019
  PyEval_InitThreads();
 
3020
  #endif
 
3021
  #endif
 
3022
  /*--- Module creation code ---*/
 
3023
  #if PY_MAJOR_VERSION < 3
 
3024
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_annotator_pyx"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_12), 0, PYTHON_API_VERSION);
 
3025
  #else
 
3026
  __pyx_m = PyModule_Create(&__pyx_moduledef);
 
3027
  #endif
 
3028
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
3029
  #if PY_MAJOR_VERSION < 3
 
3030
  Py_INCREF(__pyx_m);
 
3031
  #endif
 
3032
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
 
3033
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
3034
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
3035
  /*--- Initialize various global constants etc. ---*/
 
3036
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3037
  if (__pyx_module_is_main_bzrlib___annotator_pyx) {
 
3038
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
3039
  }
 
3040
  /*--- Builtin init code ---*/
 
3041
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3042
  /*--- Constants init code ---*/
 
3043
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3044
  /*--- Global init code ---*/
 
3045
  /*--- Function export code ---*/
 
3046
  /*--- Type init code ---*/
 
3047
  /*--- Type import code ---*/
 
3048
  /*--- Function import code ---*/
 
3049
  /*--- Execution code ---*/
 
3050
 
 
3051
  /* "bzrlib/_annotator_pyx.pyx":58
 
3052
 * 
 
3053
 * 
 
3054
 * from bzrlib import _annotator_py             # <<<<<<<<<<<<<<
 
3055
 * 
 
3056
 * 
 
3057
 */
 
3058
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3059
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
3060
  __Pyx_INCREF(((PyObject *)__pyx_n_s___annotator_py));
 
3061
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s___annotator_py));
 
3062
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s___annotator_py));
 
3063
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__bzrlib), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3064
  __Pyx_GOTREF(__pyx_t_2);
 
3065
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
3066
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s___annotator_py); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3067
  __Pyx_GOTREF(__pyx_t_1);
 
3068
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___annotator_py, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3069
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3070
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
3071
 
 
3072
  /* "bzrlib/_annotator_pyx.pyx":244
 
3073
 * 
 
3074
 * 
 
3075
 * class Annotator(_annotator_py.Annotator):             # <<<<<<<<<<<<<<
 
3076
 *     """Class that drives performing annotations."""
 
3077
 * 
 
3078
 */
 
3079
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3080
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
3081
 
 
3082
  /* "bzrlib/_annotator_pyx.pyx":247
 
3083
 *     """Class that drives performing annotations."""
 
3084
 * 
 
3085
 *     def _update_from_first_parent(self, key, annotations, lines, parent_key):             # <<<<<<<<<<<<<<
 
3086
 *         """Reannotate this text relative to its first parent."""
 
3087
 *         (parent_annotations,
 
3088
 */
 
3089
  __pyx_t_1 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator__update_from_first_parent, NULL, __pyx_n_s_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3090
  __Pyx_GOTREF(__pyx_t_1);
 
3091
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s_14, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3092
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3093
 
 
3094
  /* "bzrlib/_annotator_pyx.pyx":256
 
3095
 *                                   matching_blocks)
 
3096
 * 
 
3097
 *     def _update_from_other_parents(self, key, annotations, lines,             # <<<<<<<<<<<<<<
 
3098
 *                                    this_annotation, parent_key):
 
3099
 *         """Reannotate this text relative to a second (or more) parent."""
 
3100
 */
 
3101
  __pyx_t_1 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator_1_update_from_other_parents, NULL, __pyx_n_s_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3102
  __Pyx_GOTREF(__pyx_t_1);
 
3103
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s_15, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3104
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3105
 
 
3106
  /* "bzrlib/_annotator_pyx.pyx":265
 
3107
 *                            matching_blocks, self._ann_tuple_cache)
 
3108
 * 
 
3109
 *     def annotate_flat(self, key):             # <<<<<<<<<<<<<<
 
3110
 *         """Determine the single-best-revision to source for each line.
 
3111
 * 
 
3112
 */
 
3113
  __pyx_t_1 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_6bzrlib_14_annotator_pyx_9Annotator_2annotate_flat, NULL, __pyx_n_s_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3114
  __Pyx_GOTREF(__pyx_t_1);
 
3115
  if (PyObject_SetItem(__pyx_t_2, __pyx_n_s__annotate_flat, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3116
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3117
 
 
3118
  /* "bzrlib/_annotator_pyx.pyx":244
 
3119
 * 
 
3120
 * 
 
3121
 * class Annotator(_annotator_py.Annotator):             # <<<<<<<<<<<<<<
 
3122
 *     """Class that drives performing annotations."""
 
3123
 * 
 
3124
 */
 
3125
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___annotator_py); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3126
  __Pyx_GOTREF(__pyx_t_1);
 
3127
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__Annotator); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3128
  __Pyx_GOTREF(__pyx_t_3);
 
3129
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3130
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3131
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
3132
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
 
3133
  __Pyx_GIVEREF(__pyx_t_3);
 
3134
  __pyx_t_3 = 0;
 
3135
  if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_16)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3136
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2), __pyx_n_s__Annotator, __pyx_n_s_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3137
  __Pyx_GOTREF(__pyx_t_3);
 
3138
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
3139
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Annotator, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3140
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3141
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
3142
 
 
3143
  /* "bzrlib/_annotator_pyx.pyx":1
 
3144
 * # Copyright (C) 2009, 2010 Canonical Ltd             # <<<<<<<<<<<<<<
 
3145
 * #
 
3146
 * # This program is free software; you can redistribute it and/or modify
 
3147
 */
 
3148
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3149
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
3150
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3151
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
3152
  goto __pyx_L0;
 
3153
  __pyx_L1_error:;
 
3154
  __Pyx_XDECREF(__pyx_t_1);
 
3155
  __Pyx_XDECREF(__pyx_t_2);
 
3156
  __Pyx_XDECREF(__pyx_t_3);
 
3157
  if (__pyx_m) {
 
3158
    __Pyx_AddTraceback("init bzrlib._annotator_pyx");
 
3159
    Py_DECREF(__pyx_m); __pyx_m = 0;
 
3160
  } else if (!PyErr_Occurred()) {
 
3161
    PyErr_SetString(PyExc_ImportError, "init bzrlib._annotator_pyx");
 
3162
  }
 
3163
  __pyx_L0:;
 
3164
  __Pyx_RefNannyFinishContext();
 
3165
  #if PY_MAJOR_VERSION < 3
 
3166
  return;
 
3167
  #else
 
3168
  return __pyx_m;
 
3169
  #endif
 
3170
}
 
3171
 
 
3172
/* Runtime support code */
 
3173
 
 
3174
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
 
3175
    PyObject *result;
 
3176
    result = PyObject_GetAttr(dict, name);
 
3177
    if (!result)
 
3178
        PyErr_SetObject(PyExc_NameError, name);
 
3179
    return result;
 
3180
}
 
3181
 
 
3182
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
 
3183
    PyObject *tmp_type, *tmp_value, *tmp_tb;
 
3184
    PyThreadState *tstate = PyThreadState_GET();
 
3185
 
 
3186
    tmp_type = tstate->curexc_type;
 
3187
    tmp_value = tstate->curexc_value;
 
3188
    tmp_tb = tstate->curexc_traceback;
 
3189
    tstate->curexc_type = type;
 
3190
    tstate->curexc_value = value;
 
3191
    tstate->curexc_traceback = tb;
 
3192
    Py_XDECREF(tmp_type);
 
3193
    Py_XDECREF(tmp_value);
 
3194
    Py_XDECREF(tmp_tb);
 
3195
}
 
3196
 
 
3197
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
 
3198
    PyThreadState *tstate = PyThreadState_GET();
 
3199
    *type = tstate->curexc_type;
 
3200
    *value = tstate->curexc_value;
 
3201
    *tb = tstate->curexc_traceback;
 
3202
 
 
3203
    tstate->curexc_type = 0;
 
3204
    tstate->curexc_value = 0;
 
3205
    tstate->curexc_traceback = 0;
 
3206
}
 
3207
 
 
3208
 
 
3209
#if PY_MAJOR_VERSION < 3
 
3210
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
 
3211
    Py_XINCREF(type);
 
3212
    Py_XINCREF(value);
 
3213
    Py_XINCREF(tb);
 
3214
    /* First, check the traceback argument, replacing None with NULL. */
 
3215
    if (tb == Py_None) {
 
3216
        Py_DECREF(tb);
 
3217
        tb = 0;
 
3218
    }
 
3219
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
 
3220
        PyErr_SetString(PyExc_TypeError,
 
3221
            "raise: arg 3 must be a traceback or None");
 
3222
        goto raise_error;
 
3223
    }
 
3224
    /* Next, replace a missing value with None */
 
3225
    if (value == NULL) {
 
3226
        value = Py_None;
 
3227
        Py_INCREF(value);
 
3228
    }
 
3229
    #if PY_VERSION_HEX < 0x02050000
 
3230
    if (!PyClass_Check(type))
 
3231
    #else
 
3232
    if (!PyType_Check(type))
 
3233
    #endif
 
3234
    {
 
3235
        /* Raising an instance.  The value should be a dummy. */
 
3236
        if (value != Py_None) {
 
3237
            PyErr_SetString(PyExc_TypeError,
 
3238
                "instance exception may not have a separate value");
 
3239
            goto raise_error;
 
3240
        }
 
3241
        /* Normalize to raise <class>, <instance> */
 
3242
        Py_DECREF(value);
 
3243
        value = type;
 
3244
        #if PY_VERSION_HEX < 0x02050000
 
3245
            if (PyInstance_Check(type)) {
 
3246
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
 
3247
                Py_INCREF(type);
 
3248
            }
 
3249
            else {
 
3250
                type = 0;
 
3251
                PyErr_SetString(PyExc_TypeError,
 
3252
                    "raise: exception must be an old-style class or instance");
 
3253
                goto raise_error;
 
3254
            }
 
3255
        #else
 
3256
            type = (PyObject*) Py_TYPE(type);
 
3257
            Py_INCREF(type);
 
3258
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
 
3259
                PyErr_SetString(PyExc_TypeError,
 
3260
                    "raise: exception class must be a subclass of BaseException");
 
3261
                goto raise_error;
 
3262
            }
 
3263
        #endif
 
3264
    }
 
3265
 
 
3266
    __Pyx_ErrRestore(type, value, tb);
 
3267
    return;
 
3268
raise_error:
 
3269
    Py_XDECREF(value);
 
3270
    Py_XDECREF(type);
 
3271
    Py_XDECREF(tb);
 
3272
    return;
 
3273
}
 
3274
 
 
3275
#else /* Python 3+ */
 
3276
 
 
3277
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
 
3278
    if (tb == Py_None) {
 
3279
        tb = 0;
 
3280
    } else if (tb && !PyTraceBack_Check(tb)) {
 
3281
        PyErr_SetString(PyExc_TypeError,
 
3282
            "raise: arg 3 must be a traceback or None");
 
3283
        goto bad;
 
3284
    }
 
3285
    if (value == Py_None)
 
3286
        value = 0;
 
3287
 
 
3288
    if (PyExceptionInstance_Check(type)) {
 
3289
        if (value) {
 
3290
            PyErr_SetString(PyExc_TypeError,
 
3291
                "instance exception may not have a separate value");
 
3292
            goto bad;
 
3293
        }
 
3294
        value = type;
 
3295
        type = (PyObject*) Py_TYPE(value);
 
3296
    } else if (!PyExceptionClass_Check(type)) {
 
3297
        PyErr_SetString(PyExc_TypeError,
 
3298
            "raise: exception class must be a subclass of BaseException");
 
3299
        goto bad;
 
3300
    }
 
3301
 
 
3302
    PyErr_SetObject(type, value);
 
3303
 
 
3304
    if (tb) {
 
3305
        PyThreadState *tstate = PyThreadState_GET();
 
3306
        PyObject* tmp_tb = tstate->curexc_traceback;
 
3307
        if (tb != tmp_tb) {
 
3308
            Py_INCREF(tb);
 
3309
            tstate->curexc_traceback = tb;
 
3310
            Py_XDECREF(tmp_tb);
 
3311
        }
 
3312
    }
 
3313
 
 
3314
bad:
 
3315
    return;
 
3316
}
 
3317
#endif
 
3318
 
 
3319
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
 
3320
    PyErr_Format(PyExc_ValueError,
 
3321
        #if PY_VERSION_HEX < 0x02050000
 
3322
                 "need more than %d value%s to unpack", (int)index,
 
3323
        #else
 
3324
                 "need more than %zd value%s to unpack", index,
 
3325
        #endif
 
3326
                 (index == 1) ? "" : "s");
 
3327
}
 
3328
 
 
3329
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
 
3330
    PyErr_Format(PyExc_ValueError,
 
3331
        #if PY_VERSION_HEX < 0x02050000
 
3332
            "too many values to unpack (expected %d)", (int)expected);
 
3333
        #else
 
3334
            "too many values to unpack (expected %zd)", expected);
 
3335
        #endif
 
3336
}
 
3337
 
 
3338
static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
 
3339
    PyObject *item;
 
3340
    if (!(item = PyIter_Next(iter))) {
 
3341
        if (!PyErr_Occurred()) {
 
3342
            __Pyx_RaiseNeedMoreValuesError(index);
 
3343
        }
 
3344
    }
 
3345
    return item;
 
3346
}
 
3347
 
 
3348
static int __Pyx_EndUnpack(PyObject *iter, Py_ssize_t expected) {
 
3349
    PyObject *item;
 
3350
    if ((item = PyIter_Next(iter))) {
 
3351
        Py_DECREF(item);
 
3352
        __Pyx_RaiseTooManyValuesError(expected);
 
3353
        return -1;
 
3354
    }
 
3355
    else if (!PyErr_Occurred())
 
3356
        return 0;
 
3357
    else
 
3358
        return -1;
 
3359
}
 
3360
 
 
3361
static void __Pyx_RaiseArgtupleInvalid(
 
3362
    const char* func_name,
 
3363
    int exact,
 
3364
    Py_ssize_t num_min,
 
3365
    Py_ssize_t num_max,
 
3366
    Py_ssize_t num_found)
 
3367
{
 
3368
    Py_ssize_t num_expected;
 
3369
    const char *number, *more_or_less;
 
3370
 
 
3371
    if (num_found < num_min) {
 
3372
        num_expected = num_min;
 
3373
        more_or_less = "at least";
 
3374
    } else {
 
3375
        num_expected = num_max;
 
3376
        more_or_less = "at most";
 
3377
    }
 
3378
    if (exact) {
 
3379
        more_or_less = "exactly";
 
3380
    }
 
3381
    number = (num_expected == 1) ? "" : "s";
 
3382
    PyErr_Format(PyExc_TypeError,
 
3383
        #if PY_VERSION_HEX < 0x02050000
 
3384
            "%s() takes %s %d positional argument%s (%d given)",
 
3385
        #else
 
3386
            "%s() takes %s %zd positional argument%s (%zd given)",
 
3387
        #endif
 
3388
        func_name, more_or_less, num_expected, number, num_found);
 
3389
}
 
3390
 
 
3391
static void __Pyx_RaiseDoubleKeywordsError(
 
3392
    const char* func_name,
 
3393
    PyObject* kw_name)
 
3394
{
 
3395
    PyErr_Format(PyExc_TypeError,
 
3396
        #if PY_MAJOR_VERSION >= 3
 
3397
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
 
3398
        #else
 
3399
        "%s() got multiple values for keyword argument '%s'", func_name,
 
3400
        PyString_AS_STRING(kw_name));
 
3401
        #endif
 
3402
}
 
3403
 
 
3404
static int __Pyx_ParseOptionalKeywords(
 
3405
    PyObject *kwds,
 
3406
    PyObject **argnames[],
 
3407
    PyObject *kwds2,
 
3408
    PyObject *values[],
 
3409
    Py_ssize_t num_pos_args,
 
3410
    const char* function_name)
 
3411
{
 
3412
    PyObject *key = 0, *value = 0;
 
3413
    Py_ssize_t pos = 0;
 
3414
    PyObject*** name;
 
3415
    PyObject*** first_kw_arg = argnames + num_pos_args;
 
3416
 
 
3417
    while (PyDict_Next(kwds, &pos, &key, &value)) {
 
3418
        name = first_kw_arg;
 
3419
        while (*name && (**name != key)) name++;
 
3420
        if (*name) {
 
3421
            values[name-argnames] = value;
 
3422
        } else {
 
3423
            #if PY_MAJOR_VERSION < 3
 
3424
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
 
3425
            #else
 
3426
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
 
3427
            #endif
 
3428
                goto invalid_keyword_type;
 
3429
            } else {
 
3430
                for (name = first_kw_arg; *name; name++) {
 
3431
                    #if PY_MAJOR_VERSION >= 3
 
3432
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
 
3433
                        PyUnicode_Compare(**name, key) == 0) break;
 
3434
                    #else
 
3435
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
 
3436
                        _PyString_Eq(**name, key)) break;
 
3437
                    #endif
 
3438
                }
 
3439
                if (*name) {
 
3440
                    values[name-argnames] = value;
 
3441
                } else {
 
3442
                    /* unexpected keyword found */
 
3443
                    for (name=argnames; name != first_kw_arg; name++) {
 
3444
                        if (**name == key) goto arg_passed_twice;
 
3445
                        #if PY_MAJOR_VERSION >= 3
 
3446
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
 
3447
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
 
3448
                        #else
 
3449
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
 
3450
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
 
3451
                        #endif
 
3452
                    }
 
3453
                    if (kwds2) {
 
3454
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
 
3455
                    } else {
 
3456
                        goto invalid_keyword;
 
3457
                    }
 
3458
                }
 
3459
            }
 
3460
        }
 
3461
    }
 
3462
    return 0;
 
3463
arg_passed_twice:
 
3464
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
 
3465
    goto bad;
 
3466
invalid_keyword_type:
 
3467
    PyErr_Format(PyExc_TypeError,
 
3468
        "%s() keywords must be strings", function_name);
 
3469
    goto bad;
 
3470
invalid_keyword:
 
3471
    PyErr_Format(PyExc_TypeError,
 
3472
    #if PY_MAJOR_VERSION < 3
 
3473
        "%s() got an unexpected keyword argument '%s'",
 
3474
        function_name, PyString_AsString(key));
 
3475
    #else
 
3476
        "%s() got an unexpected keyword argument '%U'",
 
3477
        function_name, key);
 
3478
    #endif
 
3479
bad:
 
3480
    return -1;
 
3481
}
 
3482
 
 
3483
 
 
3484
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
 
3485
    PyObject *py_import = 0;
 
3486
    PyObject *empty_list = 0;
 
3487
    PyObject *module = 0;
 
3488
    PyObject *global_dict = 0;
 
3489
    PyObject *empty_dict = 0;
 
3490
    PyObject *list;
 
3491
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
 
3492
    if (!py_import)
 
3493
        goto bad;
 
3494
    if (from_list)
 
3495
        list = from_list;
 
3496
    else {
 
3497
        empty_list = PyList_New(0);
 
3498
        if (!empty_list)
 
3499
            goto bad;
 
3500
        list = empty_list;
 
3501
    }
 
3502
    global_dict = PyModule_GetDict(__pyx_m);
 
3503
    if (!global_dict)
 
3504
        goto bad;
 
3505
    empty_dict = PyDict_New();
 
3506
    if (!empty_dict)
 
3507
        goto bad;
 
3508
    module = PyObject_CallFunctionObjArgs(py_import,
 
3509
        name, global_dict, empty_dict, list, NULL);
 
3510
bad:
 
3511
    Py_XDECREF(empty_list);
 
3512
    Py_XDECREF(py_import);
 
3513
    Py_XDECREF(empty_dict);
 
3514
    return module;
 
3515
}
 
3516
 
 
3517
static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
 
3518
    PyObject *metaclass;
 
3519
    /* Default metaclass */
 
3520
#if PY_MAJOR_VERSION < 3
 
3521
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
 
3522
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
 
3523
        metaclass = PyObject_GetAttrString(base, "__class__");
 
3524
        if (!metaclass) {
 
3525
            PyErr_Clear();
 
3526
            metaclass = (PyObject*) Py_TYPE(base);
 
3527
        }
 
3528
    } else {
 
3529
        metaclass = (PyObject *) &PyClass_Type;
 
3530
    }
 
3531
#else
 
3532
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
 
3533
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
 
3534
        metaclass = (PyObject*) Py_TYPE(base);
 
3535
    } else {
 
3536
        metaclass = (PyObject *) &PyType_Type;
 
3537
    }
 
3538
#endif
 
3539
    Py_INCREF(metaclass);
 
3540
    return metaclass;
 
3541
}
 
3542
 
 
3543
static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
 
3544
                                   PyObject *modname) {
 
3545
    PyObject *result;
 
3546
    PyObject *metaclass;
 
3547
 
 
3548
    if (PyDict_SetItemString(dict, "__module__", modname) < 0)
 
3549
        return NULL;
 
3550
 
 
3551
    /* Python2 __metaclass__ */
 
3552
    metaclass = PyDict_GetItemString(dict, "__metaclass__");
 
3553
    if (metaclass) {
 
3554
        Py_INCREF(metaclass);
 
3555
    } else {
 
3556
        metaclass = __Pyx_FindPy2Metaclass(bases);
 
3557
    }
 
3558
    result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
 
3559
    Py_DECREF(metaclass);
 
3560
    return result;
 
3561
}
 
3562
 
 
3563
 
 
3564
static PyObject *__pyx_binding_PyCFunctionType_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module) {
 
3565
        __pyx_binding_PyCFunctionType_object *op = PyObject_GC_New(__pyx_binding_PyCFunctionType_object, __pyx_binding_PyCFunctionType);
 
3566
    if (op == NULL)
 
3567
        return NULL;
 
3568
        op->func.m_ml = ml;
 
3569
        Py_XINCREF(self);
 
3570
        op->func.m_self = self;
 
3571
        Py_XINCREF(module);
 
3572
        op->func.m_module = module;
 
3573
        PyObject_GC_Track(op);
 
3574
        return (PyObject *)op;
 
3575
}
 
3576
 
 
3577
static void __pyx_binding_PyCFunctionType_dealloc(__pyx_binding_PyCFunctionType_object *m) {
 
3578
        PyObject_GC_UnTrack(m);
 
3579
        Py_XDECREF(m->func.m_self);
 
3580
        Py_XDECREF(m->func.m_module);
 
3581
    PyObject_GC_Del(m);
 
3582
}
 
3583
 
 
3584
static PyObject *__pyx_binding_PyCFunctionType_descr_get(PyObject *func, PyObject *obj, PyObject *type) {
 
3585
        if (obj == Py_None)
 
3586
                obj = NULL;
 
3587
        return PyMethod_New(func, obj, type);
 
3588
}
 
3589
 
 
3590
static int __pyx_binding_PyCFunctionType_init(void) {
 
3591
    __pyx_binding_PyCFunctionType_type = PyCFunction_Type;
 
3592
    __pyx_binding_PyCFunctionType_type.tp_name = __Pyx_NAMESTR("cython_binding_builtin_function_or_method");
 
3593
    __pyx_binding_PyCFunctionType_type.tp_dealloc = (destructor)__pyx_binding_PyCFunctionType_dealloc;
 
3594
    __pyx_binding_PyCFunctionType_type.tp_descr_get = __pyx_binding_PyCFunctionType_descr_get;
 
3595
    if (PyType_Ready(&__pyx_binding_PyCFunctionType_type) < 0) {
 
3596
        return -1;
 
3597
    }
 
3598
    __pyx_binding_PyCFunctionType = &__pyx_binding_PyCFunctionType_type;
 
3599
    return 0;
 
3600
 
 
3601
}
 
3602
 
 
3603
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
 
3604
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
 
3605
    const int is_unsigned = neg_one > const_zero;
 
3606
    if (sizeof(unsigned char) < sizeof(long)) {
 
3607
        long val = __Pyx_PyInt_AsLong(x);
 
3608
        if (unlikely(val != (long)(unsigned char)val)) {
 
3609
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
3610
                PyErr_SetString(PyExc_OverflowError,
 
3611
                    (is_unsigned && unlikely(val < 0)) ?
 
3612
                    "can't convert negative value to unsigned char" :
 
3613
                    "value too large to convert to unsigned char");
 
3614
            }
 
3615
            return (unsigned char)-1;
 
3616
        }
 
3617
        return (unsigned char)val;
 
3618
    }
 
3619
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
 
3620
}
 
3621
 
 
3622
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
 
3623
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
 
3624
    const int is_unsigned = neg_one > const_zero;
 
3625
    if (sizeof(unsigned short) < sizeof(long)) {
 
3626
        long val = __Pyx_PyInt_AsLong(x);
 
3627
        if (unlikely(val != (long)(unsigned short)val)) {
 
3628
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
3629
                PyErr_SetString(PyExc_OverflowError,
 
3630
                    (is_unsigned && unlikely(val < 0)) ?
 
3631
                    "can't convert negative value to unsigned short" :
 
3632
                    "value too large to convert to unsigned short");
 
3633
            }
 
3634
            return (unsigned short)-1;
 
3635
        }
 
3636
        return (unsigned short)val;
 
3637
    }
 
3638
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
 
3639
}
 
3640
 
 
3641
static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
 
3642
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
 
3643
    const int is_unsigned = neg_one > const_zero;
 
3644
    if (sizeof(unsigned int) < sizeof(long)) {
 
3645
        long val = __Pyx_PyInt_AsLong(x);
 
3646
        if (unlikely(val != (long)(unsigned int)val)) {
 
3647
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
3648
                PyErr_SetString(PyExc_OverflowError,
 
3649
                    (is_unsigned && unlikely(val < 0)) ?
 
3650
                    "can't convert negative value to unsigned int" :
 
3651
                    "value too large to convert to unsigned int");
 
3652
            }
 
3653
            return (unsigned int)-1;
 
3654
        }
 
3655
        return (unsigned int)val;
 
3656
    }
 
3657
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
 
3658
}
 
3659
 
 
3660
static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
 
3661
    const char neg_one = (char)-1, const_zero = 0;
 
3662
    const int is_unsigned = neg_one > const_zero;
 
3663
    if (sizeof(char) < sizeof(long)) {
 
3664
        long val = __Pyx_PyInt_AsLong(x);
 
3665
        if (unlikely(val != (long)(char)val)) {
 
3666
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
3667
                PyErr_SetString(PyExc_OverflowError,
 
3668
                    (is_unsigned && unlikely(val < 0)) ?
 
3669
                    "can't convert negative value to char" :
 
3670
                    "value too large to convert to char");
 
3671
            }
 
3672
            return (char)-1;
 
3673
        }
 
3674
        return (char)val;
 
3675
    }
 
3676
    return (char)__Pyx_PyInt_AsLong(x);
 
3677
}
 
3678
 
 
3679
static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
 
3680
    const short neg_one = (short)-1, const_zero = 0;
 
3681
    const int is_unsigned = neg_one > const_zero;
 
3682
    if (sizeof(short) < sizeof(long)) {
 
3683
        long val = __Pyx_PyInt_AsLong(x);
 
3684
        if (unlikely(val != (long)(short)val)) {
 
3685
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
3686
                PyErr_SetString(PyExc_OverflowError,
 
3687
                    (is_unsigned && unlikely(val < 0)) ?
 
3688
                    "can't convert negative value to short" :
 
3689
                    "value too large to convert to short");
 
3690
            }
 
3691
            return (short)-1;
 
3692
        }
 
3693
        return (short)val;
 
3694
    }
 
3695
    return (short)__Pyx_PyInt_AsLong(x);
 
3696
}
 
3697
 
 
3698
static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
 
3699
    const int neg_one = (int)-1, const_zero = 0;
 
3700
    const int is_unsigned = neg_one > const_zero;
 
3701
    if (sizeof(int) < sizeof(long)) {
 
3702
        long val = __Pyx_PyInt_AsLong(x);
 
3703
        if (unlikely(val != (long)(int)val)) {
 
3704
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
3705
                PyErr_SetString(PyExc_OverflowError,
 
3706
                    (is_unsigned && unlikely(val < 0)) ?
 
3707
                    "can't convert negative value to int" :
 
3708
                    "value too large to convert to int");
 
3709
            }
 
3710
            return (int)-1;
 
3711
        }
 
3712
        return (int)val;
 
3713
    }
 
3714
    return (int)__Pyx_PyInt_AsLong(x);
 
3715
}
 
3716
 
 
3717
static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
 
3718
    const signed char neg_one = (signed char)-1, const_zero = 0;
 
3719
    const int is_unsigned = neg_one > const_zero;
 
3720
    if (sizeof(signed char) < sizeof(long)) {
 
3721
        long val = __Pyx_PyInt_AsLong(x);
 
3722
        if (unlikely(val != (long)(signed char)val)) {
 
3723
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
3724
                PyErr_SetString(PyExc_OverflowError,
 
3725
                    (is_unsigned && unlikely(val < 0)) ?
 
3726
                    "can't convert negative value to signed char" :
 
3727
                    "value too large to convert to signed char");
 
3728
            }
 
3729
            return (signed char)-1;
 
3730
        }
 
3731
        return (signed char)val;
 
3732
    }
 
3733
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
 
3734
}
 
3735
 
 
3736
static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
 
3737
    const signed short neg_one = (signed short)-1, const_zero = 0;
 
3738
    const int is_unsigned = neg_one > const_zero;
 
3739
    if (sizeof(signed short) < sizeof(long)) {
 
3740
        long val = __Pyx_PyInt_AsLong(x);
 
3741
        if (unlikely(val != (long)(signed short)val)) {
 
3742
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
3743
                PyErr_SetString(PyExc_OverflowError,
 
3744
                    (is_unsigned && unlikely(val < 0)) ?
 
3745
                    "can't convert negative value to signed short" :
 
3746
                    "value too large to convert to signed short");
 
3747
            }
 
3748
            return (signed short)-1;
 
3749
        }
 
3750
        return (signed short)val;
 
3751
    }
 
3752
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
 
3753
}
 
3754
 
 
3755
static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
 
3756
    const signed int neg_one = (signed int)-1, const_zero = 0;
 
3757
    const int is_unsigned = neg_one > const_zero;
 
3758
    if (sizeof(signed int) < sizeof(long)) {
 
3759
        long val = __Pyx_PyInt_AsLong(x);
 
3760
        if (unlikely(val != (long)(signed int)val)) {
 
3761
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
3762
                PyErr_SetString(PyExc_OverflowError,
 
3763
                    (is_unsigned && unlikely(val < 0)) ?
 
3764
                    "can't convert negative value to signed int" :
 
3765
                    "value too large to convert to signed int");
 
3766
            }
 
3767
            return (signed int)-1;
 
3768
        }
 
3769
        return (signed int)val;
 
3770
    }
 
3771
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
 
3772
}
 
3773
 
 
3774
static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
 
3775
    const int neg_one = (int)-1, const_zero = 0;
 
3776
    const int is_unsigned = neg_one > const_zero;
 
3777
    if (sizeof(int) < sizeof(long)) {
 
3778
        long val = __Pyx_PyInt_AsLong(x);
 
3779
        if (unlikely(val != (long)(int)val)) {
 
3780
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
3781
                PyErr_SetString(PyExc_OverflowError,
 
3782
                    (is_unsigned && unlikely(val < 0)) ?
 
3783
                    "can't convert negative value to int" :
 
3784
                    "value too large to convert to int");
 
3785
            }
 
3786
            return (int)-1;
 
3787
        }
 
3788
        return (int)val;
 
3789
    }
 
3790
    return (int)__Pyx_PyInt_AsLong(x);
 
3791
}
 
3792
 
 
3793
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
 
3794
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
 
3795
    const int is_unsigned = neg_one > const_zero;
 
3796
#if PY_VERSION_HEX < 0x03000000
 
3797
    if (likely(PyInt_Check(x))) {
 
3798
        long val = PyInt_AS_LONG(x);
 
3799
        if (is_unsigned && unlikely(val < 0)) {
 
3800
            PyErr_SetString(PyExc_OverflowError,
 
3801
                            "can't convert negative value to unsigned long");
 
3802
            return (unsigned long)-1;
 
3803
        }
 
3804
        return (unsigned long)val;
 
3805
    } else
 
3806
#endif
 
3807
    if (likely(PyLong_Check(x))) {
 
3808
        if (is_unsigned) {
 
3809
            if (unlikely(Py_SIZE(x) < 0)) {
 
3810
                PyErr_SetString(PyExc_OverflowError,
 
3811
                                "can't convert negative value to unsigned long");
 
3812
                return (unsigned long)-1;
 
3813
            }
 
3814
            return PyLong_AsUnsignedLong(x);
 
3815
        } else {
 
3816
            return PyLong_AsLong(x);
 
3817
        }
 
3818
    } else {
 
3819
        unsigned long val;
 
3820
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
3821
        if (!tmp) return (unsigned long)-1;
 
3822
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
 
3823
        Py_DECREF(tmp);
 
3824
        return val;
 
3825
    }
 
3826
}
 
3827
 
 
3828
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
 
3829
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
 
3830
    const int is_unsigned = neg_one > const_zero;
 
3831
#if PY_VERSION_HEX < 0x03000000
 
3832
    if (likely(PyInt_Check(x))) {
 
3833
        long val = PyInt_AS_LONG(x);
 
3834
        if (is_unsigned && unlikely(val < 0)) {
 
3835
            PyErr_SetString(PyExc_OverflowError,
 
3836
                            "can't convert negative value to unsigned PY_LONG_LONG");
 
3837
            return (unsigned PY_LONG_LONG)-1;
 
3838
        }
 
3839
        return (unsigned PY_LONG_LONG)val;
 
3840
    } else
 
3841
#endif
 
3842
    if (likely(PyLong_Check(x))) {
 
3843
        if (is_unsigned) {
 
3844
            if (unlikely(Py_SIZE(x) < 0)) {
 
3845
                PyErr_SetString(PyExc_OverflowError,
 
3846
                                "can't convert negative value to unsigned PY_LONG_LONG");
 
3847
                return (unsigned PY_LONG_LONG)-1;
 
3848
            }
 
3849
            return PyLong_AsUnsignedLongLong(x);
 
3850
        } else {
 
3851
            return PyLong_AsLongLong(x);
 
3852
        }
 
3853
    } else {
 
3854
        unsigned PY_LONG_LONG val;
 
3855
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
3856
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
 
3857
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
 
3858
        Py_DECREF(tmp);
 
3859
        return val;
 
3860
    }
 
3861
}
 
3862
 
 
3863
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
 
3864
    const long neg_one = (long)-1, const_zero = 0;
 
3865
    const int is_unsigned = neg_one > const_zero;
 
3866
#if PY_VERSION_HEX < 0x03000000
 
3867
    if (likely(PyInt_Check(x))) {
 
3868
        long val = PyInt_AS_LONG(x);
 
3869
        if (is_unsigned && unlikely(val < 0)) {
 
3870
            PyErr_SetString(PyExc_OverflowError,
 
3871
                            "can't convert negative value to long");
 
3872
            return (long)-1;
 
3873
        }
 
3874
        return (long)val;
 
3875
    } else
 
3876
#endif
 
3877
    if (likely(PyLong_Check(x))) {
 
3878
        if (is_unsigned) {
 
3879
            if (unlikely(Py_SIZE(x) < 0)) {
 
3880
                PyErr_SetString(PyExc_OverflowError,
 
3881
                                "can't convert negative value to long");
 
3882
                return (long)-1;
 
3883
            }
 
3884
            return PyLong_AsUnsignedLong(x);
 
3885
        } else {
 
3886
            return PyLong_AsLong(x);
 
3887
        }
 
3888
    } else {
 
3889
        long val;
 
3890
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
3891
        if (!tmp) return (long)-1;
 
3892
        val = __Pyx_PyInt_AsLong(tmp);
 
3893
        Py_DECREF(tmp);
 
3894
        return val;
 
3895
    }
 
3896
}
 
3897
 
 
3898
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
 
3899
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
 
3900
    const int is_unsigned = neg_one > const_zero;
 
3901
#if PY_VERSION_HEX < 0x03000000
 
3902
    if (likely(PyInt_Check(x))) {
 
3903
        long val = PyInt_AS_LONG(x);
 
3904
        if (is_unsigned && unlikely(val < 0)) {
 
3905
            PyErr_SetString(PyExc_OverflowError,
 
3906
                            "can't convert negative value to PY_LONG_LONG");
 
3907
            return (PY_LONG_LONG)-1;
 
3908
        }
 
3909
        return (PY_LONG_LONG)val;
 
3910
    } else
 
3911
#endif
 
3912
    if (likely(PyLong_Check(x))) {
 
3913
        if (is_unsigned) {
 
3914
            if (unlikely(Py_SIZE(x) < 0)) {
 
3915
                PyErr_SetString(PyExc_OverflowError,
 
3916
                                "can't convert negative value to PY_LONG_LONG");
 
3917
                return (PY_LONG_LONG)-1;
 
3918
            }
 
3919
            return PyLong_AsUnsignedLongLong(x);
 
3920
        } else {
 
3921
            return PyLong_AsLongLong(x);
 
3922
        }
 
3923
    } else {
 
3924
        PY_LONG_LONG val;
 
3925
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
3926
        if (!tmp) return (PY_LONG_LONG)-1;
 
3927
        val = __Pyx_PyInt_AsLongLong(tmp);
 
3928
        Py_DECREF(tmp);
 
3929
        return val;
 
3930
    }
 
3931
}
 
3932
 
 
3933
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
 
3934
    const signed long neg_one = (signed long)-1, const_zero = 0;
 
3935
    const int is_unsigned = neg_one > const_zero;
 
3936
#if PY_VERSION_HEX < 0x03000000
 
3937
    if (likely(PyInt_Check(x))) {
 
3938
        long val = PyInt_AS_LONG(x);
 
3939
        if (is_unsigned && unlikely(val < 0)) {
 
3940
            PyErr_SetString(PyExc_OverflowError,
 
3941
                            "can't convert negative value to signed long");
 
3942
            return (signed long)-1;
 
3943
        }
 
3944
        return (signed long)val;
 
3945
    } else
 
3946
#endif
 
3947
    if (likely(PyLong_Check(x))) {
 
3948
        if (is_unsigned) {
 
3949
            if (unlikely(Py_SIZE(x) < 0)) {
 
3950
                PyErr_SetString(PyExc_OverflowError,
 
3951
                                "can't convert negative value to signed long");
 
3952
                return (signed long)-1;
 
3953
            }
 
3954
            return PyLong_AsUnsignedLong(x);
 
3955
        } else {
 
3956
            return PyLong_AsLong(x);
 
3957
        }
 
3958
    } else {
 
3959
        signed long val;
 
3960
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
3961
        if (!tmp) return (signed long)-1;
 
3962
        val = __Pyx_PyInt_AsSignedLong(tmp);
 
3963
        Py_DECREF(tmp);
 
3964
        return val;
 
3965
    }
 
3966
}
 
3967
 
 
3968
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
 
3969
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
 
3970
    const int is_unsigned = neg_one > const_zero;
 
3971
#if PY_VERSION_HEX < 0x03000000
 
3972
    if (likely(PyInt_Check(x))) {
 
3973
        long val = PyInt_AS_LONG(x);
 
3974
        if (is_unsigned && unlikely(val < 0)) {
 
3975
            PyErr_SetString(PyExc_OverflowError,
 
3976
                            "can't convert negative value to signed PY_LONG_LONG");
 
3977
            return (signed PY_LONG_LONG)-1;
 
3978
        }
 
3979
        return (signed PY_LONG_LONG)val;
 
3980
    } else
 
3981
#endif
 
3982
    if (likely(PyLong_Check(x))) {
 
3983
        if (is_unsigned) {
 
3984
            if (unlikely(Py_SIZE(x) < 0)) {
 
3985
                PyErr_SetString(PyExc_OverflowError,
 
3986
                                "can't convert negative value to signed PY_LONG_LONG");
 
3987
                return (signed PY_LONG_LONG)-1;
 
3988
            }
 
3989
            return PyLong_AsUnsignedLongLong(x);
 
3990
        } else {
 
3991
            return PyLong_AsLongLong(x);
 
3992
        }
 
3993
    } else {
 
3994
        signed PY_LONG_LONG val;
 
3995
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
3996
        if (!tmp) return (signed PY_LONG_LONG)-1;
 
3997
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
 
3998
        Py_DECREF(tmp);
 
3999
        return val;
 
4000
    }
 
4001
}
 
4002
 
 
4003
#include "compile.h"
 
4004
#include "frameobject.h"
 
4005
#include "traceback.h"
 
4006
 
 
4007
static void __Pyx_AddTraceback(const char *funcname) {
 
4008
    PyObject *py_srcfile = 0;
 
4009
    PyObject *py_funcname = 0;
 
4010
    PyObject *py_globals = 0;
 
4011
    PyCodeObject *py_code = 0;
 
4012
    PyFrameObject *py_frame = 0;
 
4013
 
 
4014
    #if PY_MAJOR_VERSION < 3
 
4015
    py_srcfile = PyString_FromString(__pyx_filename);
 
4016
    #else
 
4017
    py_srcfile = PyUnicode_FromString(__pyx_filename);
 
4018
    #endif
 
4019
    if (!py_srcfile) goto bad;
 
4020
    if (__pyx_clineno) {
 
4021
        #if PY_MAJOR_VERSION < 3
 
4022
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
 
4023
        #else
 
4024
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
 
4025
        #endif
 
4026
    }
 
4027
    else {
 
4028
        #if PY_MAJOR_VERSION < 3
 
4029
        py_funcname = PyString_FromString(funcname);
 
4030
        #else
 
4031
        py_funcname = PyUnicode_FromString(funcname);
 
4032
        #endif
 
4033
    }
 
4034
    if (!py_funcname) goto bad;
 
4035
    py_globals = PyModule_GetDict(__pyx_m);
 
4036
    if (!py_globals) goto bad;
 
4037
    py_code = PyCode_New(
 
4038
        0,            /*int argcount,*/
 
4039
        #if PY_MAJOR_VERSION >= 3
 
4040
        0,            /*int kwonlyargcount,*/
 
4041
        #endif
 
4042
        0,            /*int nlocals,*/
 
4043
        0,            /*int stacksize,*/
 
4044
        0,            /*int flags,*/
 
4045
        __pyx_empty_bytes, /*PyObject *code,*/
 
4046
        __pyx_empty_tuple,  /*PyObject *consts,*/
 
4047
        __pyx_empty_tuple,  /*PyObject *names,*/
 
4048
        __pyx_empty_tuple,  /*PyObject *varnames,*/
 
4049
        __pyx_empty_tuple,  /*PyObject *freevars,*/
 
4050
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
 
4051
        py_srcfile,   /*PyObject *filename,*/
 
4052
        py_funcname,  /*PyObject *name,*/
 
4053
        __pyx_lineno,   /*int firstlineno,*/
 
4054
        __pyx_empty_bytes  /*PyObject *lnotab*/
 
4055
    );
 
4056
    if (!py_code) goto bad;
 
4057
    py_frame = PyFrame_New(
 
4058
        PyThreadState_GET(), /*PyThreadState *tstate,*/
 
4059
        py_code,             /*PyCodeObject *code,*/
 
4060
        py_globals,          /*PyObject *globals,*/
 
4061
        0                    /*PyObject *locals*/
 
4062
    );
 
4063
    if (!py_frame) goto bad;
 
4064
    py_frame->f_lineno = __pyx_lineno;
 
4065
    PyTraceBack_Here(py_frame);
 
4066
bad:
 
4067
    Py_XDECREF(py_srcfile);
 
4068
    Py_XDECREF(py_funcname);
 
4069
    Py_XDECREF(py_code);
 
4070
    Py_XDECREF(py_frame);
 
4071
}
 
4072
 
 
4073
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
 
4074
    while (t->p) {
 
4075
        #if PY_MAJOR_VERSION < 3
 
4076
        if (t->is_unicode) {
 
4077
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
 
4078
        } else if (t->intern) {
 
4079
            *t->p = PyString_InternFromString(t->s);
 
4080
        } else {
 
4081
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
 
4082
        }
 
4083
        #else  /* Python 3+ has unicode identifiers */
 
4084
        if (t->is_unicode | t->is_str) {
 
4085
            if (t->intern) {
 
4086
                *t->p = PyUnicode_InternFromString(t->s);
 
4087
            } else if (t->encoding) {
 
4088
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
 
4089
            } else {
 
4090
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
 
4091
            }
 
4092
        } else {
 
4093
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
 
4094
        }
 
4095
        #endif
 
4096
        if (!*t->p)
 
4097
            return -1;
 
4098
        ++t;
 
4099
    }
 
4100
    return 0;
 
4101
}
 
4102
 
 
4103
/* Type Conversion Functions */
 
4104
 
 
4105
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
 
4106
   int is_true = x == Py_True;
 
4107
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
 
4108
   else return PyObject_IsTrue(x);
 
4109
}
 
4110
 
 
4111
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
 
4112
  PyNumberMethods *m;
 
4113
  const char *name = NULL;
 
4114
  PyObject *res = NULL;
 
4115
#if PY_VERSION_HEX < 0x03000000
 
4116
  if (PyInt_Check(x) || PyLong_Check(x))
 
4117
#else
 
4118
  if (PyLong_Check(x))
 
4119
#endif
 
4120
    return Py_INCREF(x), x;
 
4121
  m = Py_TYPE(x)->tp_as_number;
 
4122
#if PY_VERSION_HEX < 0x03000000
 
4123
  if (m && m->nb_int) {
 
4124
    name = "int";
 
4125
    res = PyNumber_Int(x);
 
4126
  }
 
4127
  else if (m && m->nb_long) {
 
4128
    name = "long";
 
4129
    res = PyNumber_Long(x);
 
4130
  }
 
4131
#else
 
4132
  if (m && m->nb_int) {
 
4133
    name = "int";
 
4134
    res = PyNumber_Long(x);
 
4135
  }
 
4136
#endif
 
4137
  if (res) {
 
4138
#if PY_VERSION_HEX < 0x03000000
 
4139
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
 
4140
#else
 
4141
    if (!PyLong_Check(res)) {
 
4142
#endif
 
4143
      PyErr_Format(PyExc_TypeError,
 
4144
                   "__%s__ returned non-%s (type %.200s)",
 
4145
                   name, name, Py_TYPE(res)->tp_name);
 
4146
      Py_DECREF(res);
 
4147
      return NULL;
 
4148
    }
 
4149
  }
 
4150
  else if (!PyErr_Occurred()) {
 
4151
    PyErr_SetString(PyExc_TypeError,
 
4152
                    "an integer is required");
 
4153
  }
 
4154
  return res;
 
4155
}
 
4156
 
 
4157
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
 
4158
  Py_ssize_t ival;
 
4159
  PyObject* x = PyNumber_Index(b);
 
4160
  if (!x) return -1;
 
4161
  ival = PyInt_AsSsize_t(x);
 
4162
  Py_DECREF(x);
 
4163
  return ival;
 
4164
}
 
4165
 
 
4166
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
 
4167
#if PY_VERSION_HEX < 0x02050000
 
4168
   if (ival <= LONG_MAX)
 
4169
       return PyInt_FromLong((long)ival);
 
4170
   else {
 
4171
       unsigned char *bytes = (unsigned char *) &ival;
 
4172
       int one = 1; int little = (int)*(unsigned char*)&one;
 
4173
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
 
4174
   }
 
4175
#else
 
4176
   return PyInt_FromSize_t(ival);
 
4177
#endif
 
4178
}
 
4179
 
 
4180
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
 
4181
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
 
4182
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
 
4183
       return (size_t)-1;
 
4184
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
 
4185
       PyErr_SetString(PyExc_OverflowError,
 
4186
                       "value too large to convert to size_t");
 
4187
       return (size_t)-1;
 
4188
   }
 
4189
   return (size_t)val;
 
4190
}
 
4191
 
 
4192
 
 
4193
#endif /* Py_PYTHON_H */