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

« back to all changes in this revision

Viewing changes to bzrlib/_known_graph_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:27 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___known_graph_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
  "_known_graph_pyx.pyx",
 
303
};
 
304
 
 
305
/* Type declarations */
 
306
 
 
307
/* "bzrlib/_known_graph_pyx.pyx":666
 
308
 * 
 
309
 * 
 
310
 * cdef class _MergeSortNode:             # <<<<<<<<<<<<<<
 
311
 *     """Tracks information about a node during the merge_sort operation."""
 
312
 * 
 
313
 */
 
314
 
 
315
struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode {
 
316
  PyObject_HEAD
 
317
  struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_vtab;
 
318
  PyObject *key;
 
319
  long merge_depth;
 
320
  PyObject *end_of_merge;
 
321
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *left_parent;
 
322
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *left_pending_parent;
 
323
  PyObject *pending_parents;
 
324
  long _revno_first;
 
325
  long _revno_second;
 
326
  long _revno_last;
 
327
  int is_first_child;
 
328
  int seen_by_child;
 
329
  int completed;
 
330
};
 
331
 
 
332
/* "bzrlib/_known_graph_pyx.pyx":192
 
333
 * cdef class _MergeSorter
 
334
 * 
 
335
 * cdef class KnownGraph:             # <<<<<<<<<<<<<<
 
336
 *     """This is a class which assumes we already know the full graph."""
 
337
 * 
 
338
 */
 
339
 
 
340
struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph {
 
341
  PyObject_HEAD
 
342
  struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx_KnownGraph *__pyx_vtab;
 
343
  PyObject *_nodes;
 
344
  PyObject *_known_heads;
 
345
  int do_cache;
 
346
};
 
347
 
 
348
/* "bzrlib/_known_graph_pyx.pyx":63
 
349
 * 
 
350
 * 
 
351
 * cdef class _KnownGraphNode:             # <<<<<<<<<<<<<<
 
352
 *     """Represents a single object in the known graph."""
 
353
 * 
 
354
 */
 
355
 
 
356
struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode {
 
357
  PyObject_HEAD
 
358
  struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_vtab;
 
359
  PyObject *key;
 
360
  PyObject *parents;
 
361
  PyObject *children;
 
362
  long gdfo;
 
363
  int seen;
 
364
  PyObject *extra;
 
365
};
 
366
 
 
367
/* "bzrlib/_known_graph_pyx.pyx":190
 
368
 * 
 
369
 * 
 
370
 * cdef class _MergeSorter             # <<<<<<<<<<<<<<
 
371
 * 
 
372
 * cdef class KnownGraph:
 
373
 */
 
374
 
 
375
struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter {
 
376
  PyObject_HEAD
 
377
  struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter *__pyx_vtab;
 
378
  struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *graph;
 
379
  PyObject *_depth_first_stack;
 
380
  Py_ssize_t _last_stack_item;
 
381
  PyObject *_revno_to_branch_count;
 
382
  PyObject *_scheduled_nodes;
 
383
};
 
384
 
 
385
 
 
386
/* "bzrlib/_known_graph_pyx.pyx":724
 
387
 * 
 
388
 * 
 
389
 * cdef class _MergeSorter:             # <<<<<<<<<<<<<<
 
390
 *     """This class does the work of computing the merge_sort ordering.
 
391
 * 
 
392
 */
 
393
 
 
394
struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter {
 
395
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *(*_get_ms_node)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *, struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *);
 
396
  PyObject *(*_push_node)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *, struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *, long);
 
397
  PyObject *(*_pop_node)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *);
 
398
  PyObject *(*_schedule_stack)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *);
 
399
  PyObject *(*topo_order)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *);
 
400
};
 
401
static struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter *__pyx_vtabptr_6bzrlib_16_known_graph_pyx__MergeSorter;
 
402
 
 
403
 
 
404
/* "bzrlib/_known_graph_pyx.pyx":63
 
405
 * 
 
406
 * 
 
407
 * cdef class _KnownGraphNode:             # <<<<<<<<<<<<<<
 
408
 *     """Represents a single object in the known graph."""
 
409
 * 
 
410
 */
 
411
 
 
412
struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__KnownGraphNode {
 
413
  PyObject *(*clear_references)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *);
 
414
};
 
415
static struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_vtabptr_6bzrlib_16_known_graph_pyx__KnownGraphNode;
 
416
 
 
417
 
 
418
/* "bzrlib/_known_graph_pyx.pyx":666
 
419
 * 
 
420
 * 
 
421
 * cdef class _MergeSortNode:             # <<<<<<<<<<<<<<
 
422
 *     """Tracks information about a node during the merge_sort operation."""
 
423
 * 
 
424
 */
 
425
 
 
426
struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSortNode {
 
427
  int (*has_pending_parents)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *);
 
428
  PyObject *(*_revno)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *);
 
429
};
 
430
static struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_vtabptr_6bzrlib_16_known_graph_pyx__MergeSortNode;
 
431
 
 
432
 
 
433
/* "bzrlib/_known_graph_pyx.pyx":192
 
434
 * cdef class _MergeSorter
 
435
 * 
 
436
 * cdef class KnownGraph:             # <<<<<<<<<<<<<<
 
437
 *     """This is a class which assumes we already know the full graph."""
 
438
 * 
 
439
 */
 
440
 
 
441
struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx_KnownGraph {
 
442
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *(*_get_or_create_node)(struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *, PyObject *);
 
443
  PyObject *(*_populate_parents)(struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *, struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *, PyObject *);
 
444
};
 
445
static struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx_KnownGraph *__pyx_vtabptr_6bzrlib_16_known_graph_pyx_KnownGraph;
 
446
 
 
447
#ifndef CYTHON_REFNANNY
 
448
  #define CYTHON_REFNANNY 0
 
449
#endif
 
450
 
 
451
#if CYTHON_REFNANNY
 
452
  typedef struct {
 
453
    void (*INCREF)(void*, PyObject*, int);
 
454
    void (*DECREF)(void*, PyObject*, int);
 
455
    void (*GOTREF)(void*, PyObject*, int);
 
456
    void (*GIVEREF)(void*, PyObject*, int);
 
457
    void* (*SetupContext)(const char*, int, const char*);
 
458
    void (*FinishContext)(void**);
 
459
  } __Pyx_RefNannyAPIStruct;
 
460
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
 
461
  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
 
462
    PyObject *m = NULL, *p = NULL;
 
463
    void *r = NULL;
 
464
    m = PyImport_ImportModule((char *)modname);
 
465
    if (!m) goto end;
 
466
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
 
467
    if (!p) goto end;
 
468
    r = PyLong_AsVoidPtr(p);
 
469
  end:
 
470
    Py_XDECREF(p);
 
471
    Py_XDECREF(m);
 
472
    return (__Pyx_RefNannyAPIStruct *)r;
 
473
  }
 
474
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
 
475
  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
 
476
  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
477
  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
478
  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
479
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
480
  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
 
481
#else
 
482
  #define __Pyx_RefNannySetupContext(name)
 
483
  #define __Pyx_RefNannyFinishContext()
 
484
  #define __Pyx_INCREF(r) Py_INCREF(r)
 
485
  #define __Pyx_DECREF(r) Py_DECREF(r)
 
486
  #define __Pyx_GOTREF(r)
 
487
  #define __Pyx_GIVEREF(r)
 
488
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
 
489
#endif /* CYTHON_REFNANNY */
 
490
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
 
491
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
 
492
 
 
493
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
 
494
 
 
495
static void __Pyx_RaiseDoubleKeywordsError(
 
496
    const char* func_name, PyObject* kw_name); /*proto*/
 
497
 
 
498
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
 
499
 
 
500
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
 
501
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
 
502
 
 
503
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
 
504
 
 
505
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 
506
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
 
507
 
 
508
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 
509
 
 
510
 
 
511
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
 
512
    PyObject *r;
 
513
    if (!j) return NULL;
 
514
    r = PyObject_GetItem(o, j);
 
515
    Py_DECREF(j);
 
516
    return r;
 
517
}
 
518
 
 
519
 
 
520
#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
 
521
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
 
522
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
 
523
 
 
524
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
 
525
    if (likely(o != Py_None)) {
 
526
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
 
527
            PyObject *r = PyList_GET_ITEM(o, i);
 
528
            Py_INCREF(r);
 
529
            return r;
 
530
        }
 
531
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
 
532
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
 
533
            Py_INCREF(r);
 
534
            return r;
 
535
        }
 
536
    }
 
537
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
 
538
}
 
539
 
 
540
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
 
541
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
 
542
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
 
543
 
 
544
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
 
545
    if (likely(o != Py_None)) {
 
546
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
 
547
            PyObject *r = PyTuple_GET_ITEM(o, i);
 
548
            Py_INCREF(r);
 
549
            return r;
 
550
        }
 
551
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
 
552
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
 
553
            Py_INCREF(r);
 
554
            return r;
 
555
        }
 
556
    }
 
557
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
 
558
}
 
559
 
 
560
 
 
561
#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
 
562
                                                    __Pyx_GetItemInt_Fast(o, i) : \
 
563
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
 
564
 
 
565
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
 
566
    PyObject *r;
 
567
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
 
568
        r = PyList_GET_ITEM(o, i);
 
569
        Py_INCREF(r);
 
570
    }
 
571
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
 
572
        r = PyTuple_GET_ITEM(o, i);
 
573
        Py_INCREF(r);
 
574
    }
 
575
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
 
576
        r = PySequence_GetItem(o, i);
 
577
    }
 
578
    else {
 
579
        r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
 
580
    }
 
581
    return r;
 
582
}
 
583
 
 
584
static CYTHON_INLINE long __Pyx_NegateNonNeg(long b) { return unlikely(b < 0) ? b : !b; }
 
585
static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
 
586
    return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
 
587
}
 
588
 
 
589
static CYTHON_INLINE PyObject* __Pyx_PyObject_Pop(PyObject* L) {
 
590
    PyObject *r, *m;
 
591
#if PY_VERSION_HEX >= 0x02040000
 
592
    if (likely(PyList_CheckExact(L))
 
593
            /* Check that both the size is positive and no reallocation shrinking needs to be done. */
 
594
            && likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
 
595
        Py_SIZE(L) -= 1;
 
596
        return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
 
597
    }
 
598
#endif
 
599
    m = __Pyx_GetAttrString(L, "pop");
 
600
    if (!m) return NULL;
 
601
    r = PyObject_CallObject(m, NULL);
 
602
    Py_DECREF(m);
 
603
    return r;
 
604
}
 
605
 
 
606
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
 
607
 
 
608
#if PY_VERSION_HEX < 0x02050000
 
609
#ifndef PyAnySet_CheckExact
 
610
 
 
611
#define PyAnySet_CheckExact(ob) \
 
612
    ((ob)->ob_type == &PySet_Type || \
 
613
     (ob)->ob_type == &PyFrozenSet_Type)
 
614
 
 
615
#define PySet_New(iterable) \
 
616
    PyObject_CallFunctionObjArgs((PyObject *)&PySet_Type, (iterable), NULL)
 
617
 
 
618
#define Pyx_PyFrozenSet_New(iterable) \
 
619
    PyObject_CallFunctionObjArgs((PyObject *)&PyFrozenSet_Type, (iterable), NULL)
 
620
 
 
621
#define PySet_Size(anyset) \
 
622
    PyObject_Size((anyset))
 
623
 
 
624
#define PySet_Contains(anyset, key) \
 
625
    PySequence_Contains((anyset), (key))
 
626
 
 
627
#define PySet_Pop(set) \
 
628
    PyObject_CallMethod(set, (char *)"pop", NULL)
 
629
 
 
630
static CYTHON_INLINE int PySet_Clear(PyObject *set) {
 
631
    PyObject *ret = PyObject_CallMethod(set, (char *)"clear", NULL);
 
632
    if (!ret) return -1;
 
633
    Py_DECREF(ret); return 0;
 
634
}
 
635
 
 
636
static CYTHON_INLINE int PySet_Discard(PyObject *set, PyObject *key) {
 
637
    PyObject *ret = PyObject_CallMethod(set, (char *)"discard", (char *)"O", key);
 
638
    if (!ret) return -1;
 
639
    Py_DECREF(ret); return 0;
 
640
}
 
641
 
 
642
static CYTHON_INLINE int PySet_Add(PyObject *set, PyObject *key) {
 
643
    PyObject *ret = PyObject_CallMethod(set, (char *)"add", (char *)"O", key);
 
644
    if (!ret) return -1;
 
645
    Py_DECREF(ret); return 0;
 
646
}
 
647
 
 
648
#endif /* PyAnySet_CheckExact (<= Py2.4) */
 
649
 
 
650
#if PY_VERSION_HEX < 0x02040000
 
651
#ifndef Py_SETOBJECT_H
 
652
#define Py_SETOBJECT_H
 
653
 
 
654
static PyTypeObject *__Pyx_PySet_Type = NULL;
 
655
static PyTypeObject *__Pyx_PyFrozenSet_Type = NULL;
 
656
 
 
657
#define PySet_Type (*__Pyx_PySet_Type)
 
658
#define PyFrozenSet_Type (*__Pyx_PyFrozenSet_Type)
 
659
 
 
660
#define PyAnySet_Check(ob) \
 
661
    (PyAnySet_CheckExact(ob) || \
 
662
     PyType_IsSubtype((ob)->ob_type, &PySet_Type) || \
 
663
     PyType_IsSubtype((ob)->ob_type, &PyFrozenSet_Type))
 
664
 
 
665
#define PyFrozenSet_CheckExact(ob) ((ob)->ob_type == &PyFrozenSet_Type)
 
666
 
 
667
static int __Pyx_Py23SetsImport(void) {
 
668
    PyObject *sets=0, *Set=0, *ImmutableSet=0;
 
669
 
 
670
    sets = PyImport_ImportModule((char *)"sets");
 
671
    if (!sets) goto bad;
 
672
    Set = PyObject_GetAttrString(sets, (char *)"Set");
 
673
    if (!Set) goto bad;
 
674
    ImmutableSet = PyObject_GetAttrString(sets, (char *)"ImmutableSet");
 
675
    if (!ImmutableSet) goto bad;
 
676
    Py_DECREF(sets);
 
677
 
 
678
    __Pyx_PySet_Type       = (PyTypeObject*) Set;
 
679
    __Pyx_PyFrozenSet_Type = (PyTypeObject*) ImmutableSet;
 
680
 
 
681
    return 0;
 
682
 
 
683
 bad:
 
684
    Py_XDECREF(sets);
 
685
    Py_XDECREF(Set);
 
686
    Py_XDECREF(ImmutableSet);
 
687
    return -1;
 
688
}
 
689
 
 
690
#else
 
691
static int __Pyx_Py23SetsImport(void) { return 0; }
 
692
#endif /* !Py_SETOBJECT_H */
 
693
#endif /* < Py2.4  */
 
694
#endif /* < Py2.5  */
 
695
 
 
696
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
 
697
 
 
698
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
 
699
 
 
700
static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
 
701
 
 
702
static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
 
703
 
 
704
static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
 
705
 
 
706
static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
 
707
 
 
708
static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
 
709
 
 
710
static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
 
711
 
 
712
static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
 
713
 
 
714
static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
 
715
 
 
716
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
 
717
 
 
718
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
 
719
 
 
720
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
 
721
 
 
722
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
 
723
 
 
724
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
 
725
 
 
726
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
 
727
 
 
728
static void __Pyx_WriteUnraisable(const char *name); /*proto*/
 
729
 
 
730
static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
 
731
 
 
732
static void __Pyx_AddTraceback(const char *funcname); /*proto*/
 
733
 
 
734
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
 
735
/* Module declarations from bzrlib._known_graph_pyx */
 
736
 
 
737
static PyTypeObject *__pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode = 0;
 
738
static PyTypeObject *__pyx_ptype_6bzrlib_16_known_graph_pyx__MergeSorter = 0;
 
739
static PyTypeObject *__pyx_ptype_6bzrlib_16_known_graph_pyx_KnownGraph = 0;
 
740
static PyTypeObject *__pyx_ptype_6bzrlib_16_known_graph_pyx__MergeSortNode = 0;
 
741
static PyObject *__pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION = 0;
 
742
static struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(PyObject *, Py_ssize_t); /*proto*/
 
743
static struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_f_6bzrlib_16_known_graph_pyx__get_tuple_node(PyObject *, Py_ssize_t); /*proto*/
 
744
static PyObject *__pyx_f_6bzrlib_16_known_graph_pyx__sort_list_nodes(PyObject *, int); /*proto*/
 
745
#define __Pyx_MODULE_NAME "bzrlib._known_graph_pyx"
 
746
static int __pyx_module_is_main_bzrlib___known_graph_pyx = 0;
 
747
 
 
748
/* Implementation of bzrlib._known_graph_pyx */
 
749
static PyObject *__pyx_builtin_TypeError;
 
750
static PyObject *__pyx_builtin_ValueError;
 
751
static PyObject *__pyx_builtin_KeyError;
 
752
static PyObject *__pyx_builtin_sorted;
 
753
static PyObject *__pyx_builtin_RuntimeError;
 
754
static char __pyx_k_1[] = "%s(%s  gdfo:%s par:%s child:%s)";
 
755
static char __pyx_k_2[] = "lst_or_tpl must be a list or tuple.";
 
756
static char __pyx_k_5[] = "parent_map should be a dict of {key:parent_keys}";
 
757
static char __pyx_k_7[] = "Parent key mismatch, existing node %s has parents of %s not %s";
 
758
static char __pyx_k_8[] = "key %s not in nodes";
 
759
static char __pyx_k_9[] = "";
 
760
static char __pyx_k_10[] = "%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)";
 
761
static char __pyx_k_11[] = "Something wrong with: %s";
 
762
static char __pyx_k_12[] = "_revno_to_branch_count";
 
763
static char __pyx_k_13[] = "ghost nodes should not be pushed onto the stack: %s";
 
764
static char __pyx_k_14[] = "Implementation of Graph algorithms when we have already loaded everything.\n";
 
765
static char __pyx_k_15[] = "bzrlib._known_graph_pyx";
 
766
static char __pyx_k__gc[] = "gc";
 
767
static char __pyx_k__key[] = "key";
 
768
static char __pyx_k__pop[] = "pop";
 
769
static char __pyx_k__gdfo[] = "gdfo";
 
770
static char __pyx_k__seen[] = "seen";
 
771
static char __pyx_k__sort[] = "sort";
 
772
static char __pyx_k__clear[] = "clear";
 
773
static char __pyx_k__deque[] = "deque";
 
774
static char __pyx_k__extra[] = "extra";
 
775
static char __pyx_k__graph[] = "graph";
 
776
static char __pyx_k___nodes[] = "_nodes";
 
777
static char __pyx_k___revno[] = "_revno";
 
778
static char __pyx_k__append[] = "append";
 
779
static char __pyx_k__bzrlib[] = "bzrlib";
 
780
static char __pyx_k__errors[] = "errors";
 
781
static char __pyx_k__extend[] = "extend";
 
782
static char __pyx_k__sorted[] = "sorted";
 
783
static char __pyx_k__get_key[] = "get_key";
 
784
static char __pyx_k__parents[] = "parents";
 
785
static char __pyx_k__popleft[] = "popleft";
 
786
static char __pyx_k__reverse[] = "reverse";
 
787
static char __pyx_k__tip_key[] = "tip_key";
 
788
static char __pyx_k__KeyError[] = "KeyError";
 
789
static char __pyx_k____main__[] = "__main__";
 
790
static char __pyx_k____name__[] = "__name__";
 
791
static char __pyx_k____test__[] = "__test__";
 
792
static char __pyx_k__children[] = "children";
 
793
static char __pyx_k__do_cache[] = "do_cache";
 
794
static char __pyx_k__revision[] = "revision";
 
795
static char __pyx_k__TypeError[] = "TypeError";
 
796
static char __pyx_k____class__[] = "__class__";
 
797
static char __pyx_k___pop_node[] = "_pop_node";
 
798
static char __pyx_k__completed[] = "completed";
 
799
static char __pyx_k__ValueError[] = "ValueError";
 
800
static char __pyx_k___find_gdfo[] = "_find_gdfo";
 
801
static char __pyx_k___find_tips[] = "_find_tips";
 
802
static char __pyx_k___push_node[] = "_push_node";
 
803
static char __pyx_k__child_keys[] = "child_keys";
 
804
static char __pyx_k__parent_map[] = "parent_map";
 
805
static char __pyx_k__topo_order[] = "topo_order";
 
806
static char __pyx_k___find_tails[] = "_find_tails";
 
807
static char __pyx_k___revno_last[] = "_revno_last";
 
808
static char __pyx_k__collections[] = "collections";
 
809
static char __pyx_k__known_graph[] = "known_graph";
 
810
static char __pyx_k__left_parent[] = "left_parent";
 
811
static char __pyx_k__merge_depth[] = "merge_depth";
 
812
static char __pyx_k__parent_keys[] = "parent_keys";
 
813
static char __pyx_k__RuntimeError[] = "RuntimeError";
 
814
static char __pyx_k___get_ms_node[] = "_get_ms_node";
 
815
static char __pyx_k___known_heads[] = "_known_heads";
 
816
static char __pyx_k___revno_first[] = "_revno_first";
 
817
static char __pyx_k__end_of_merge[] = "end_of_merge";
 
818
static char __pyx_k__NULL_REVISION[] = "NULL_REVISION";
 
819
static char __pyx_k___revno_second[] = "_revno_second";
 
820
static char __pyx_k__seen_by_child[] = "seen_by_child";
 
821
static char __pyx_k__is_first_child[] = "is_first_child";
 
822
static char __pyx_k__GraphCycleError[] = "GraphCycleError";
 
823
static char __pyx_k___schedule_stack[] = "_schedule_stack";
 
824
static char __pyx_k__pending_parents[] = "pending_parents";
 
825
static char __pyx_k___last_stack_item[] = "_last_stack_item";
 
826
static char __pyx_k___scheduled_nodes[] = "_scheduled_nodes";
 
827
static char __pyx_k__clear_references[] = "clear_references";
 
828
static char __pyx_k___initialize_nodes[] = "_initialize_nodes";
 
829
static char __pyx_k___populate_parents[] = "_populate_parents";
 
830
static char __pyx_k___depth_first_stack[] = "_depth_first_stack";
 
831
static char __pyx_k___get_or_create_node[] = "_get_or_create_node";
 
832
static char __pyx_k__has_pending_parents[] = "has_pending_parents";
 
833
static char __pyx_k__left_pending_parent[] = "left_pending_parent";
 
834
static PyObject *__pyx_kp_s_1;
 
835
static PyObject *__pyx_kp_s_10;
 
836
static PyObject *__pyx_kp_s_11;
 
837
static PyObject *__pyx_n_s_12;
 
838
static PyObject *__pyx_kp_s_13;
 
839
static PyObject *__pyx_n_s_15;
 
840
static PyObject *__pyx_kp_s_2;
 
841
static PyObject *__pyx_kp_s_5;
 
842
static PyObject *__pyx_kp_s_7;
 
843
static PyObject *__pyx_kp_s_8;
 
844
static PyObject *__pyx_kp_s_9;
 
845
static PyObject *__pyx_n_s__GraphCycleError;
 
846
static PyObject *__pyx_n_s__KeyError;
 
847
static PyObject *__pyx_n_s__NULL_REVISION;
 
848
static PyObject *__pyx_n_s__RuntimeError;
 
849
static PyObject *__pyx_n_s__TypeError;
 
850
static PyObject *__pyx_n_s__ValueError;
 
851
static PyObject *__pyx_n_s____class__;
 
852
static PyObject *__pyx_n_s____main__;
 
853
static PyObject *__pyx_n_s____name__;
 
854
static PyObject *__pyx_n_s____test__;
 
855
static PyObject *__pyx_n_s___depth_first_stack;
 
856
static PyObject *__pyx_n_s___find_gdfo;
 
857
static PyObject *__pyx_n_s___find_tails;
 
858
static PyObject *__pyx_n_s___find_tips;
 
859
static PyObject *__pyx_n_s___get_ms_node;
 
860
static PyObject *__pyx_n_s___get_or_create_node;
 
861
static PyObject *__pyx_n_s___initialize_nodes;
 
862
static PyObject *__pyx_n_s___known_heads;
 
863
static PyObject *__pyx_n_s___last_stack_item;
 
864
static PyObject *__pyx_n_s___nodes;
 
865
static PyObject *__pyx_n_s___pop_node;
 
866
static PyObject *__pyx_n_s___populate_parents;
 
867
static PyObject *__pyx_n_s___push_node;
 
868
static PyObject *__pyx_n_s___revno;
 
869
static PyObject *__pyx_n_s___revno_first;
 
870
static PyObject *__pyx_n_s___revno_last;
 
871
static PyObject *__pyx_n_s___revno_second;
 
872
static PyObject *__pyx_n_s___schedule_stack;
 
873
static PyObject *__pyx_n_s___scheduled_nodes;
 
874
static PyObject *__pyx_n_s__append;
 
875
static PyObject *__pyx_n_s__bzrlib;
 
876
static PyObject *__pyx_n_s__child_keys;
 
877
static PyObject *__pyx_n_s__children;
 
878
static PyObject *__pyx_n_s__clear;
 
879
static PyObject *__pyx_n_s__clear_references;
 
880
static PyObject *__pyx_n_s__collections;
 
881
static PyObject *__pyx_n_s__completed;
 
882
static PyObject *__pyx_n_s__deque;
 
883
static PyObject *__pyx_n_s__do_cache;
 
884
static PyObject *__pyx_n_s__end_of_merge;
 
885
static PyObject *__pyx_n_s__errors;
 
886
static PyObject *__pyx_n_s__extend;
 
887
static PyObject *__pyx_n_s__extra;
 
888
static PyObject *__pyx_n_s__gc;
 
889
static PyObject *__pyx_n_s__gdfo;
 
890
static PyObject *__pyx_n_s__get_key;
 
891
static PyObject *__pyx_n_s__graph;
 
892
static PyObject *__pyx_n_s__has_pending_parents;
 
893
static PyObject *__pyx_n_s__is_first_child;
 
894
static PyObject *__pyx_n_s__key;
 
895
static PyObject *__pyx_n_s__known_graph;
 
896
static PyObject *__pyx_n_s__left_parent;
 
897
static PyObject *__pyx_n_s__left_pending_parent;
 
898
static PyObject *__pyx_n_s__merge_depth;
 
899
static PyObject *__pyx_n_s__parent_keys;
 
900
static PyObject *__pyx_n_s__parent_map;
 
901
static PyObject *__pyx_n_s__parents;
 
902
static PyObject *__pyx_n_s__pending_parents;
 
903
static PyObject *__pyx_n_s__pop;
 
904
static PyObject *__pyx_n_s__popleft;
 
905
static PyObject *__pyx_n_s__reverse;
 
906
static PyObject *__pyx_n_s__revision;
 
907
static PyObject *__pyx_n_s__seen;
 
908
static PyObject *__pyx_n_s__seen_by_child;
 
909
static PyObject *__pyx_n_s__sort;
 
910
static PyObject *__pyx_n_s__sorted;
 
911
static PyObject *__pyx_n_s__tip_key;
 
912
static PyObject *__pyx_n_s__topo_order;
 
913
static PyObject *__pyx_int_0;
 
914
static PyObject *__pyx_int_1;
 
915
static PyObject *__pyx_k_4;
 
916
static PyObject *__pyx_k_tuple_3;
 
917
static PyObject *__pyx_k_tuple_6;
 
918
 
 
919
/* "bzrlib/_known_graph_pyx.pyx":73
 
920
 *     cdef object extra
 
921
 * 
 
922
 *     def __init__(self, key):             # <<<<<<<<<<<<<<
 
923
 *         self.key = key
 
924
 *         self.parents = None
 
925
 */
 
926
 
 
927
static int __pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
928
static int __pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
929
  PyObject *__pyx_v_key = 0;
 
930
  int __pyx_r;
 
931
  PyObject *__pyx_t_1 = NULL;
 
932
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,0};
 
933
  __Pyx_RefNannySetupContext("__init__");
 
934
  if (unlikely(__pyx_kwds)) {
 
935
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
936
    PyObject* values[1] = {0};
 
937
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
938
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
939
      case  0: break;
 
940
      default: goto __pyx_L5_argtuple_error;
 
941
    }
 
942
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
943
      case  0:
 
944
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
 
945
      if (likely(values[0])) kw_args--;
 
946
      else goto __pyx_L5_argtuple_error;
 
947
    }
 
948
    if (unlikely(kw_args > 0)) {
 
949
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
950
    }
 
951
    __pyx_v_key = values[0];
 
952
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
 
953
    goto __pyx_L5_argtuple_error;
 
954
  } else {
 
955
    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
 
956
  }
 
957
  goto __pyx_L4_argument_unpacking_done;
 
958
  __pyx_L5_argtuple_error:;
 
959
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
960
  __pyx_L3_error:;
 
961
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._KnownGraphNode.__init__");
 
962
  __Pyx_RefNannyFinishContext();
 
963
  return -1;
 
964
  __pyx_L4_argument_unpacking_done:;
 
965
 
 
966
  /* "bzrlib/_known_graph_pyx.pyx":74
 
967
 * 
 
968
 *     def __init__(self, key):
 
969
 *         self.key = key             # <<<<<<<<<<<<<<
 
970
 *         self.parents = None
 
971
 * 
 
972
 */
 
973
  __Pyx_INCREF(__pyx_v_key);
 
974
  __Pyx_GIVEREF(__pyx_v_key);
 
975
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->key);
 
976
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->key);
 
977
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->key = __pyx_v_key;
 
978
 
 
979
  /* "bzrlib/_known_graph_pyx.pyx":75
 
980
 *     def __init__(self, key):
 
981
 *         self.key = key
 
982
 *         self.parents = None             # <<<<<<<<<<<<<<
 
983
 * 
 
984
 *         self.children = []
 
985
 */
 
986
  __Pyx_INCREF(Py_None);
 
987
  __Pyx_GIVEREF(Py_None);
 
988
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents);
 
989
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents);
 
990
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents = Py_None;
 
991
 
 
992
  /* "bzrlib/_known_graph_pyx.pyx":77
 
993
 *         self.parents = None
 
994
 * 
 
995
 *         self.children = []             # <<<<<<<<<<<<<<
 
996
 *         # Greatest distance from origin
 
997
 *         self.gdfo = -1
 
998
 */
 
999
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1000
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
1001
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
 
1002
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children);
 
1003
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children);
 
1004
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children = ((PyObject *)__pyx_t_1);
 
1005
  __pyx_t_1 = 0;
 
1006
 
 
1007
  /* "bzrlib/_known_graph_pyx.pyx":79
 
1008
 *         self.children = []
 
1009
 *         # Greatest distance from origin
 
1010
 *         self.gdfo = -1             # <<<<<<<<<<<<<<
 
1011
 *         self.seen = 0
 
1012
 *         self.extra = None
 
1013
 */
 
1014
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->gdfo = -1;
 
1015
 
 
1016
  /* "bzrlib/_known_graph_pyx.pyx":80
 
1017
 *         # Greatest distance from origin
 
1018
 *         self.gdfo = -1
 
1019
 *         self.seen = 0             # <<<<<<<<<<<<<<
 
1020
 *         self.extra = None
 
1021
 * 
 
1022
 */
 
1023
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->seen = 0;
 
1024
 
 
1025
  /* "bzrlib/_known_graph_pyx.pyx":81
 
1026
 *         self.gdfo = -1
 
1027
 *         self.seen = 0
 
1028
 *         self.extra = None             # <<<<<<<<<<<<<<
 
1029
 * 
 
1030
 *     property child_keys:
 
1031
 */
 
1032
  __Pyx_INCREF(Py_None);
 
1033
  __Pyx_GIVEREF(Py_None);
 
1034
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->extra);
 
1035
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->extra);
 
1036
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->extra = Py_None;
 
1037
 
 
1038
  __pyx_r = 0;
 
1039
  goto __pyx_L0;
 
1040
  __pyx_L1_error:;
 
1041
  __Pyx_XDECREF(__pyx_t_1);
 
1042
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._KnownGraphNode.__init__");
 
1043
  __pyx_r = -1;
 
1044
  __pyx_L0:;
 
1045
  __Pyx_RefNannyFinishContext();
 
1046
  return __pyx_r;
 
1047
}
 
1048
 
 
1049
/* "bzrlib/_known_graph_pyx.pyx":84
 
1050
 * 
 
1051
 *     property child_keys:
 
1052
 *         def __get__(self):             # <<<<<<<<<<<<<<
 
1053
 *             cdef _KnownGraphNode child
 
1054
 * 
 
1055
 */
 
1056
 
 
1057
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_10child_keys___get__(PyObject *__pyx_v_self); /*proto*/
 
1058
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_10child_keys___get__(PyObject *__pyx_v_self) {
 
1059
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_child;
 
1060
  PyObject *__pyx_v_keys;
 
1061
  PyObject *__pyx_r = NULL;
 
1062
  PyObject *__pyx_t_1 = NULL;
 
1063
  Py_ssize_t __pyx_t_2;
 
1064
  PyObject *__pyx_t_3 = NULL;
 
1065
  int __pyx_t_4;
 
1066
  __Pyx_RefNannySetupContext("__get__");
 
1067
  __pyx_v_child = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
1068
  __pyx_v_keys = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
1069
 
 
1070
  /* "bzrlib/_known_graph_pyx.pyx":87
 
1071
 *             cdef _KnownGraphNode child
 
1072
 * 
 
1073
 *             keys = []             # <<<<<<<<<<<<<<
 
1074
 *             for child in self.children:
 
1075
 *                 PyList_Append(keys, child.key)
 
1076
 */
 
1077
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1078
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
1079
  __Pyx_DECREF(((PyObject *)__pyx_v_keys));
 
1080
  __pyx_v_keys = __pyx_t_1;
 
1081
  __pyx_t_1 = 0;
 
1082
 
 
1083
  /* "bzrlib/_known_graph_pyx.pyx":88
 
1084
 * 
 
1085
 *             keys = []
 
1086
 *             for child in self.children:             # <<<<<<<<<<<<<<
 
1087
 *                 PyList_Append(keys, child.key)
 
1088
 *             return keys
 
1089
 */
 
1090
  if (PyList_CheckExact(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children) || PyTuple_CheckExact(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children)) {
 
1091
    __pyx_t_2 = 0; __pyx_t_1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children; __Pyx_INCREF(__pyx_t_1);
 
1092
  } else {
 
1093
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1094
    __Pyx_GOTREF(__pyx_t_1);
 
1095
  }
 
1096
  for (;;) {
 
1097
    if (likely(PyList_CheckExact(__pyx_t_1))) {
 
1098
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
 
1099
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
 
1100
    } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
 
1101
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
 
1102
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
 
1103
    } else {
 
1104
      __pyx_t_3 = PyIter_Next(__pyx_t_1);
 
1105
      if (!__pyx_t_3) {
 
1106
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1107
        break;
 
1108
      }
 
1109
      __Pyx_GOTREF(__pyx_t_3);
 
1110
    }
 
1111
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1112
    __Pyx_DECREF(((PyObject *)__pyx_v_child));
 
1113
    __pyx_v_child = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
 
1114
    __pyx_t_3 = 0;
 
1115
 
 
1116
    /* "bzrlib/_known_graph_pyx.pyx":89
 
1117
 *             keys = []
 
1118
 *             for child in self.children:
 
1119
 *                 PyList_Append(keys, child.key)             # <<<<<<<<<<<<<<
 
1120
 *             return keys
 
1121
 * 
 
1122
 */
 
1123
    __pyx_t_3 = __pyx_v_child->key;
 
1124
    __Pyx_INCREF(__pyx_t_3);
 
1125
    __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_keys), __pyx_t_3); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1126
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
1127
  }
 
1128
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
1129
 
 
1130
  /* "bzrlib/_known_graph_pyx.pyx":90
 
1131
 *             for child in self.children:
 
1132
 *                 PyList_Append(keys, child.key)
 
1133
 *             return keys             # <<<<<<<<<<<<<<
 
1134
 * 
 
1135
 *     property parent_keys:
 
1136
 */
 
1137
  __Pyx_XDECREF(__pyx_r);
 
1138
  __Pyx_INCREF(((PyObject *)__pyx_v_keys));
 
1139
  __pyx_r = ((PyObject *)__pyx_v_keys);
 
1140
  goto __pyx_L0;
 
1141
 
 
1142
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
1143
  goto __pyx_L0;
 
1144
  __pyx_L1_error:;
 
1145
  __Pyx_XDECREF(__pyx_t_1);
 
1146
  __Pyx_XDECREF(__pyx_t_3);
 
1147
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._KnownGraphNode.child_keys.__get__");
 
1148
  __pyx_r = NULL;
 
1149
  __pyx_L0:;
 
1150
  __Pyx_DECREF((PyObject *)__pyx_v_child);
 
1151
  __Pyx_DECREF(__pyx_v_keys);
 
1152
  __Pyx_XGIVEREF(__pyx_r);
 
1153
  __Pyx_RefNannyFinishContext();
 
1154
  return __pyx_r;
 
1155
}
 
1156
 
 
1157
/* "bzrlib/_known_graph_pyx.pyx":93
 
1158
 * 
 
1159
 *     property parent_keys:
 
1160
 *         def __get__(self):             # <<<<<<<<<<<<<<
 
1161
 *             if self.parents is None:
 
1162
 *                 return None
 
1163
 */
 
1164
 
 
1165
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_11parent_keys___get__(PyObject *__pyx_v_self); /*proto*/
 
1166
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_11parent_keys___get__(PyObject *__pyx_v_self) {
 
1167
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent;
 
1168
  PyObject *__pyx_v_keys;
 
1169
  PyObject *__pyx_r = NULL;
 
1170
  int __pyx_t_1;
 
1171
  PyObject *__pyx_t_2 = NULL;
 
1172
  Py_ssize_t __pyx_t_3;
 
1173
  PyObject *__pyx_t_4 = NULL;
 
1174
  int __pyx_t_5;
 
1175
  __Pyx_RefNannySetupContext("__get__");
 
1176
  __pyx_v_parent = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
1177
  __pyx_v_keys = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
1178
 
 
1179
  /* "bzrlib/_known_graph_pyx.pyx":94
 
1180
 *     property parent_keys:
 
1181
 *         def __get__(self):
 
1182
 *             if self.parents is None:             # <<<<<<<<<<<<<<
 
1183
 *                 return None
 
1184
 * 
 
1185
 */
 
1186
  __pyx_t_1 = (((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents == Py_None);
 
1187
  if (__pyx_t_1) {
 
1188
 
 
1189
    /* "bzrlib/_known_graph_pyx.pyx":95
 
1190
 *         def __get__(self):
 
1191
 *             if self.parents is None:
 
1192
 *                 return None             # <<<<<<<<<<<<<<
 
1193
 * 
 
1194
 *             cdef _KnownGraphNode parent
 
1195
 */
 
1196
    __Pyx_XDECREF(__pyx_r);
 
1197
    __Pyx_INCREF(Py_None);
 
1198
    __pyx_r = Py_None;
 
1199
    goto __pyx_L0;
 
1200
    goto __pyx_L5;
 
1201
  }
 
1202
  __pyx_L5:;
 
1203
 
 
1204
  /* "bzrlib/_known_graph_pyx.pyx":99
 
1205
 *             cdef _KnownGraphNode parent
 
1206
 * 
 
1207
 *             keys = []             # <<<<<<<<<<<<<<
 
1208
 *             for parent in self.parents:
 
1209
 *                 PyList_Append(keys, parent.key)
 
1210
 */
 
1211
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1212
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
1213
  __Pyx_DECREF(((PyObject *)__pyx_v_keys));
 
1214
  __pyx_v_keys = __pyx_t_2;
 
1215
  __pyx_t_2 = 0;
 
1216
 
 
1217
  /* "bzrlib/_known_graph_pyx.pyx":100
 
1218
 * 
 
1219
 *             keys = []
 
1220
 *             for parent in self.parents:             # <<<<<<<<<<<<<<
 
1221
 *                 PyList_Append(keys, parent.key)
 
1222
 *             return keys
 
1223
 */
 
1224
  if (PyList_CheckExact(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents) || PyTuple_CheckExact(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents)) {
 
1225
    __pyx_t_3 = 0; __pyx_t_2 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents; __Pyx_INCREF(__pyx_t_2);
 
1226
  } else {
 
1227
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1228
    __Pyx_GOTREF(__pyx_t_2);
 
1229
  }
 
1230
  for (;;) {
 
1231
    if (likely(PyList_CheckExact(__pyx_t_2))) {
 
1232
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
 
1233
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++;
 
1234
    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
 
1235
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
 
1236
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++;
 
1237
    } else {
 
1238
      __pyx_t_4 = PyIter_Next(__pyx_t_2);
 
1239
      if (!__pyx_t_4) {
 
1240
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1241
        break;
 
1242
      }
 
1243
      __Pyx_GOTREF(__pyx_t_4);
 
1244
    }
 
1245
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1246
    __Pyx_DECREF(((PyObject *)__pyx_v_parent));
 
1247
    __pyx_v_parent = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4);
 
1248
    __pyx_t_4 = 0;
 
1249
 
 
1250
    /* "bzrlib/_known_graph_pyx.pyx":101
 
1251
 *             keys = []
 
1252
 *             for parent in self.parents:
 
1253
 *                 PyList_Append(keys, parent.key)             # <<<<<<<<<<<<<<
 
1254
 *             return keys
 
1255
 * 
 
1256
 */
 
1257
    __pyx_t_4 = __pyx_v_parent->key;
 
1258
    __Pyx_INCREF(__pyx_t_4);
 
1259
    __pyx_t_5 = PyList_Append(((PyObject *)__pyx_v_keys), __pyx_t_4); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1260
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
1261
  }
 
1262
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
1263
 
 
1264
  /* "bzrlib/_known_graph_pyx.pyx":102
 
1265
 *             for parent in self.parents:
 
1266
 *                 PyList_Append(keys, parent.key)
 
1267
 *             return keys             # <<<<<<<<<<<<<<
 
1268
 * 
 
1269
 *     cdef clear_references(self):
 
1270
 */
 
1271
  __Pyx_XDECREF(__pyx_r);
 
1272
  __Pyx_INCREF(((PyObject *)__pyx_v_keys));
 
1273
  __pyx_r = ((PyObject *)__pyx_v_keys);
 
1274
  goto __pyx_L0;
 
1275
 
 
1276
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
1277
  goto __pyx_L0;
 
1278
  __pyx_L1_error:;
 
1279
  __Pyx_XDECREF(__pyx_t_2);
 
1280
  __Pyx_XDECREF(__pyx_t_4);
 
1281
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._KnownGraphNode.parent_keys.__get__");
 
1282
  __pyx_r = NULL;
 
1283
  __pyx_L0:;
 
1284
  __Pyx_DECREF((PyObject *)__pyx_v_parent);
 
1285
  __Pyx_DECREF(__pyx_v_keys);
 
1286
  __Pyx_XGIVEREF(__pyx_r);
 
1287
  __Pyx_RefNannyFinishContext();
 
1288
  return __pyx_r;
 
1289
}
 
1290
 
 
1291
/* "bzrlib/_known_graph_pyx.pyx":104
 
1292
 *             return keys
 
1293
 * 
 
1294
 *     cdef clear_references(self):             # <<<<<<<<<<<<<<
 
1295
 *         self.parents = None
 
1296
 *         self.children = None
 
1297
 */
 
1298
 
 
1299
static  PyObject *__pyx_f_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_clear_references(struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_self) {
 
1300
  PyObject *__pyx_r = NULL;
 
1301
  __Pyx_RefNannySetupContext("clear_references");
 
1302
 
 
1303
  /* "bzrlib/_known_graph_pyx.pyx":105
 
1304
 * 
 
1305
 *     cdef clear_references(self):
 
1306
 *         self.parents = None             # <<<<<<<<<<<<<<
 
1307
 *         self.children = None
 
1308
 * 
 
1309
 */
 
1310
  __Pyx_INCREF(Py_None);
 
1311
  __Pyx_GIVEREF(Py_None);
 
1312
  __Pyx_GOTREF(__pyx_v_self->parents);
 
1313
  __Pyx_DECREF(__pyx_v_self->parents);
 
1314
  __pyx_v_self->parents = Py_None;
 
1315
 
 
1316
  /* "bzrlib/_known_graph_pyx.pyx":106
 
1317
 *     cdef clear_references(self):
 
1318
 *         self.parents = None
 
1319
 *         self.children = None             # <<<<<<<<<<<<<<
 
1320
 * 
 
1321
 *     def __repr__(self):
 
1322
 */
 
1323
  __Pyx_INCREF(Py_None);
 
1324
  __Pyx_GIVEREF(Py_None);
 
1325
  __Pyx_GOTREF(__pyx_v_self->children);
 
1326
  __Pyx_DECREF(__pyx_v_self->children);
 
1327
  __pyx_v_self->children = Py_None;
 
1328
 
 
1329
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
1330
  __Pyx_XGIVEREF(__pyx_r);
 
1331
  __Pyx_RefNannyFinishContext();
 
1332
  return __pyx_r;
 
1333
}
 
1334
 
 
1335
/* "bzrlib/_known_graph_pyx.pyx":108
 
1336
 *         self.children = None
 
1337
 * 
 
1338
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 
1339
 *         cdef _KnownGraphNode node
 
1340
 * 
 
1341
 */
 
1342
 
 
1343
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_1__repr__(PyObject *__pyx_v_self); /*proto*/
 
1344
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_1__repr__(PyObject *__pyx_v_self) {
 
1345
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
1346
  PyObject *__pyx_v_parent_keys;
 
1347
  PyObject *__pyx_v_child_keys;
 
1348
  PyObject *__pyx_r = NULL;
 
1349
  PyObject *__pyx_t_1 = NULL;
 
1350
  int __pyx_t_2;
 
1351
  Py_ssize_t __pyx_t_3;
 
1352
  PyObject *__pyx_t_4 = NULL;
 
1353
  int __pyx_t_5;
 
1354
  PyObject *__pyx_t_6 = NULL;
 
1355
  __Pyx_RefNannySetupContext("__repr__");
 
1356
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
1357
  __pyx_v_parent_keys = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
1358
  __pyx_v_child_keys = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
1359
 
 
1360
  /* "bzrlib/_known_graph_pyx.pyx":111
 
1361
 *         cdef _KnownGraphNode node
 
1362
 * 
 
1363
 *         parent_keys = []             # <<<<<<<<<<<<<<
 
1364
 *         if self.parents is not None:
 
1365
 *             for node in self.parents:
 
1366
 */
 
1367
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1368
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
1369
  __Pyx_DECREF(((PyObject *)__pyx_v_parent_keys));
 
1370
  __pyx_v_parent_keys = __pyx_t_1;
 
1371
  __pyx_t_1 = 0;
 
1372
 
 
1373
  /* "bzrlib/_known_graph_pyx.pyx":112
 
1374
 * 
 
1375
 *         parent_keys = []
 
1376
 *         if self.parents is not None:             # <<<<<<<<<<<<<<
 
1377
 *             for node in self.parents:
 
1378
 *                 parent_keys.append(node.key)
 
1379
 */
 
1380
  __pyx_t_2 = (((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents != Py_None);
 
1381
  if (__pyx_t_2) {
 
1382
 
 
1383
    /* "bzrlib/_known_graph_pyx.pyx":113
 
1384
 *         parent_keys = []
 
1385
 *         if self.parents is not None:
 
1386
 *             for node in self.parents:             # <<<<<<<<<<<<<<
 
1387
 *                 parent_keys.append(node.key)
 
1388
 *         child_keys = []
 
1389
 */
 
1390
    if (PyList_CheckExact(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents) || PyTuple_CheckExact(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents)) {
 
1391
      __pyx_t_3 = 0; __pyx_t_1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents; __Pyx_INCREF(__pyx_t_1);
 
1392
    } else {
 
1393
      __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->parents); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1394
      __Pyx_GOTREF(__pyx_t_1);
 
1395
    }
 
1396
    for (;;) {
 
1397
      if (likely(PyList_CheckExact(__pyx_t_1))) {
 
1398
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
 
1399
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++;
 
1400
      } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
 
1401
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
 
1402
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++;
 
1403
      } else {
 
1404
        __pyx_t_4 = PyIter_Next(__pyx_t_1);
 
1405
        if (!__pyx_t_4) {
 
1406
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1407
          break;
 
1408
        }
 
1409
        __Pyx_GOTREF(__pyx_t_4);
 
1410
      }
 
1411
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1412
      __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
1413
      __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4);
 
1414
      __pyx_t_4 = 0;
 
1415
 
 
1416
      /* "bzrlib/_known_graph_pyx.pyx":114
 
1417
 *         if self.parents is not None:
 
1418
 *             for node in self.parents:
 
1419
 *                 parent_keys.append(node.key)             # <<<<<<<<<<<<<<
 
1420
 *         child_keys = []
 
1421
 *         if self.children is not None:
 
1422
 */
 
1423
      if (unlikely(__pyx_v_parent_keys == Py_None)) {
 
1424
        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
 
1425
      }
 
1426
      __pyx_t_4 = __pyx_v_node->key;
 
1427
      __Pyx_INCREF(__pyx_t_4);
 
1428
      __pyx_t_5 = PyList_Append(__pyx_v_parent_keys, __pyx_t_4); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1429
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
1430
    }
 
1431
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
1432
    goto __pyx_L5;
 
1433
  }
 
1434
  __pyx_L5:;
 
1435
 
 
1436
  /* "bzrlib/_known_graph_pyx.pyx":115
 
1437
 *             for node in self.parents:
 
1438
 *                 parent_keys.append(node.key)
 
1439
 *         child_keys = []             # <<<<<<<<<<<<<<
 
1440
 *         if self.children is not None:
 
1441
 *             for node in self.children:
 
1442
 */
 
1443
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1444
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
1445
  __Pyx_DECREF(((PyObject *)__pyx_v_child_keys));
 
1446
  __pyx_v_child_keys = __pyx_t_1;
 
1447
  __pyx_t_1 = 0;
 
1448
 
 
1449
  /* "bzrlib/_known_graph_pyx.pyx":116
 
1450
 *                 parent_keys.append(node.key)
 
1451
 *         child_keys = []
 
1452
 *         if self.children is not None:             # <<<<<<<<<<<<<<
 
1453
 *             for node in self.children:
 
1454
 *                 child_keys.append(node.key)
 
1455
 */
 
1456
  __pyx_t_2 = (((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children != Py_None);
 
1457
  if (__pyx_t_2) {
 
1458
 
 
1459
    /* "bzrlib/_known_graph_pyx.pyx":117
 
1460
 *         child_keys = []
 
1461
 *         if self.children is not None:
 
1462
 *             for node in self.children:             # <<<<<<<<<<<<<<
 
1463
 *                 child_keys.append(node.key)
 
1464
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (
 
1465
 */
 
1466
    if (PyList_CheckExact(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children) || PyTuple_CheckExact(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children)) {
 
1467
      __pyx_t_3 = 0; __pyx_t_1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children; __Pyx_INCREF(__pyx_t_1);
 
1468
    } else {
 
1469
      __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->children); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1470
      __Pyx_GOTREF(__pyx_t_1);
 
1471
    }
 
1472
    for (;;) {
 
1473
      if (likely(PyList_CheckExact(__pyx_t_1))) {
 
1474
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
 
1475
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++;
 
1476
      } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
 
1477
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
 
1478
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++;
 
1479
      } else {
 
1480
        __pyx_t_4 = PyIter_Next(__pyx_t_1);
 
1481
        if (!__pyx_t_4) {
 
1482
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1483
          break;
 
1484
        }
 
1485
        __Pyx_GOTREF(__pyx_t_4);
 
1486
      }
 
1487
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1488
      __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
1489
      __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4);
 
1490
      __pyx_t_4 = 0;
 
1491
 
 
1492
      /* "bzrlib/_known_graph_pyx.pyx":118
 
1493
 *         if self.children is not None:
 
1494
 *             for node in self.children:
 
1495
 *                 child_keys.append(node.key)             # <<<<<<<<<<<<<<
 
1496
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (
 
1497
 *             self.__class__.__name__, self.key, self.gdfo,
 
1498
 */
 
1499
      if (unlikely(__pyx_v_child_keys == Py_None)) {
 
1500
        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
 
1501
      }
 
1502
      __pyx_t_4 = __pyx_v_node->key;
 
1503
      __Pyx_INCREF(__pyx_t_4);
 
1504
      __pyx_t_5 = PyList_Append(__pyx_v_child_keys, __pyx_t_4); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1505
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
1506
    }
 
1507
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
1508
    goto __pyx_L8;
 
1509
  }
 
1510
  __pyx_L8:;
 
1511
 
 
1512
  /* "bzrlib/_known_graph_pyx.pyx":119
 
1513
 *             for node in self.children:
 
1514
 *                 child_keys.append(node.key)
 
1515
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (             # <<<<<<<<<<<<<<
 
1516
 *             self.__class__.__name__, self.key, self.gdfo,
 
1517
 *             parent_keys, child_keys)
 
1518
 */
 
1519
  __Pyx_XDECREF(__pyx_r);
 
1520
 
 
1521
  /* "bzrlib/_known_graph_pyx.pyx":120
 
1522
 *                 child_keys.append(node.key)
 
1523
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (
 
1524
 *             self.__class__.__name__, self.key, self.gdfo,             # <<<<<<<<<<<<<<
 
1525
 *             parent_keys, child_keys)
 
1526
 * 
 
1527
 */
 
1528
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1529
  __Pyx_GOTREF(__pyx_t_1);
 
1530
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____name__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1531
  __Pyx_GOTREF(__pyx_t_4);
 
1532
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
1533
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->gdfo); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1534
  __Pyx_GOTREF(__pyx_t_1);
 
1535
 
 
1536
  /* "bzrlib/_known_graph_pyx.pyx":121
 
1537
 *         return '%s(%s  gdfo:%s par:%s child:%s)' % (
 
1538
 *             self.__class__.__name__, self.key, self.gdfo,
 
1539
 *             parent_keys, child_keys)             # <<<<<<<<<<<<<<
 
1540
 * 
 
1541
 * 
 
1542
 */
 
1543
  __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1544
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
 
1545
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
 
1546
  __Pyx_GIVEREF(__pyx_t_4);
 
1547
  __Pyx_INCREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->key);
 
1548
  PyTuple_SET_ITEM(__pyx_t_6, 1, ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->key);
 
1549
  __Pyx_GIVEREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->key);
 
1550
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
 
1551
  __Pyx_GIVEREF(__pyx_t_1);
 
1552
  __Pyx_INCREF(((PyObject *)__pyx_v_parent_keys));
 
1553
  PyTuple_SET_ITEM(__pyx_t_6, 3, ((PyObject *)__pyx_v_parent_keys));
 
1554
  __Pyx_GIVEREF(((PyObject *)__pyx_v_parent_keys));
 
1555
  __Pyx_INCREF(((PyObject *)__pyx_v_child_keys));
 
1556
  PyTuple_SET_ITEM(__pyx_t_6, 4, ((PyObject *)__pyx_v_child_keys));
 
1557
  __Pyx_GIVEREF(((PyObject *)__pyx_v_child_keys));
 
1558
  __pyx_t_4 = 0;
 
1559
  __pyx_t_1 = 0;
 
1560
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1561
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
1562
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
 
1563
  __pyx_r = ((PyObject *)__pyx_t_1);
 
1564
  __pyx_t_1 = 0;
 
1565
  goto __pyx_L0;
 
1566
 
 
1567
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
1568
  goto __pyx_L0;
 
1569
  __pyx_L1_error:;
 
1570
  __Pyx_XDECREF(__pyx_t_1);
 
1571
  __Pyx_XDECREF(__pyx_t_4);
 
1572
  __Pyx_XDECREF(__pyx_t_6);
 
1573
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._KnownGraphNode.__repr__");
 
1574
  __pyx_r = NULL;
 
1575
  __pyx_L0:;
 
1576
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
1577
  __Pyx_DECREF(__pyx_v_parent_keys);
 
1578
  __Pyx_DECREF(__pyx_v_child_keys);
 
1579
  __Pyx_XGIVEREF(__pyx_r);
 
1580
  __Pyx_RefNannyFinishContext();
 
1581
  return __pyx_r;
 
1582
}
 
1583
 
 
1584
/* "bzrlib/_known_graph_pyx.pyx":69
 
1585
 *     cdef object parents
 
1586
 *     cdef object children
 
1587
 *     cdef public long gdfo             # <<<<<<<<<<<<<<
 
1588
 *     cdef int seen
 
1589
 *     cdef object extra
 
1590
 */
 
1591
 
 
1592
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_4gdfo___get__(PyObject *__pyx_v_self); /*proto*/
 
1593
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_4gdfo___get__(PyObject *__pyx_v_self) {
 
1594
  PyObject *__pyx_r = NULL;
 
1595
  PyObject *__pyx_t_1 = NULL;
 
1596
  __Pyx_RefNannySetupContext("__get__");
 
1597
  __Pyx_XDECREF(__pyx_r);
 
1598
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->gdfo); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1599
  __Pyx_GOTREF(__pyx_t_1);
 
1600
  __pyx_r = __pyx_t_1;
 
1601
  __pyx_t_1 = 0;
 
1602
  goto __pyx_L0;
 
1603
 
 
1604
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
1605
  goto __pyx_L0;
 
1606
  __pyx_L1_error:;
 
1607
  __Pyx_XDECREF(__pyx_t_1);
 
1608
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._KnownGraphNode.gdfo.__get__");
 
1609
  __pyx_r = NULL;
 
1610
  __pyx_L0:;
 
1611
  __Pyx_XGIVEREF(__pyx_r);
 
1612
  __Pyx_RefNannyFinishContext();
 
1613
  return __pyx_r;
 
1614
}
 
1615
 
 
1616
static int __pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_4gdfo_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
 
1617
static int __pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_4gdfo_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
 
1618
  int __pyx_r;
 
1619
  long __pyx_t_1;
 
1620
  __Pyx_RefNannySetupContext("__set__");
 
1621
  __pyx_t_1 = __Pyx_PyInt_AsLong(__pyx_v_value); if (unlikely((__pyx_t_1 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1622
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_self)->gdfo = __pyx_t_1;
 
1623
 
 
1624
  __pyx_r = 0;
 
1625
  goto __pyx_L0;
 
1626
  __pyx_L1_error:;
 
1627
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._KnownGraphNode.gdfo.__set__");
 
1628
  __pyx_r = -1;
 
1629
  __pyx_L0:;
 
1630
  __Pyx_RefNannyFinishContext();
 
1631
  return __pyx_r;
 
1632
}
 
1633
 
 
1634
/* "bzrlib/_known_graph_pyx.pyx":124
 
1635
 * 
 
1636
 * 
 
1637
 * cdef _KnownGraphNode _get_list_node(lst, Py_ssize_t pos):             # <<<<<<<<<<<<<<
 
1638
 *     cdef PyObject *temp_node
 
1639
 * 
 
1640
 */
 
1641
 
 
1642
static  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(PyObject *__pyx_v_lst, Py_ssize_t __pyx_v_pos) {
 
1643
  PyObject *__pyx_v_temp_node;
 
1644
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_r = NULL;
 
1645
  __Pyx_RefNannySetupContext("_get_list_node");
 
1646
 
 
1647
  /* "bzrlib/_known_graph_pyx.pyx":127
 
1648
 *     cdef PyObject *temp_node
 
1649
 * 
 
1650
 *     temp_node = PyList_GET_ITEM(lst, pos)             # <<<<<<<<<<<<<<
 
1651
 *     return <_KnownGraphNode>temp_node
 
1652
 * 
 
1653
 */
 
1654
  __pyx_v_temp_node = PyList_GET_ITEM(__pyx_v_lst, __pyx_v_pos);
 
1655
 
 
1656
  /* "bzrlib/_known_graph_pyx.pyx":128
 
1657
 * 
 
1658
 *     temp_node = PyList_GET_ITEM(lst, pos)
 
1659
 *     return <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 
1660
 * 
 
1661
 * 
 
1662
 */
 
1663
  __Pyx_XDECREF(((PyObject *)__pyx_r));
 
1664
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node)));
 
1665
  __pyx_r = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node);
 
1666
  goto __pyx_L0;
 
1667
 
 
1668
  __pyx_r = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
1669
  __pyx_L0:;
 
1670
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
 
1671
  __Pyx_RefNannyFinishContext();
 
1672
  return __pyx_r;
 
1673
}
 
1674
 
 
1675
/* "bzrlib/_known_graph_pyx.pyx":131
 
1676
 * 
 
1677
 * 
 
1678
 * cdef _KnownGraphNode _get_tuple_node(tpl, Py_ssize_t pos):             # <<<<<<<<<<<<<<
 
1679
 *     cdef PyObject *temp_node
 
1680
 * 
 
1681
 */
 
1682
 
 
1683
static  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_f_6bzrlib_16_known_graph_pyx__get_tuple_node(PyObject *__pyx_v_tpl, Py_ssize_t __pyx_v_pos) {
 
1684
  PyObject *__pyx_v_temp_node;
 
1685
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_r = NULL;
 
1686
  __Pyx_RefNannySetupContext("_get_tuple_node");
 
1687
 
 
1688
  /* "bzrlib/_known_graph_pyx.pyx":134
 
1689
 *     cdef PyObject *temp_node
 
1690
 * 
 
1691
 *     temp_node = PyTuple_GET_ITEM(tpl, pos)             # <<<<<<<<<<<<<<
 
1692
 *     return <_KnownGraphNode>temp_node
 
1693
 * 
 
1694
 */
 
1695
  __pyx_v_temp_node = PyTuple_GET_ITEM(__pyx_v_tpl, __pyx_v_pos);
 
1696
 
 
1697
  /* "bzrlib/_known_graph_pyx.pyx":135
 
1698
 * 
 
1699
 *     temp_node = PyTuple_GET_ITEM(tpl, pos)
 
1700
 *     return <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 
1701
 * 
 
1702
 * 
 
1703
 */
 
1704
  __Pyx_XDECREF(((PyObject *)__pyx_r));
 
1705
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node)));
 
1706
  __pyx_r = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node);
 
1707
  goto __pyx_L0;
 
1708
 
 
1709
  __pyx_r = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
1710
  __pyx_L0:;
 
1711
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
 
1712
  __Pyx_RefNannyFinishContext();
 
1713
  return __pyx_r;
 
1714
}
 
1715
 
 
1716
/* "bzrlib/_known_graph_pyx.pyx":138
 
1717
 * 
 
1718
 * 
 
1719
 * def get_key(node):             # <<<<<<<<<<<<<<
 
1720
 *     cdef _KnownGraphNode real_node
 
1721
 *     real_node = node
 
1722
 */
 
1723
 
 
1724
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_get_key(PyObject *__pyx_self, PyObject *__pyx_v_node); /*proto*/
 
1725
static PyMethodDef __pyx_mdef_6bzrlib_16_known_graph_pyx_get_key = {__Pyx_NAMESTR("get_key"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_get_key, METH_O, __Pyx_DOCSTR(0)};
 
1726
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_get_key(PyObject *__pyx_self, PyObject *__pyx_v_node) {
 
1727
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_real_node;
 
1728
  PyObject *__pyx_r = NULL;
 
1729
  __Pyx_RefNannySetupContext("get_key");
 
1730
  __pyx_self = __pyx_self;
 
1731
  __pyx_v_real_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
1732
 
 
1733
  /* "bzrlib/_known_graph_pyx.pyx":140
 
1734
 * def get_key(node):
 
1735
 *     cdef _KnownGraphNode real_node
 
1736
 *     real_node = node             # <<<<<<<<<<<<<<
 
1737
 *     return real_node.key
 
1738
 * 
 
1739
 */
 
1740
  if (!(likely(((__pyx_v_node) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_node, __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1741
  __Pyx_INCREF(__pyx_v_node);
 
1742
  __Pyx_DECREF(((PyObject *)__pyx_v_real_node));
 
1743
  __pyx_v_real_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_node);
 
1744
 
 
1745
  /* "bzrlib/_known_graph_pyx.pyx":141
 
1746
 *     cdef _KnownGraphNode real_node
 
1747
 *     real_node = node
 
1748
 *     return real_node.key             # <<<<<<<<<<<<<<
 
1749
 * 
 
1750
 * 
 
1751
 */
 
1752
  __Pyx_XDECREF(__pyx_r);
 
1753
  __Pyx_INCREF(__pyx_v_real_node->key);
 
1754
  __pyx_r = __pyx_v_real_node->key;
 
1755
  goto __pyx_L0;
 
1756
 
 
1757
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
1758
  goto __pyx_L0;
 
1759
  __pyx_L1_error:;
 
1760
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.get_key");
 
1761
  __pyx_r = NULL;
 
1762
  __pyx_L0:;
 
1763
  __Pyx_DECREF((PyObject *)__pyx_v_real_node);
 
1764
  __Pyx_XGIVEREF(__pyx_r);
 
1765
  __Pyx_RefNannyFinishContext();
 
1766
  return __pyx_r;
 
1767
}
 
1768
 
 
1769
/* "bzrlib/_known_graph_pyx.pyx":144
 
1770
 * 
 
1771
 * 
 
1772
 * cdef object _sort_list_nodes(object lst_or_tpl, int reverse):             # <<<<<<<<<<<<<<
 
1773
 *     """Sort a list of _KnownGraphNode objects.
 
1774
 * 
 
1775
 */
 
1776
 
 
1777
static  PyObject *__pyx_f_6bzrlib_16_known_graph_pyx__sort_list_nodes(PyObject *__pyx_v_lst_or_tpl, int __pyx_v_reverse) {
 
1778
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node1;
 
1779
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node2;
 
1780
  int __pyx_v_do_swap;
 
1781
  int __pyx_v_is_tuple;
 
1782
  Py_ssize_t __pyx_v_length;
 
1783
  PyObject *__pyx_r = NULL;
 
1784
  int __pyx_t_1;
 
1785
  int __pyx_t_2;
 
1786
  int __pyx_t_3;
 
1787
  PyObject *__pyx_t_4 = NULL;
 
1788
  Py_ssize_t __pyx_t_5;
 
1789
  PyObject *__pyx_t_6 = NULL;
 
1790
  PyObject *__pyx_t_7 = NULL;
 
1791
  __Pyx_RefNannySetupContext("_sort_list_nodes");
 
1792
  __Pyx_INCREF(__pyx_v_lst_or_tpl);
 
1793
  __pyx_v_node1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
1794
  __pyx_v_node2 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
1795
 
 
1796
  /* "bzrlib/_known_graph_pyx.pyx":154
 
1797
 *     cdef Py_ssize_t length
 
1798
 * 
 
1799
 *     is_tuple = PyTuple_CheckExact(lst_or_tpl)             # <<<<<<<<<<<<<<
 
1800
 *     if not (is_tuple or PyList_CheckExact(lst_or_tpl)):
 
1801
 *         raise TypeError('lst_or_tpl must be a list or tuple.')
 
1802
 */
 
1803
  __pyx_v_is_tuple = PyTuple_CheckExact(__pyx_v_lst_or_tpl);
 
1804
 
 
1805
  /* "bzrlib/_known_graph_pyx.pyx":155
 
1806
 * 
 
1807
 *     is_tuple = PyTuple_CheckExact(lst_or_tpl)
 
1808
 *     if not (is_tuple or PyList_CheckExact(lst_or_tpl)):             # <<<<<<<<<<<<<<
 
1809
 *         raise TypeError('lst_or_tpl must be a list or tuple.')
 
1810
 *     length = len(lst_or_tpl)
 
1811
 */
 
1812
  if (!__pyx_v_is_tuple) {
 
1813
    __pyx_t_1 = PyList_CheckExact(__pyx_v_lst_or_tpl);
 
1814
    __pyx_t_2 = __pyx_t_1;
 
1815
  } else {
 
1816
    __pyx_t_2 = __pyx_v_is_tuple;
 
1817
  }
 
1818
  __pyx_t_3 = (!__pyx_t_2);
 
1819
  if (__pyx_t_3) {
 
1820
 
 
1821
    /* "bzrlib/_known_graph_pyx.pyx":156
 
1822
 *     is_tuple = PyTuple_CheckExact(lst_or_tpl)
 
1823
 *     if not (is_tuple or PyList_CheckExact(lst_or_tpl)):
 
1824
 *         raise TypeError('lst_or_tpl must be a list or tuple.')             # <<<<<<<<<<<<<<
 
1825
 *     length = len(lst_or_tpl)
 
1826
 *     if length == 0 or length == 1:
 
1827
 */
 
1828
    __pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1829
    __Pyx_GOTREF(__pyx_t_4);
 
1830
    __Pyx_Raise(__pyx_t_4, 0, 0);
 
1831
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
1832
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1833
    goto __pyx_L3;
 
1834
  }
 
1835
  __pyx_L3:;
 
1836
 
 
1837
  /* "bzrlib/_known_graph_pyx.pyx":157
 
1838
 *     if not (is_tuple or PyList_CheckExact(lst_or_tpl)):
 
1839
 *         raise TypeError('lst_or_tpl must be a list or tuple.')
 
1840
 *     length = len(lst_or_tpl)             # <<<<<<<<<<<<<<
 
1841
 *     if length == 0 or length == 1:
 
1842
 *         return lst_or_tpl
 
1843
 */
 
1844
  __pyx_t_5 = PyObject_Length(__pyx_v_lst_or_tpl); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1845
  __pyx_v_length = __pyx_t_5;
 
1846
 
 
1847
  /* "bzrlib/_known_graph_pyx.pyx":158
 
1848
 *         raise TypeError('lst_or_tpl must be a list or tuple.')
 
1849
 *     length = len(lst_or_tpl)
 
1850
 *     if length == 0 or length == 1:             # <<<<<<<<<<<<<<
 
1851
 *         return lst_or_tpl
 
1852
 *     if length == 2:
 
1853
 */
 
1854
  switch (__pyx_v_length) {
 
1855
    case 0:
 
1856
    case 1:
 
1857
 
 
1858
    /* "bzrlib/_known_graph_pyx.pyx":159
 
1859
 *     length = len(lst_or_tpl)
 
1860
 *     if length == 0 or length == 1:
 
1861
 *         return lst_or_tpl             # <<<<<<<<<<<<<<
 
1862
 *     if length == 2:
 
1863
 *         if is_tuple:
 
1864
 */
 
1865
    __Pyx_XDECREF(__pyx_r);
 
1866
    __Pyx_INCREF(__pyx_v_lst_or_tpl);
 
1867
    __pyx_r = __pyx_v_lst_or_tpl;
 
1868
    goto __pyx_L0;
 
1869
    break;
 
1870
  }
 
1871
 
 
1872
  /* "bzrlib/_known_graph_pyx.pyx":160
 
1873
 *     if length == 0 or length == 1:
 
1874
 *         return lst_or_tpl
 
1875
 *     if length == 2:             # <<<<<<<<<<<<<<
 
1876
 *         if is_tuple:
 
1877
 *             node1 = _get_tuple_node(lst_or_tpl, 0)
 
1878
 */
 
1879
  __pyx_t_3 = (__pyx_v_length == 2);
 
1880
  if (__pyx_t_3) {
 
1881
 
 
1882
    /* "bzrlib/_known_graph_pyx.pyx":161
 
1883
 *         return lst_or_tpl
 
1884
 *     if length == 2:
 
1885
 *         if is_tuple:             # <<<<<<<<<<<<<<
 
1886
 *             node1 = _get_tuple_node(lst_or_tpl, 0)
 
1887
 *             node2 = _get_tuple_node(lst_or_tpl, 1)
 
1888
 */
 
1889
    if (__pyx_v_is_tuple) {
 
1890
 
 
1891
      /* "bzrlib/_known_graph_pyx.pyx":162
 
1892
 *     if length == 2:
 
1893
 *         if is_tuple:
 
1894
 *             node1 = _get_tuple_node(lst_or_tpl, 0)             # <<<<<<<<<<<<<<
 
1895
 *             node2 = _get_tuple_node(lst_or_tpl, 1)
 
1896
 *         else:
 
1897
 */
 
1898
      __pyx_t_4 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_tuple_node(__pyx_v_lst_or_tpl, 0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1899
      __Pyx_GOTREF(__pyx_t_4);
 
1900
      __Pyx_DECREF(((PyObject *)__pyx_v_node1));
 
1901
      __pyx_v_node1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4);
 
1902
      __pyx_t_4 = 0;
 
1903
 
 
1904
      /* "bzrlib/_known_graph_pyx.pyx":163
 
1905
 *         if is_tuple:
 
1906
 *             node1 = _get_tuple_node(lst_or_tpl, 0)
 
1907
 *             node2 = _get_tuple_node(lst_or_tpl, 1)             # <<<<<<<<<<<<<<
 
1908
 *         else:
 
1909
 *             node1 = _get_list_node(lst_or_tpl, 0)
 
1910
 */
 
1911
      __pyx_t_4 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_tuple_node(__pyx_v_lst_or_tpl, 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1912
      __Pyx_GOTREF(__pyx_t_4);
 
1913
      __Pyx_DECREF(((PyObject *)__pyx_v_node2));
 
1914
      __pyx_v_node2 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4);
 
1915
      __pyx_t_4 = 0;
 
1916
      goto __pyx_L5;
 
1917
    }
 
1918
    /*else*/ {
 
1919
 
 
1920
      /* "bzrlib/_known_graph_pyx.pyx":165
 
1921
 *             node2 = _get_tuple_node(lst_or_tpl, 1)
 
1922
 *         else:
 
1923
 *             node1 = _get_list_node(lst_or_tpl, 0)             # <<<<<<<<<<<<<<
 
1924
 *             node2 = _get_list_node(lst_or_tpl, 1)
 
1925
 *         if reverse:
 
1926
 */
 
1927
      __pyx_t_4 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_v_lst_or_tpl, 0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1928
      __Pyx_GOTREF(__pyx_t_4);
 
1929
      __Pyx_DECREF(((PyObject *)__pyx_v_node1));
 
1930
      __pyx_v_node1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4);
 
1931
      __pyx_t_4 = 0;
 
1932
 
 
1933
      /* "bzrlib/_known_graph_pyx.pyx":166
 
1934
 *         else:
 
1935
 *             node1 = _get_list_node(lst_or_tpl, 0)
 
1936
 *             node2 = _get_list_node(lst_or_tpl, 1)             # <<<<<<<<<<<<<<
 
1937
 *         if reverse:
 
1938
 *             do_swap = PyObject_RichCompareBool(node1.key, node2.key, Py_LT)
 
1939
 */
 
1940
      __pyx_t_4 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_v_lst_or_tpl, 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1941
      __Pyx_GOTREF(__pyx_t_4);
 
1942
      __Pyx_DECREF(((PyObject *)__pyx_v_node2));
 
1943
      __pyx_v_node2 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4);
 
1944
      __pyx_t_4 = 0;
 
1945
    }
 
1946
    __pyx_L5:;
 
1947
 
 
1948
    /* "bzrlib/_known_graph_pyx.pyx":167
 
1949
 *             node1 = _get_list_node(lst_or_tpl, 0)
 
1950
 *             node2 = _get_list_node(lst_or_tpl, 1)
 
1951
 *         if reverse:             # <<<<<<<<<<<<<<
 
1952
 *             do_swap = PyObject_RichCompareBool(node1.key, node2.key, Py_LT)
 
1953
 *         else:
 
1954
 */
 
1955
    if (__pyx_v_reverse) {
 
1956
 
 
1957
      /* "bzrlib/_known_graph_pyx.pyx":168
 
1958
 *             node2 = _get_list_node(lst_or_tpl, 1)
 
1959
 *         if reverse:
 
1960
 *             do_swap = PyObject_RichCompareBool(node1.key, node2.key, Py_LT)             # <<<<<<<<<<<<<<
 
1961
 *         else:
 
1962
 *             do_swap = PyObject_RichCompareBool(node2.key, node1.key, Py_LT)
 
1963
 */
 
1964
      __pyx_t_4 = __pyx_v_node1->key;
 
1965
      __Pyx_INCREF(__pyx_t_4);
 
1966
      __pyx_t_6 = __pyx_v_node2->key;
 
1967
      __Pyx_INCREF(__pyx_t_6);
 
1968
      __pyx_v_do_swap = PyObject_RichCompareBool(__pyx_t_4, __pyx_t_6, Py_LT);
 
1969
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
1970
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
1971
      goto __pyx_L6;
 
1972
    }
 
1973
    /*else*/ {
 
1974
 
 
1975
      /* "bzrlib/_known_graph_pyx.pyx":170
 
1976
 *             do_swap = PyObject_RichCompareBool(node1.key, node2.key, Py_LT)
 
1977
 *         else:
 
1978
 *             do_swap = PyObject_RichCompareBool(node2.key, node1.key, Py_LT)             # <<<<<<<<<<<<<<
 
1979
 *         if not do_swap:
 
1980
 *             return lst_or_tpl
 
1981
 */
 
1982
      __pyx_t_6 = __pyx_v_node2->key;
 
1983
      __Pyx_INCREF(__pyx_t_6);
 
1984
      __pyx_t_4 = __pyx_v_node1->key;
 
1985
      __Pyx_INCREF(__pyx_t_4);
 
1986
      __pyx_v_do_swap = PyObject_RichCompareBool(__pyx_t_6, __pyx_t_4, Py_LT);
 
1987
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
1988
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
1989
    }
 
1990
    __pyx_L6:;
 
1991
 
 
1992
    /* "bzrlib/_known_graph_pyx.pyx":171
 
1993
 *         else:
 
1994
 *             do_swap = PyObject_RichCompareBool(node2.key, node1.key, Py_LT)
 
1995
 *         if not do_swap:             # <<<<<<<<<<<<<<
 
1996
 *             return lst_or_tpl
 
1997
 *         if is_tuple:
 
1998
 */
 
1999
    __pyx_t_3 = (!__pyx_v_do_swap);
 
2000
    if (__pyx_t_3) {
 
2001
 
 
2002
      /* "bzrlib/_known_graph_pyx.pyx":172
 
2003
 *             do_swap = PyObject_RichCompareBool(node2.key, node1.key, Py_LT)
 
2004
 *         if not do_swap:
 
2005
 *             return lst_or_tpl             # <<<<<<<<<<<<<<
 
2006
 *         if is_tuple:
 
2007
 *             return (node2, node1)
 
2008
 */
 
2009
      __Pyx_XDECREF(__pyx_r);
 
2010
      __Pyx_INCREF(__pyx_v_lst_or_tpl);
 
2011
      __pyx_r = __pyx_v_lst_or_tpl;
 
2012
      goto __pyx_L0;
 
2013
      goto __pyx_L7;
 
2014
    }
 
2015
    __pyx_L7:;
 
2016
 
 
2017
    /* "bzrlib/_known_graph_pyx.pyx":173
 
2018
 *         if not do_swap:
 
2019
 *             return lst_or_tpl
 
2020
 *         if is_tuple:             # <<<<<<<<<<<<<<
 
2021
 *             return (node2, node1)
 
2022
 *         else:
 
2023
 */
 
2024
    if (__pyx_v_is_tuple) {
 
2025
 
 
2026
      /* "bzrlib/_known_graph_pyx.pyx":174
 
2027
 *             return lst_or_tpl
 
2028
 *         if is_tuple:
 
2029
 *             return (node2, node1)             # <<<<<<<<<<<<<<
 
2030
 *         else:
 
2031
 *             # Swap 'in-place', since lists are mutable
 
2032
 */
 
2033
      __Pyx_XDECREF(__pyx_r);
 
2034
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2035
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
 
2036
      __Pyx_INCREF(((PyObject *)__pyx_v_node2));
 
2037
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_node2));
 
2038
      __Pyx_GIVEREF(((PyObject *)__pyx_v_node2));
 
2039
      __Pyx_INCREF(((PyObject *)__pyx_v_node1));
 
2040
      PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_node1));
 
2041
      __Pyx_GIVEREF(((PyObject *)__pyx_v_node1));
 
2042
      __pyx_r = ((PyObject *)__pyx_t_4);
 
2043
      __pyx_t_4 = 0;
 
2044
      goto __pyx_L0;
 
2045
      goto __pyx_L8;
 
2046
    }
 
2047
    /*else*/ {
 
2048
 
 
2049
      /* "bzrlib/_known_graph_pyx.pyx":177
 
2050
 *         else:
 
2051
 *             # Swap 'in-place', since lists are mutable
 
2052
 *             Py_INCREF(node1)             # <<<<<<<<<<<<<<
 
2053
 *             PyList_SetItem(lst_or_tpl, 1, node1)
 
2054
 *             Py_INCREF(node2)
 
2055
 */
 
2056
      Py_INCREF(((PyObject *)__pyx_v_node1));
 
2057
 
 
2058
      /* "bzrlib/_known_graph_pyx.pyx":178
 
2059
 *             # Swap 'in-place', since lists are mutable
 
2060
 *             Py_INCREF(node1)
 
2061
 *             PyList_SetItem(lst_or_tpl, 1, node1)             # <<<<<<<<<<<<<<
 
2062
 *             Py_INCREF(node2)
 
2063
 *             PyList_SetItem(lst_or_tpl, 0, node2)
 
2064
 */
 
2065
      __pyx_t_1 = PyList_SetItem(__pyx_v_lst_or_tpl, 1, ((PyObject *)__pyx_v_node1)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2066
 
 
2067
      /* "bzrlib/_known_graph_pyx.pyx":179
 
2068
 *             Py_INCREF(node1)
 
2069
 *             PyList_SetItem(lst_or_tpl, 1, node1)
 
2070
 *             Py_INCREF(node2)             # <<<<<<<<<<<<<<
 
2071
 *             PyList_SetItem(lst_or_tpl, 0, node2)
 
2072
 *             return lst_or_tpl
 
2073
 */
 
2074
      Py_INCREF(((PyObject *)__pyx_v_node2));
 
2075
 
 
2076
      /* "bzrlib/_known_graph_pyx.pyx":180
 
2077
 *             PyList_SetItem(lst_or_tpl, 1, node1)
 
2078
 *             Py_INCREF(node2)
 
2079
 *             PyList_SetItem(lst_or_tpl, 0, node2)             # <<<<<<<<<<<<<<
 
2080
 *             return lst_or_tpl
 
2081
 *     # For all other sizes, we just use 'sorted()'
 
2082
 */
 
2083
      __pyx_t_1 = PyList_SetItem(__pyx_v_lst_or_tpl, 0, ((PyObject *)__pyx_v_node2)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2084
 
 
2085
      /* "bzrlib/_known_graph_pyx.pyx":181
 
2086
 *             Py_INCREF(node2)
 
2087
 *             PyList_SetItem(lst_or_tpl, 0, node2)
 
2088
 *             return lst_or_tpl             # <<<<<<<<<<<<<<
 
2089
 *     # For all other sizes, we just use 'sorted()'
 
2090
 *     if is_tuple:
 
2091
 */
 
2092
      __Pyx_XDECREF(__pyx_r);
 
2093
      __Pyx_INCREF(__pyx_v_lst_or_tpl);
 
2094
      __pyx_r = __pyx_v_lst_or_tpl;
 
2095
      goto __pyx_L0;
 
2096
    }
 
2097
    __pyx_L8:;
 
2098
    goto __pyx_L4;
 
2099
  }
 
2100
  __pyx_L4:;
 
2101
 
 
2102
  /* "bzrlib/_known_graph_pyx.pyx":183
 
2103
 *             return lst_or_tpl
 
2104
 *     # For all other sizes, we just use 'sorted()'
 
2105
 *     if is_tuple:             # <<<<<<<<<<<<<<
 
2106
 *         # Note that sorted() is just list(iterable).sort()
 
2107
 *         lst_or_tpl = list(lst_or_tpl)
 
2108
 */
 
2109
  if (__pyx_v_is_tuple) {
 
2110
 
 
2111
    /* "bzrlib/_known_graph_pyx.pyx":185
 
2112
 *     if is_tuple:
 
2113
 *         # Note that sorted() is just list(iterable).sort()
 
2114
 *         lst_or_tpl = list(lst_or_tpl)             # <<<<<<<<<<<<<<
 
2115
 *     lst_or_tpl.sort(key=get_key, reverse=reverse)
 
2116
 *     return lst_or_tpl
 
2117
 */
 
2118
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2119
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
 
2120
    __Pyx_INCREF(__pyx_v_lst_or_tpl);
 
2121
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_lst_or_tpl);
 
2122
    __Pyx_GIVEREF(__pyx_v_lst_or_tpl);
 
2123
    __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2124
    __Pyx_GOTREF(__pyx_t_6);
 
2125
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
 
2126
    __Pyx_DECREF(__pyx_v_lst_or_tpl);
 
2127
    __pyx_v_lst_or_tpl = __pyx_t_6;
 
2128
    __pyx_t_6 = 0;
 
2129
    goto __pyx_L9;
 
2130
  }
 
2131
  __pyx_L9:;
 
2132
 
 
2133
  /* "bzrlib/_known_graph_pyx.pyx":186
 
2134
 *         # Note that sorted() is just list(iterable).sort()
 
2135
 *         lst_or_tpl = list(lst_or_tpl)
 
2136
 *     lst_or_tpl.sort(key=get_key, reverse=reverse)             # <<<<<<<<<<<<<<
 
2137
 *     return lst_or_tpl
 
2138
 * 
 
2139
 */
 
2140
  __pyx_t_6 = PyObject_GetAttr(__pyx_v_lst_or_tpl, __pyx_n_s__sort); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2141
  __Pyx_GOTREF(__pyx_t_6);
 
2142
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2143
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
 
2144
  __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_key); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2145
  __Pyx_GOTREF(__pyx_t_7);
 
2146
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__key), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2147
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
2148
  __pyx_t_7 = PyInt_FromLong(__pyx_v_reverse); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2149
  __Pyx_GOTREF(__pyx_t_7);
 
2150
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__reverse), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2151
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
2152
  __pyx_t_7 = PyEval_CallObjectWithKeywords(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2153
  __Pyx_GOTREF(__pyx_t_7);
 
2154
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
2155
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
 
2156
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
2157
 
 
2158
  /* "bzrlib/_known_graph_pyx.pyx":187
 
2159
 *         lst_or_tpl = list(lst_or_tpl)
 
2160
 *     lst_or_tpl.sort(key=get_key, reverse=reverse)
 
2161
 *     return lst_or_tpl             # <<<<<<<<<<<<<<
 
2162
 * 
 
2163
 * 
 
2164
 */
 
2165
  __Pyx_XDECREF(__pyx_r);
 
2166
  __Pyx_INCREF(__pyx_v_lst_or_tpl);
 
2167
  __pyx_r = __pyx_v_lst_or_tpl;
 
2168
  goto __pyx_L0;
 
2169
 
 
2170
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2171
  goto __pyx_L0;
 
2172
  __pyx_L1_error:;
 
2173
  __Pyx_XDECREF(__pyx_t_4);
 
2174
  __Pyx_XDECREF(__pyx_t_6);
 
2175
  __Pyx_XDECREF(__pyx_t_7);
 
2176
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._sort_list_nodes");
 
2177
  __pyx_r = 0;
 
2178
  __pyx_L0:;
 
2179
  __Pyx_DECREF((PyObject *)__pyx_v_node1);
 
2180
  __Pyx_DECREF((PyObject *)__pyx_v_node2);
 
2181
  __Pyx_DECREF(__pyx_v_lst_or_tpl);
 
2182
  __Pyx_XGIVEREF(__pyx_r);
 
2183
  __Pyx_RefNannyFinishContext();
 
2184
  return __pyx_r;
 
2185
}
 
2186
 
 
2187
/* "bzrlib/_known_graph_pyx.pyx":199
 
2188
 *     cdef public int do_cache
 
2189
 * 
 
2190
 *     def __init__(self, parent_map, do_cache=True):             # <<<<<<<<<<<<<<
 
2191
 *         """Create a new KnownGraph instance.
 
2192
 * 
 
2193
 */
 
2194
 
 
2195
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
2196
static char __pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph___init__[] = "Create a new KnownGraph instance.\n\n        :param parent_map: A dictionary mapping key => parent_keys\n        ";
 
2197
struct wrapperbase __pyx_wrapperbase_6bzrlib_16_known_graph_pyx_10KnownGraph___init__;
 
2198
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
2199
  PyObject *__pyx_v_parent_map = 0;
 
2200
  PyObject *__pyx_v_do_cache = 0;
 
2201
  int __pyx_r;
 
2202
  PyObject *__pyx_t_1 = NULL;
 
2203
  PyObject *__pyx_t_2 = NULL;
 
2204
  int __pyx_t_3;
 
2205
  PyObject *__pyx_t_4 = NULL;
 
2206
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__parent_map,&__pyx_n_s__do_cache,0};
 
2207
  __Pyx_RefNannySetupContext("__init__");
 
2208
  if (unlikely(__pyx_kwds)) {
 
2209
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
2210
    PyObject* values[2] = {0,0};
 
2211
    values[1] = __pyx_k_4;
 
2212
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
2213
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
 
2214
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
2215
      case  0: break;
 
2216
      default: goto __pyx_L5_argtuple_error;
 
2217
    }
 
2218
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
2219
      case  0:
 
2220
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parent_map);
 
2221
      if (likely(values[0])) kw_args--;
 
2222
      else goto __pyx_L5_argtuple_error;
 
2223
      case  1:
 
2224
      if (kw_args > 0) {
 
2225
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__do_cache);
 
2226
        if (value) { values[1] = value; kw_args--; }
 
2227
      }
 
2228
    }
 
2229
    if (unlikely(kw_args > 0)) {
 
2230
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2231
    }
 
2232
    __pyx_v_parent_map = values[0];
 
2233
    __pyx_v_do_cache = values[1];
 
2234
  } else {
 
2235
    __pyx_v_do_cache = __pyx_k_4;
 
2236
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
2237
      case  2: __pyx_v_do_cache = PyTuple_GET_ITEM(__pyx_args, 1);
 
2238
      case  1: __pyx_v_parent_map = PyTuple_GET_ITEM(__pyx_args, 0);
 
2239
      break;
 
2240
      default: goto __pyx_L5_argtuple_error;
 
2241
    }
 
2242
  }
 
2243
  goto __pyx_L4_argument_unpacking_done;
 
2244
  __pyx_L5_argtuple_error:;
 
2245
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
2246
  __pyx_L3_error:;
 
2247
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.__init__");
 
2248
  __Pyx_RefNannyFinishContext();
 
2249
  return -1;
 
2250
  __pyx_L4_argument_unpacking_done:;
 
2251
 
 
2252
  /* "bzrlib/_known_graph_pyx.pyx":205
 
2253
 *         """
 
2254
 *         # tests at pre-allocating the node dict actually slowed things down
 
2255
 *         self._nodes = {}             # <<<<<<<<<<<<<<
 
2256
 *         # Maps {sorted(revision_id, revision_id): heads}
 
2257
 *         self._known_heads = {}
 
2258
 */
 
2259
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2260
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
2261
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
 
2262
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
2263
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
2264
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes = ((PyObject *)__pyx_t_1);
 
2265
  __pyx_t_1 = 0;
 
2266
 
 
2267
  /* "bzrlib/_known_graph_pyx.pyx":207
 
2268
 *         self._nodes = {}
 
2269
 *         # Maps {sorted(revision_id, revision_id): heads}
 
2270
 *         self._known_heads = {}             # <<<<<<<<<<<<<<
 
2271
 *         self.do_cache = int(do_cache)
 
2272
 *         # TODO: consider disabling gc since we are allocating a lot of nodes
 
2273
 */
 
2274
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2275
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
2276
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
 
2277
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads);
 
2278
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads);
 
2279
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads = ((PyObject *)__pyx_t_1);
 
2280
  __pyx_t_1 = 0;
 
2281
 
 
2282
  /* "bzrlib/_known_graph_pyx.pyx":208
 
2283
 *         # Maps {sorted(revision_id, revision_id): heads}
 
2284
 *         self._known_heads = {}
 
2285
 *         self.do_cache = int(do_cache)             # <<<<<<<<<<<<<<
 
2286
 *         # TODO: consider disabling gc since we are allocating a lot of nodes
 
2287
 *         #       that won't be collectable anyway. real world testing has not
 
2288
 */
 
2289
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2290
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
2291
  __Pyx_INCREF(__pyx_v_do_cache);
 
2292
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_do_cache);
 
2293
  __Pyx_GIVEREF(__pyx_v_do_cache);
 
2294
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2295
  __Pyx_GOTREF(__pyx_t_2);
 
2296
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
2297
  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2298
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
2299
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->do_cache = __pyx_t_3;
 
2300
 
 
2301
  /* "bzrlib/_known_graph_pyx.pyx":212
 
2302
 *         #       that won't be collectable anyway. real world testing has not
 
2303
 *         #       shown a specific impact, yet.
 
2304
 *         self._initialize_nodes(parent_map)             # <<<<<<<<<<<<<<
 
2305
 *         self._find_gdfo()
 
2306
 * 
 
2307
 */
 
2308
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___initialize_nodes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2309
  __Pyx_GOTREF(__pyx_t_2);
 
2310
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2311
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
2312
  __Pyx_INCREF(__pyx_v_parent_map);
 
2313
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_parent_map);
 
2314
  __Pyx_GIVEREF(__pyx_v_parent_map);
 
2315
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2316
  __Pyx_GOTREF(__pyx_t_4);
 
2317
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
2318
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
2319
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
2320
 
 
2321
  /* "bzrlib/_known_graph_pyx.pyx":213
 
2322
 *         #       shown a specific impact, yet.
 
2323
 *         self._initialize_nodes(parent_map)
 
2324
 *         self._find_gdfo()             # <<<<<<<<<<<<<<
 
2325
 * 
 
2326
 *     def __dealloc__(self):
 
2327
 */
 
2328
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___find_gdfo); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2329
  __Pyx_GOTREF(__pyx_t_4);
 
2330
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2331
  __Pyx_GOTREF(__pyx_t_1);
 
2332
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
2333
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
2334
 
 
2335
  __pyx_r = 0;
 
2336
  goto __pyx_L0;
 
2337
  __pyx_L1_error:;
 
2338
  __Pyx_XDECREF(__pyx_t_1);
 
2339
  __Pyx_XDECREF(__pyx_t_2);
 
2340
  __Pyx_XDECREF(__pyx_t_4);
 
2341
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.__init__");
 
2342
  __pyx_r = -1;
 
2343
  __pyx_L0:;
 
2344
  __Pyx_RefNannyFinishContext();
 
2345
  return __pyx_r;
 
2346
}
 
2347
 
 
2348
/* "bzrlib/_known_graph_pyx.pyx":215
 
2349
 *         self._find_gdfo()
 
2350
 * 
 
2351
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 
2352
 *         cdef _KnownGraphNode child
 
2353
 *         cdef Py_ssize_t pos
 
2354
 */
 
2355
 
 
2356
static void __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
 
2357
static void __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_1__dealloc__(PyObject *__pyx_v_self) {
 
2358
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_child;
 
2359
  Py_ssize_t __pyx_v_pos;
 
2360
  PyObject *__pyx_v_temp_node;
 
2361
  PyObject *__pyx_t_1 = NULL;
 
2362
  int __pyx_t_2;
 
2363
  __Pyx_RefNannySetupContext("__dealloc__");
 
2364
  __pyx_v_child = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
2365
 
 
2366
  /* "bzrlib/_known_graph_pyx.pyx":220
 
2367
 *         cdef PyObject *temp_node
 
2368
 * 
 
2369
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):             # <<<<<<<<<<<<<<
 
2370
 *             child = <_KnownGraphNode>temp_node
 
2371
 *             child.clear_references()
 
2372
 */
 
2373
  while (1) {
 
2374
    __pyx_t_1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes;
 
2375
    __Pyx_INCREF(__pyx_t_1);
 
2376
    __pyx_t_2 = PyDict_Next(__pyx_t_1, (&__pyx_v_pos), NULL, (&__pyx_v_temp_node));
 
2377
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
2378
    if (!__pyx_t_2) break;
 
2379
 
 
2380
    /* "bzrlib/_known_graph_pyx.pyx":221
 
2381
 * 
 
2382
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 
2383
 *             child = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 
2384
 *             child.clear_references()
 
2385
 * 
 
2386
 */
 
2387
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node)));
 
2388
    __Pyx_DECREF(((PyObject *)__pyx_v_child));
 
2389
    __pyx_v_child = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node);
 
2390
 
 
2391
    /* "bzrlib/_known_graph_pyx.pyx":222
 
2392
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 
2393
 *             child = <_KnownGraphNode>temp_node
 
2394
 *             child.clear_references()             # <<<<<<<<<<<<<<
 
2395
 * 
 
2396
 *     cdef _KnownGraphNode _get_or_create_node(self, key):
 
2397
 */
 
2398
    __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_child->__pyx_vtab)->clear_references(__pyx_v_child); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2399
    __Pyx_GOTREF(__pyx_t_1);
 
2400
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
2401
  }
 
2402
 
 
2403
  goto __pyx_L0;
 
2404
  __pyx_L1_error:;
 
2405
  __Pyx_XDECREF(__pyx_t_1);
 
2406
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.__dealloc__");
 
2407
  __pyx_L0:;
 
2408
  __Pyx_DECREF((PyObject *)__pyx_v_child);
 
2409
  __Pyx_RefNannyFinishContext();
 
2410
}
 
2411
 
 
2412
/* "bzrlib/_known_graph_pyx.pyx":224
 
2413
 *             child.clear_references()
 
2414
 * 
 
2415
 *     cdef _KnownGraphNode _get_or_create_node(self, key):             # <<<<<<<<<<<<<<
 
2416
 *         cdef PyObject *temp_node
 
2417
 *         cdef _KnownGraphNode node
 
2418
 */
 
2419
 
 
2420
static  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_f_6bzrlib_16_known_graph_pyx_10KnownGraph__get_or_create_node(struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *__pyx_v_self, PyObject *__pyx_v_key) {
 
2421
  PyObject *__pyx_v_temp_node;
 
2422
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
2423
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_r = NULL;
 
2424
  PyObject *__pyx_t_1 = NULL;
 
2425
  int __pyx_t_2;
 
2426
  PyObject *__pyx_t_3 = NULL;
 
2427
  int __pyx_t_4;
 
2428
  __Pyx_RefNannySetupContext("_get_or_create_node");
 
2429
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
2430
 
 
2431
  /* "bzrlib/_known_graph_pyx.pyx":228
 
2432
 *         cdef _KnownGraphNode node
 
2433
 * 
 
2434
 *         temp_node = PyDict_GetItem(self._nodes, key)             # <<<<<<<<<<<<<<
 
2435
 *         if temp_node == NULL:
 
2436
 *             node = _KnownGraphNode(key)
 
2437
 */
 
2438
  __pyx_t_1 = __pyx_v_self->_nodes;
 
2439
  __Pyx_INCREF(__pyx_t_1);
 
2440
  __pyx_v_temp_node = PyDict_GetItem(__pyx_t_1, __pyx_v_key);
 
2441
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
2442
 
 
2443
  /* "bzrlib/_known_graph_pyx.pyx":229
 
2444
 * 
 
2445
 *         temp_node = PyDict_GetItem(self._nodes, key)
 
2446
 *         if temp_node == NULL:             # <<<<<<<<<<<<<<
 
2447
 *             node = _KnownGraphNode(key)
 
2448
 *             PyDict_SetItem(self._nodes, key, node)
 
2449
 */
 
2450
  __pyx_t_2 = (__pyx_v_temp_node == NULL);
 
2451
  if (__pyx_t_2) {
 
2452
 
 
2453
    /* "bzrlib/_known_graph_pyx.pyx":230
 
2454
 *         temp_node = PyDict_GetItem(self._nodes, key)
 
2455
 *         if temp_node == NULL:
 
2456
 *             node = _KnownGraphNode(key)             # <<<<<<<<<<<<<<
 
2457
 *             PyDict_SetItem(self._nodes, key, node)
 
2458
 *         else:
 
2459
 */
 
2460
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2461
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
2462
    __Pyx_INCREF(__pyx_v_key);
 
2463
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_key);
 
2464
    __Pyx_GIVEREF(__pyx_v_key);
 
2465
    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2466
    __Pyx_GOTREF(__pyx_t_3);
 
2467
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
2468
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
2469
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
 
2470
    __pyx_t_3 = 0;
 
2471
 
 
2472
    /* "bzrlib/_known_graph_pyx.pyx":231
 
2473
 *         if temp_node == NULL:
 
2474
 *             node = _KnownGraphNode(key)
 
2475
 *             PyDict_SetItem(self._nodes, key, node)             # <<<<<<<<<<<<<<
 
2476
 *         else:
 
2477
 *             node = <_KnownGraphNode>temp_node
 
2478
 */
 
2479
    __pyx_t_3 = __pyx_v_self->_nodes;
 
2480
    __Pyx_INCREF(__pyx_t_3);
 
2481
    __pyx_t_4 = PyDict_SetItem(__pyx_t_3, __pyx_v_key, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2482
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
2483
    goto __pyx_L3;
 
2484
  }
 
2485
  /*else*/ {
 
2486
 
 
2487
    /* "bzrlib/_known_graph_pyx.pyx":233
 
2488
 *             PyDict_SetItem(self._nodes, key, node)
 
2489
 *         else:
 
2490
 *             node = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 
2491
 *         return node
 
2492
 * 
 
2493
 */
 
2494
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node)));
 
2495
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
2496
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node);
 
2497
  }
 
2498
  __pyx_L3:;
 
2499
 
 
2500
  /* "bzrlib/_known_graph_pyx.pyx":234
 
2501
 *         else:
 
2502
 *             node = <_KnownGraphNode>temp_node
 
2503
 *         return node             # <<<<<<<<<<<<<<
 
2504
 * 
 
2505
 *     cdef _populate_parents(self, _KnownGraphNode node, parent_keys):
 
2506
 */
 
2507
  __Pyx_XDECREF(((PyObject *)__pyx_r));
 
2508
  __Pyx_INCREF(((PyObject *)__pyx_v_node));
 
2509
  __pyx_r = __pyx_v_node;
 
2510
  goto __pyx_L0;
 
2511
 
 
2512
  __pyx_r = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
2513
  goto __pyx_L0;
 
2514
  __pyx_L1_error:;
 
2515
  __Pyx_XDECREF(__pyx_t_1);
 
2516
  __Pyx_XDECREF(__pyx_t_3);
 
2517
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph._get_or_create_node");
 
2518
  __pyx_r = 0;
 
2519
  __pyx_L0:;
 
2520
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
2521
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
 
2522
  __Pyx_RefNannyFinishContext();
 
2523
  return __pyx_r;
 
2524
}
 
2525
 
 
2526
/* "bzrlib/_known_graph_pyx.pyx":236
 
2527
 *         return node
 
2528
 * 
 
2529
 *     cdef _populate_parents(self, _KnownGraphNode node, parent_keys):             # <<<<<<<<<<<<<<
 
2530
 *         cdef Py_ssize_t num_parent_keys, pos
 
2531
 *         cdef _KnownGraphNode parent_node
 
2532
 */
 
2533
 
 
2534
static  PyObject *__pyx_f_6bzrlib_16_known_graph_pyx_10KnownGraph__populate_parents(struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *__pyx_v_self, struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node, PyObject *__pyx_v_parent_keys) {
 
2535
  Py_ssize_t __pyx_v_num_parent_keys;
 
2536
  Py_ssize_t __pyx_v_pos;
 
2537
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent_node;
 
2538
  PyObject *__pyx_v_parent_nodes;
 
2539
  PyObject *__pyx_r = NULL;
 
2540
  Py_ssize_t __pyx_t_1;
 
2541
  PyObject *__pyx_t_2 = NULL;
 
2542
  PyObject *__pyx_t_3 = NULL;
 
2543
  int __pyx_t_4;
 
2544
  __Pyx_RefNannySetupContext("_populate_parents");
 
2545
  __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
2546
  __pyx_v_parent_nodes = Py_None; __Pyx_INCREF(Py_None);
 
2547
 
 
2548
  /* "bzrlib/_known_graph_pyx.pyx":240
 
2549
 *         cdef _KnownGraphNode parent_node
 
2550
 * 
 
2551
 *         num_parent_keys = len(parent_keys)             # <<<<<<<<<<<<<<
 
2552
 *         # We know how many parents, so we pre allocate the tuple
 
2553
 *         parent_nodes = PyTuple_New(num_parent_keys)
 
2554
 */
 
2555
  __pyx_t_1 = PyObject_Length(__pyx_v_parent_keys); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2556
  __pyx_v_num_parent_keys = __pyx_t_1;
 
2557
 
 
2558
  /* "bzrlib/_known_graph_pyx.pyx":242
 
2559
 *         num_parent_keys = len(parent_keys)
 
2560
 *         # We know how many parents, so we pre allocate the tuple
 
2561
 *         parent_nodes = PyTuple_New(num_parent_keys)             # <<<<<<<<<<<<<<
 
2562
 *         for pos from 0 <= pos < num_parent_keys:
 
2563
 *             # Note: it costs us 10ms out of 40ms to lookup all of these
 
2564
 */
 
2565
  __pyx_t_2 = PyTuple_New(__pyx_v_num_parent_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2566
  __Pyx_GOTREF(__pyx_t_2);
 
2567
  __Pyx_DECREF(__pyx_v_parent_nodes);
 
2568
  __pyx_v_parent_nodes = __pyx_t_2;
 
2569
  __pyx_t_2 = 0;
 
2570
 
 
2571
  /* "bzrlib/_known_graph_pyx.pyx":243
 
2572
 *         # We know how many parents, so we pre allocate the tuple
 
2573
 *         parent_nodes = PyTuple_New(num_parent_keys)
 
2574
 *         for pos from 0 <= pos < num_parent_keys:             # <<<<<<<<<<<<<<
 
2575
 *             # Note: it costs us 10ms out of 40ms to lookup all of these
 
2576
 *             #       parents, it doesn't seem to be an allocation overhead,
 
2577
 */
 
2578
  __pyx_t_1 = __pyx_v_num_parent_keys;
 
2579
  for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_1; __pyx_v_pos++) {
 
2580
 
 
2581
    /* "bzrlib/_known_graph_pyx.pyx":251
 
2582
 *             #       node.
 
2583
 *             # We use [] because parent_keys may be a tuple or list
 
2584
 *             parent_node = self._get_or_create_node(parent_keys[pos])             # <<<<<<<<<<<<<<
 
2585
 *             # PyTuple_SET_ITEM will steal a reference, so INCREF first
 
2586
 *             Py_INCREF(parent_node)
 
2587
 */
 
2588
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_parent_keys, __pyx_v_pos, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2589
    __Pyx_GOTREF(__pyx_t_2);
 
2590
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self->__pyx_vtab)->_get_or_create_node(__pyx_v_self, __pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2591
    __Pyx_GOTREF(__pyx_t_3);
 
2592
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
2593
    __Pyx_DECREF(((PyObject *)__pyx_v_parent_node));
 
2594
    __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
 
2595
    __pyx_t_3 = 0;
 
2596
 
 
2597
    /* "bzrlib/_known_graph_pyx.pyx":253
 
2598
 *             parent_node = self._get_or_create_node(parent_keys[pos])
 
2599
 *             # PyTuple_SET_ITEM will steal a reference, so INCREF first
 
2600
 *             Py_INCREF(parent_node)             # <<<<<<<<<<<<<<
 
2601
 *             PyTuple_SET_ITEM(parent_nodes, pos, parent_node)
 
2602
 *             PyList_Append(parent_node.children, node)
 
2603
 */
 
2604
    Py_INCREF(((PyObject *)__pyx_v_parent_node));
 
2605
 
 
2606
    /* "bzrlib/_known_graph_pyx.pyx":254
 
2607
 *             # PyTuple_SET_ITEM will steal a reference, so INCREF first
 
2608
 *             Py_INCREF(parent_node)
 
2609
 *             PyTuple_SET_ITEM(parent_nodes, pos, parent_node)             # <<<<<<<<<<<<<<
 
2610
 *             PyList_Append(parent_node.children, node)
 
2611
 *         node.parents = parent_nodes
 
2612
 */
 
2613
    PyTuple_SET_ITEM(__pyx_v_parent_nodes, __pyx_v_pos, ((PyObject *)__pyx_v_parent_node));
 
2614
 
 
2615
    /* "bzrlib/_known_graph_pyx.pyx":255
 
2616
 *             Py_INCREF(parent_node)
 
2617
 *             PyTuple_SET_ITEM(parent_nodes, pos, parent_node)
 
2618
 *             PyList_Append(parent_node.children, node)             # <<<<<<<<<<<<<<
 
2619
 *         node.parents = parent_nodes
 
2620
 * 
 
2621
 */
 
2622
    __pyx_t_3 = __pyx_v_parent_node->children;
 
2623
    __Pyx_INCREF(__pyx_t_3);
 
2624
    __pyx_t_4 = PyList_Append(__pyx_t_3, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2625
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
2626
  }
 
2627
 
 
2628
  /* "bzrlib/_known_graph_pyx.pyx":256
 
2629
 *             PyTuple_SET_ITEM(parent_nodes, pos, parent_node)
 
2630
 *             PyList_Append(parent_node.children, node)
 
2631
 *         node.parents = parent_nodes             # <<<<<<<<<<<<<<
 
2632
 * 
 
2633
 *     def _initialize_nodes(self, parent_map):
 
2634
 */
 
2635
  __Pyx_INCREF(__pyx_v_parent_nodes);
 
2636
  __Pyx_GIVEREF(__pyx_v_parent_nodes);
 
2637
  __Pyx_GOTREF(__pyx_v_node->parents);
 
2638
  __Pyx_DECREF(__pyx_v_node->parents);
 
2639
  __pyx_v_node->parents = __pyx_v_parent_nodes;
 
2640
 
 
2641
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2642
  goto __pyx_L0;
 
2643
  __pyx_L1_error:;
 
2644
  __Pyx_XDECREF(__pyx_t_2);
 
2645
  __Pyx_XDECREF(__pyx_t_3);
 
2646
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph._populate_parents");
 
2647
  __pyx_r = 0;
 
2648
  __pyx_L0:;
 
2649
  __Pyx_DECREF((PyObject *)__pyx_v_parent_node);
 
2650
  __Pyx_DECREF(__pyx_v_parent_nodes);
 
2651
  __Pyx_XGIVEREF(__pyx_r);
 
2652
  __Pyx_RefNannyFinishContext();
 
2653
  return __pyx_r;
 
2654
}
 
2655
 
 
2656
/* "bzrlib/_known_graph_pyx.pyx":258
 
2657
 *         node.parents = parent_nodes
 
2658
 * 
 
2659
 *     def _initialize_nodes(self, parent_map):             # <<<<<<<<<<<<<<
 
2660
 *         """Populate self._nodes.
 
2661
 * 
 
2662
 */
 
2663
 
 
2664
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_2_initialize_nodes(PyObject *__pyx_v_self, PyObject *__pyx_v_parent_map); /*proto*/
 
2665
static char __pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_2_initialize_nodes[] = "Populate self._nodes.\n\n        After this has finished:\n        - self._nodes will have an entry for every entry in parent_map.\n        - ghosts will have a parent_keys = None,\n        - all nodes found will also have child_keys populated with all known\n          child keys,\n        ";
 
2666
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_2_initialize_nodes(PyObject *__pyx_v_self, PyObject *__pyx_v_parent_map) {
 
2667
  PyObject *__pyx_v_temp_key;
 
2668
  PyObject *__pyx_v_temp_parent_keys;
 
2669
  Py_ssize_t __pyx_v_pos;
 
2670
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
2671
  PyObject *__pyx_v_key;
 
2672
  PyObject *__pyx_v_parent_keys;
 
2673
  PyObject *__pyx_r = NULL;
 
2674
  int __pyx_t_1;
 
2675
  PyObject *__pyx_t_2 = NULL;
 
2676
  int __pyx_t_3;
 
2677
  __Pyx_RefNannySetupContext("_initialize_nodes");
 
2678
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
2679
  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
 
2680
  __pyx_v_parent_keys = Py_None; __Pyx_INCREF(Py_None);
 
2681
 
 
2682
  /* "bzrlib/_known_graph_pyx.pyx":272
 
2683
 *         cdef _KnownGraphNode parent_node
 
2684
 * 
 
2685
 *         if not PyDict_CheckExact(parent_map):             # <<<<<<<<<<<<<<
 
2686
 *             raise TypeError('parent_map should be a dict of {key:parent_keys}')
 
2687
 *         # for key, parent_keys in parent_map.iteritems():
 
2688
 */
 
2689
  __pyx_t_1 = (!PyDict_CheckExact(__pyx_v_parent_map));
 
2690
  if (__pyx_t_1) {
 
2691
 
 
2692
    /* "bzrlib/_known_graph_pyx.pyx":273
 
2693
 * 
 
2694
 *         if not PyDict_CheckExact(parent_map):
 
2695
 *             raise TypeError('parent_map should be a dict of {key:parent_keys}')             # <<<<<<<<<<<<<<
 
2696
 *         # for key, parent_keys in parent_map.iteritems():
 
2697
 *         pos = 0
 
2698
 */
 
2699
    __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2700
    __Pyx_GOTREF(__pyx_t_2);
 
2701
    __Pyx_Raise(__pyx_t_2, 0, 0);
 
2702
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
2703
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2704
    goto __pyx_L5;
 
2705
  }
 
2706
  __pyx_L5:;
 
2707
 
 
2708
  /* "bzrlib/_known_graph_pyx.pyx":275
 
2709
 *             raise TypeError('parent_map should be a dict of {key:parent_keys}')
 
2710
 *         # for key, parent_keys in parent_map.iteritems():
 
2711
 *         pos = 0             # <<<<<<<<<<<<<<
 
2712
 *         while PyDict_Next(parent_map, &pos, &temp_key, &temp_parent_keys):
 
2713
 *             key = <object>temp_key
 
2714
 */
 
2715
  __pyx_v_pos = 0;
 
2716
 
 
2717
  /* "bzrlib/_known_graph_pyx.pyx":276
 
2718
 *         # for key, parent_keys in parent_map.iteritems():
 
2719
 *         pos = 0
 
2720
 *         while PyDict_Next(parent_map, &pos, &temp_key, &temp_parent_keys):             # <<<<<<<<<<<<<<
 
2721
 *             key = <object>temp_key
 
2722
 *             parent_keys = <object>temp_parent_keys
 
2723
 */
 
2724
  while (1) {
 
2725
    __pyx_t_3 = PyDict_Next(__pyx_v_parent_map, (&__pyx_v_pos), (&__pyx_v_temp_key), (&__pyx_v_temp_parent_keys));
 
2726
    if (!__pyx_t_3) break;
 
2727
 
 
2728
    /* "bzrlib/_known_graph_pyx.pyx":277
 
2729
 *         pos = 0
 
2730
 *         while PyDict_Next(parent_map, &pos, &temp_key, &temp_parent_keys):
 
2731
 *             key = <object>temp_key             # <<<<<<<<<<<<<<
 
2732
 *             parent_keys = <object>temp_parent_keys
 
2733
 *             node = self._get_or_create_node(key)
 
2734
 */
 
2735
    __Pyx_INCREF(((PyObject *)__pyx_v_temp_key));
 
2736
    __Pyx_DECREF(__pyx_v_key);
 
2737
    __pyx_v_key = ((PyObject *)__pyx_v_temp_key);
 
2738
 
 
2739
    /* "bzrlib/_known_graph_pyx.pyx":278
 
2740
 *         while PyDict_Next(parent_map, &pos, &temp_key, &temp_parent_keys):
 
2741
 *             key = <object>temp_key
 
2742
 *             parent_keys = <object>temp_parent_keys             # <<<<<<<<<<<<<<
 
2743
 *             node = self._get_or_create_node(key)
 
2744
 *             self._populate_parents(node, parent_keys)
 
2745
 */
 
2746
    __Pyx_INCREF(((PyObject *)__pyx_v_temp_parent_keys));
 
2747
    __Pyx_DECREF(__pyx_v_parent_keys);
 
2748
    __pyx_v_parent_keys = ((PyObject *)__pyx_v_temp_parent_keys);
 
2749
 
 
2750
    /* "bzrlib/_known_graph_pyx.pyx":279
 
2751
 *             key = <object>temp_key
 
2752
 *             parent_keys = <object>temp_parent_keys
 
2753
 *             node = self._get_or_create_node(key)             # <<<<<<<<<<<<<<
 
2754
 *             self._populate_parents(node, parent_keys)
 
2755
 * 
 
2756
 */
 
2757
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx_KnownGraph *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->__pyx_vtab)->_get_or_create_node(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self), __pyx_v_key)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2758
    __Pyx_GOTREF(__pyx_t_2);
 
2759
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
2760
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_2);
 
2761
    __pyx_t_2 = 0;
 
2762
 
 
2763
    /* "bzrlib/_known_graph_pyx.pyx":280
 
2764
 *             parent_keys = <object>temp_parent_keys
 
2765
 *             node = self._get_or_create_node(key)
 
2766
 *             self._populate_parents(node, parent_keys)             # <<<<<<<<<<<<<<
 
2767
 * 
 
2768
 *     def _find_tails(self):
 
2769
 */
 
2770
    __pyx_t_2 = ((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx_KnownGraph *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->__pyx_vtab)->_populate_parents(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self), __pyx_v_node, __pyx_v_parent_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2771
    __Pyx_GOTREF(__pyx_t_2);
 
2772
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
2773
  }
 
2774
 
 
2775
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2776
  goto __pyx_L0;
 
2777
  __pyx_L1_error:;
 
2778
  __Pyx_XDECREF(__pyx_t_2);
 
2779
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph._initialize_nodes");
 
2780
  __pyx_r = NULL;
 
2781
  __pyx_L0:;
 
2782
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
2783
  __Pyx_DECREF(__pyx_v_key);
 
2784
  __Pyx_DECREF(__pyx_v_parent_keys);
 
2785
  __Pyx_XGIVEREF(__pyx_r);
 
2786
  __Pyx_RefNannyFinishContext();
 
2787
  return __pyx_r;
 
2788
}
 
2789
 
 
2790
/* "bzrlib/_known_graph_pyx.pyx":282
 
2791
 *             self._populate_parents(node, parent_keys)
 
2792
 * 
 
2793
 *     def _find_tails(self):             # <<<<<<<<<<<<<<
 
2794
 *         cdef PyObject *temp_node
 
2795
 *         cdef _KnownGraphNode node
 
2796
 */
 
2797
 
 
2798
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_3_find_tails(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
 
2799
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_3_find_tails(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
 
2800
  PyObject *__pyx_v_temp_node;
 
2801
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
2802
  Py_ssize_t __pyx_v_pos;
 
2803
  PyObject *__pyx_v_tails;
 
2804
  PyObject *__pyx_r = NULL;
 
2805
  PyObject *__pyx_t_1 = NULL;
 
2806
  int __pyx_t_2;
 
2807
  int __pyx_t_3;
 
2808
  int __pyx_t_4;
 
2809
  int __pyx_t_5;
 
2810
  __Pyx_RefNannySetupContext("_find_tails");
 
2811
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
2812
  __pyx_v_tails = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
2813
 
 
2814
  /* "bzrlib/_known_graph_pyx.pyx":287
 
2815
 *         cdef Py_ssize_t pos
 
2816
 * 
 
2817
 *         tails = []             # <<<<<<<<<<<<<<
 
2818
 *         pos = 0
 
2819
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 
2820
 */
 
2821
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2822
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
2823
  __Pyx_DECREF(((PyObject *)__pyx_v_tails));
 
2824
  __pyx_v_tails = __pyx_t_1;
 
2825
  __pyx_t_1 = 0;
 
2826
 
 
2827
  /* "bzrlib/_known_graph_pyx.pyx":288
 
2828
 * 
 
2829
 *         tails = []
 
2830
 *         pos = 0             # <<<<<<<<<<<<<<
 
2831
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 
2832
 *             node = <_KnownGraphNode>temp_node
 
2833
 */
 
2834
  __pyx_v_pos = 0;
 
2835
 
 
2836
  /* "bzrlib/_known_graph_pyx.pyx":289
 
2837
 *         tails = []
 
2838
 *         pos = 0
 
2839
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):             # <<<<<<<<<<<<<<
 
2840
 *             node = <_KnownGraphNode>temp_node
 
2841
 *             if node.parents is None or PyTuple_GET_SIZE(node.parents) == 0:
 
2842
 */
 
2843
  while (1) {
 
2844
    __pyx_t_1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes;
 
2845
    __Pyx_INCREF(__pyx_t_1);
 
2846
    __pyx_t_2 = PyDict_Next(__pyx_t_1, (&__pyx_v_pos), NULL, (&__pyx_v_temp_node));
 
2847
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
2848
    if (!__pyx_t_2) break;
 
2849
 
 
2850
    /* "bzrlib/_known_graph_pyx.pyx":290
 
2851
 *         pos = 0
 
2852
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 
2853
 *             node = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 
2854
 *             if node.parents is None or PyTuple_GET_SIZE(node.parents) == 0:
 
2855
 *                 node.gdfo = 1
 
2856
 */
 
2857
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node)));
 
2858
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
2859
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node);
 
2860
 
 
2861
    /* "bzrlib/_known_graph_pyx.pyx":291
 
2862
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 
2863
 *             node = <_KnownGraphNode>temp_node
 
2864
 *             if node.parents is None or PyTuple_GET_SIZE(node.parents) == 0:             # <<<<<<<<<<<<<<
 
2865
 *                 node.gdfo = 1
 
2866
 *                 PyList_Append(tails, node)
 
2867
 */
 
2868
    __pyx_t_3 = (__pyx_v_node->parents == Py_None);
 
2869
    if (!__pyx_t_3) {
 
2870
      __pyx_t_1 = __pyx_v_node->parents;
 
2871
      __Pyx_INCREF(__pyx_t_1);
 
2872
      __pyx_t_4 = (PyTuple_GET_SIZE(__pyx_t_1) == 0);
 
2873
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
2874
      __pyx_t_5 = __pyx_t_4;
 
2875
    } else {
 
2876
      __pyx_t_5 = __pyx_t_3;
 
2877
    }
 
2878
    if (__pyx_t_5) {
 
2879
 
 
2880
      /* "bzrlib/_known_graph_pyx.pyx":292
 
2881
 *             node = <_KnownGraphNode>temp_node
 
2882
 *             if node.parents is None or PyTuple_GET_SIZE(node.parents) == 0:
 
2883
 *                 node.gdfo = 1             # <<<<<<<<<<<<<<
 
2884
 *                 PyList_Append(tails, node)
 
2885
 *         return tails
 
2886
 */
 
2887
      __pyx_v_node->gdfo = 1;
 
2888
 
 
2889
      /* "bzrlib/_known_graph_pyx.pyx":293
 
2890
 *             if node.parents is None or PyTuple_GET_SIZE(node.parents) == 0:
 
2891
 *                 node.gdfo = 1
 
2892
 *                 PyList_Append(tails, node)             # <<<<<<<<<<<<<<
 
2893
 *         return tails
 
2894
 * 
 
2895
 */
 
2896
      __pyx_t_2 = PyList_Append(((PyObject *)__pyx_v_tails), ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2897
      goto __pyx_L7;
 
2898
    }
 
2899
    __pyx_L7:;
 
2900
  }
 
2901
 
 
2902
  /* "bzrlib/_known_graph_pyx.pyx":294
 
2903
 *                 node.gdfo = 1
 
2904
 *                 PyList_Append(tails, node)
 
2905
 *         return tails             # <<<<<<<<<<<<<<
 
2906
 * 
 
2907
 *     def _find_tips(self):
 
2908
 */
 
2909
  __Pyx_XDECREF(__pyx_r);
 
2910
  __Pyx_INCREF(((PyObject *)__pyx_v_tails));
 
2911
  __pyx_r = ((PyObject *)__pyx_v_tails);
 
2912
  goto __pyx_L0;
 
2913
 
 
2914
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2915
  goto __pyx_L0;
 
2916
  __pyx_L1_error:;
 
2917
  __Pyx_XDECREF(__pyx_t_1);
 
2918
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph._find_tails");
 
2919
  __pyx_r = NULL;
 
2920
  __pyx_L0:;
 
2921
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
2922
  __Pyx_DECREF(__pyx_v_tails);
 
2923
  __Pyx_XGIVEREF(__pyx_r);
 
2924
  __Pyx_RefNannyFinishContext();
 
2925
  return __pyx_r;
 
2926
}
 
2927
 
 
2928
/* "bzrlib/_known_graph_pyx.pyx":296
 
2929
 *         return tails
 
2930
 * 
 
2931
 *     def _find_tips(self):             # <<<<<<<<<<<<<<
 
2932
 *         cdef PyObject *temp_node
 
2933
 *         cdef _KnownGraphNode node
 
2934
 */
 
2935
 
 
2936
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_4_find_tips(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
 
2937
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_4_find_tips(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
 
2938
  PyObject *__pyx_v_temp_node;
 
2939
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
2940
  Py_ssize_t __pyx_v_pos;
 
2941
  PyObject *__pyx_v_tips;
 
2942
  PyObject *__pyx_r = NULL;
 
2943
  PyObject *__pyx_t_1 = NULL;
 
2944
  int __pyx_t_2;
 
2945
  int __pyx_t_3;
 
2946
  __Pyx_RefNannySetupContext("_find_tips");
 
2947
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
2948
  __pyx_v_tips = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
2949
 
 
2950
  /* "bzrlib/_known_graph_pyx.pyx":301
 
2951
 *         cdef Py_ssize_t pos
 
2952
 * 
 
2953
 *         tips = []             # <<<<<<<<<<<<<<
 
2954
 *         pos = 0
 
2955
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 
2956
 */
 
2957
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2958
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
2959
  __Pyx_DECREF(((PyObject *)__pyx_v_tips));
 
2960
  __pyx_v_tips = __pyx_t_1;
 
2961
  __pyx_t_1 = 0;
 
2962
 
 
2963
  /* "bzrlib/_known_graph_pyx.pyx":302
 
2964
 * 
 
2965
 *         tips = []
 
2966
 *         pos = 0             # <<<<<<<<<<<<<<
 
2967
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 
2968
 *             node = <_KnownGraphNode>temp_node
 
2969
 */
 
2970
  __pyx_v_pos = 0;
 
2971
 
 
2972
  /* "bzrlib/_known_graph_pyx.pyx":303
 
2973
 *         tips = []
 
2974
 *         pos = 0
 
2975
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):             # <<<<<<<<<<<<<<
 
2976
 *             node = <_KnownGraphNode>temp_node
 
2977
 *             if PyList_GET_SIZE(node.children) == 0:
 
2978
 */
 
2979
  while (1) {
 
2980
    __pyx_t_1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes;
 
2981
    __Pyx_INCREF(__pyx_t_1);
 
2982
    __pyx_t_2 = PyDict_Next(__pyx_t_1, (&__pyx_v_pos), NULL, (&__pyx_v_temp_node));
 
2983
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
2984
    if (!__pyx_t_2) break;
 
2985
 
 
2986
    /* "bzrlib/_known_graph_pyx.pyx":304
 
2987
 *         pos = 0
 
2988
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 
2989
 *             node = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 
2990
 *             if PyList_GET_SIZE(node.children) == 0:
 
2991
 *                 PyList_Append(tips, node)
 
2992
 */
 
2993
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node)));
 
2994
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
2995
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node);
 
2996
 
 
2997
    /* "bzrlib/_known_graph_pyx.pyx":305
 
2998
 *         while PyDict_Next(self._nodes, &pos, NULL, &temp_node):
 
2999
 *             node = <_KnownGraphNode>temp_node
 
3000
 *             if PyList_GET_SIZE(node.children) == 0:             # <<<<<<<<<<<<<<
 
3001
 *                 PyList_Append(tips, node)
 
3002
 *         return tips
 
3003
 */
 
3004
    __pyx_t_1 = __pyx_v_node->children;
 
3005
    __Pyx_INCREF(__pyx_t_1);
 
3006
    __pyx_t_3 = (PyList_GET_SIZE(__pyx_t_1) == 0);
 
3007
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3008
    if (__pyx_t_3) {
 
3009
 
 
3010
      /* "bzrlib/_known_graph_pyx.pyx":306
 
3011
 *             node = <_KnownGraphNode>temp_node
 
3012
 *             if PyList_GET_SIZE(node.children) == 0:
 
3013
 *                 PyList_Append(tips, node)             # <<<<<<<<<<<<<<
 
3014
 *         return tips
 
3015
 * 
 
3016
 */
 
3017
      __pyx_t_2 = PyList_Append(((PyObject *)__pyx_v_tips), ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3018
      goto __pyx_L7;
 
3019
    }
 
3020
    __pyx_L7:;
 
3021
  }
 
3022
 
 
3023
  /* "bzrlib/_known_graph_pyx.pyx":307
 
3024
 *             if PyList_GET_SIZE(node.children) == 0:
 
3025
 *                 PyList_Append(tips, node)
 
3026
 *         return tips             # <<<<<<<<<<<<<<
 
3027
 * 
 
3028
 *     def _find_gdfo(self):
 
3029
 */
 
3030
  __Pyx_XDECREF(__pyx_r);
 
3031
  __Pyx_INCREF(((PyObject *)__pyx_v_tips));
 
3032
  __pyx_r = ((PyObject *)__pyx_v_tips);
 
3033
  goto __pyx_L0;
 
3034
 
 
3035
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
3036
  goto __pyx_L0;
 
3037
  __pyx_L1_error:;
 
3038
  __Pyx_XDECREF(__pyx_t_1);
 
3039
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph._find_tips");
 
3040
  __pyx_r = NULL;
 
3041
  __pyx_L0:;
 
3042
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
3043
  __Pyx_DECREF(__pyx_v_tips);
 
3044
  __Pyx_XGIVEREF(__pyx_r);
 
3045
  __Pyx_RefNannyFinishContext();
 
3046
  return __pyx_r;
 
3047
}
 
3048
 
 
3049
/* "bzrlib/_known_graph_pyx.pyx":309
 
3050
 *         return tips
 
3051
 * 
 
3052
 *     def _find_gdfo(self):             # <<<<<<<<<<<<<<
 
3053
 *         cdef _KnownGraphNode node
 
3054
 *         cdef _KnownGraphNode child
 
3055
 */
 
3056
 
 
3057
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_5_find_gdfo(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
 
3058
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_5_find_gdfo(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
 
3059
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
3060
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_child;
 
3061
  Py_ssize_t __pyx_v_pos;
 
3062
  Py_ssize_t __pyx_v_last_item;
 
3063
  long __pyx_v_next_gdfo;
 
3064
  PyObject *__pyx_v_pending;
 
3065
  PyObject *__pyx_r = NULL;
 
3066
  PyObject *__pyx_t_1 = NULL;
 
3067
  PyObject *__pyx_t_2 = NULL;
 
3068
  int __pyx_t_3;
 
3069
  Py_ssize_t __pyx_t_4;
 
3070
  int __pyx_t_5;
 
3071
  __Pyx_RefNannySetupContext("_find_gdfo");
 
3072
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
3073
  __pyx_v_child = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
3074
  __pyx_v_pending = Py_None; __Pyx_INCREF(Py_None);
 
3075
 
 
3076
  /* "bzrlib/_known_graph_pyx.pyx":318
 
3077
 *         cdef long next_gdfo
 
3078
 * 
 
3079
 *         pending = self._find_tails()             # <<<<<<<<<<<<<<
 
3080
 * 
 
3081
 *         last_item = PyList_GET_SIZE(pending) - 1
 
3082
 */
 
3083
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___find_tails); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3084
  __Pyx_GOTREF(__pyx_t_1);
 
3085
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3086
  __Pyx_GOTREF(__pyx_t_2);
 
3087
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3088
  __Pyx_DECREF(__pyx_v_pending);
 
3089
  __pyx_v_pending = __pyx_t_2;
 
3090
  __pyx_t_2 = 0;
 
3091
 
 
3092
  /* "bzrlib/_known_graph_pyx.pyx":320
 
3093
 *         pending = self._find_tails()
 
3094
 * 
 
3095
 *         last_item = PyList_GET_SIZE(pending) - 1             # <<<<<<<<<<<<<<
 
3096
 *         while last_item >= 0:
 
3097
 *             # Avoid pop followed by push, instead, peek, and replace
 
3098
 */
 
3099
  __pyx_v_last_item = (PyList_GET_SIZE(__pyx_v_pending) - 1);
 
3100
 
 
3101
  /* "bzrlib/_known_graph_pyx.pyx":321
 
3102
 * 
 
3103
 *         last_item = PyList_GET_SIZE(pending) - 1
 
3104
 *         while last_item >= 0:             # <<<<<<<<<<<<<<
 
3105
 *             # Avoid pop followed by push, instead, peek, and replace
 
3106
 *             # timing shows this is 930ms => 770ms for OOo
 
3107
 */
 
3108
  while (1) {
 
3109
    __pyx_t_3 = (__pyx_v_last_item >= 0);
 
3110
    if (!__pyx_t_3) break;
 
3111
 
 
3112
    /* "bzrlib/_known_graph_pyx.pyx":324
 
3113
 *             # Avoid pop followed by push, instead, peek, and replace
 
3114
 *             # timing shows this is 930ms => 770ms for OOo
 
3115
 *             node = _get_list_node(pending, last_item)             # <<<<<<<<<<<<<<
 
3116
 *             last_item = last_item - 1
 
3117
 *             next_gdfo = node.gdfo + 1
 
3118
 */
 
3119
    __pyx_t_2 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_v_pending, __pyx_v_last_item)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3120
    __Pyx_GOTREF(__pyx_t_2);
 
3121
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
3122
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_2);
 
3123
    __pyx_t_2 = 0;
 
3124
 
 
3125
    /* "bzrlib/_known_graph_pyx.pyx":325
 
3126
 *             # timing shows this is 930ms => 770ms for OOo
 
3127
 *             node = _get_list_node(pending, last_item)
 
3128
 *             last_item = last_item - 1             # <<<<<<<<<<<<<<
 
3129
 *             next_gdfo = node.gdfo + 1
 
3130
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 
3131
 */
 
3132
    __pyx_v_last_item = (__pyx_v_last_item - 1);
 
3133
 
 
3134
    /* "bzrlib/_known_graph_pyx.pyx":326
 
3135
 *             node = _get_list_node(pending, last_item)
 
3136
 *             last_item = last_item - 1
 
3137
 *             next_gdfo = node.gdfo + 1             # <<<<<<<<<<<<<<
 
3138
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 
3139
 *                 child = _get_list_node(node.children, pos)
 
3140
 */
 
3141
    __pyx_v_next_gdfo = (__pyx_v_node->gdfo + 1);
 
3142
 
 
3143
    /* "bzrlib/_known_graph_pyx.pyx":327
 
3144
 *             last_item = last_item - 1
 
3145
 *             next_gdfo = node.gdfo + 1
 
3146
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):             # <<<<<<<<<<<<<<
 
3147
 *                 child = _get_list_node(node.children, pos)
 
3148
 *                 if next_gdfo > child.gdfo:
 
3149
 */
 
3150
    __pyx_t_2 = __pyx_v_node->children;
 
3151
    __Pyx_INCREF(__pyx_t_2);
 
3152
    __pyx_t_4 = PyList_GET_SIZE(__pyx_t_2);
 
3153
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
3154
    for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_4; __pyx_v_pos++) {
 
3155
 
 
3156
      /* "bzrlib/_known_graph_pyx.pyx":328
 
3157
 *             next_gdfo = node.gdfo + 1
 
3158
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 
3159
 *                 child = _get_list_node(node.children, pos)             # <<<<<<<<<<<<<<
 
3160
 *                 if next_gdfo > child.gdfo:
 
3161
 *                     child.gdfo = next_gdfo
 
3162
 */
 
3163
      __pyx_t_2 = __pyx_v_node->children;
 
3164
      __Pyx_INCREF(__pyx_t_2);
 
3165
      __pyx_t_1 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_t_2, __pyx_v_pos)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3166
      __Pyx_GOTREF(__pyx_t_1);
 
3167
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
3168
      __Pyx_DECREF(((PyObject *)__pyx_v_child));
 
3169
      __pyx_v_child = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
 
3170
      __pyx_t_1 = 0;
 
3171
 
 
3172
      /* "bzrlib/_known_graph_pyx.pyx":329
 
3173
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 
3174
 *                 child = _get_list_node(node.children, pos)
 
3175
 *                 if next_gdfo > child.gdfo:             # <<<<<<<<<<<<<<
 
3176
 *                     child.gdfo = next_gdfo
 
3177
 *                 child.seen = child.seen + 1
 
3178
 */
 
3179
      __pyx_t_3 = (__pyx_v_next_gdfo > __pyx_v_child->gdfo);
 
3180
      if (__pyx_t_3) {
 
3181
 
 
3182
        /* "bzrlib/_known_graph_pyx.pyx":330
 
3183
 *                 child = _get_list_node(node.children, pos)
 
3184
 *                 if next_gdfo > child.gdfo:
 
3185
 *                     child.gdfo = next_gdfo             # <<<<<<<<<<<<<<
 
3186
 *                 child.seen = child.seen + 1
 
3187
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):
 
3188
 */
 
3189
        __pyx_v_child->gdfo = __pyx_v_next_gdfo;
 
3190
        goto __pyx_L9;
 
3191
      }
 
3192
      __pyx_L9:;
 
3193
 
 
3194
      /* "bzrlib/_known_graph_pyx.pyx":331
 
3195
 *                 if next_gdfo > child.gdfo:
 
3196
 *                     child.gdfo = next_gdfo
 
3197
 *                 child.seen = child.seen + 1             # <<<<<<<<<<<<<<
 
3198
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):
 
3199
 *                     # This child is populated, queue it to be walked
 
3200
 */
 
3201
      __pyx_v_child->seen = (__pyx_v_child->seen + 1);
 
3202
 
 
3203
      /* "bzrlib/_known_graph_pyx.pyx":332
 
3204
 *                     child.gdfo = next_gdfo
 
3205
 *                 child.seen = child.seen + 1
 
3206
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):             # <<<<<<<<<<<<<<
 
3207
 *                     # This child is populated, queue it to be walked
 
3208
 *                     last_item = last_item + 1
 
3209
 */
 
3210
      __pyx_t_1 = __pyx_v_child->parents;
 
3211
      __Pyx_INCREF(__pyx_t_1);
 
3212
      __pyx_t_3 = (__pyx_v_child->seen == PyTuple_GET_SIZE(__pyx_t_1));
 
3213
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3214
      if (__pyx_t_3) {
 
3215
 
 
3216
        /* "bzrlib/_known_graph_pyx.pyx":334
 
3217
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):
 
3218
 *                     # This child is populated, queue it to be walked
 
3219
 *                     last_item = last_item + 1             # <<<<<<<<<<<<<<
 
3220
 *                     if last_item < PyList_GET_SIZE(pending):
 
3221
 *                         Py_INCREF(child) # SetItem steals a ref
 
3222
 */
 
3223
        __pyx_v_last_item = (__pyx_v_last_item + 1);
 
3224
 
 
3225
        /* "bzrlib/_known_graph_pyx.pyx":335
 
3226
 *                     # This child is populated, queue it to be walked
 
3227
 *                     last_item = last_item + 1
 
3228
 *                     if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 
3229
 *                         Py_INCREF(child) # SetItem steals a ref
 
3230
 *                         PyList_SetItem(pending, last_item, child)
 
3231
 */
 
3232
        __pyx_t_3 = (__pyx_v_last_item < PyList_GET_SIZE(__pyx_v_pending));
 
3233
        if (__pyx_t_3) {
 
3234
 
 
3235
          /* "bzrlib/_known_graph_pyx.pyx":336
 
3236
 *                     last_item = last_item + 1
 
3237
 *                     if last_item < PyList_GET_SIZE(pending):
 
3238
 *                         Py_INCREF(child) # SetItem steals a ref             # <<<<<<<<<<<<<<
 
3239
 *                         PyList_SetItem(pending, last_item, child)
 
3240
 *                     else:
 
3241
 */
 
3242
          Py_INCREF(((PyObject *)__pyx_v_child));
 
3243
 
 
3244
          /* "bzrlib/_known_graph_pyx.pyx":337
 
3245
 *                     if last_item < PyList_GET_SIZE(pending):
 
3246
 *                         Py_INCREF(child) # SetItem steals a ref
 
3247
 *                         PyList_SetItem(pending, last_item, child)             # <<<<<<<<<<<<<<
 
3248
 *                     else:
 
3249
 *                         PyList_Append(pending, child)
 
3250
 */
 
3251
          __pyx_t_5 = PyList_SetItem(__pyx_v_pending, __pyx_v_last_item, ((PyObject *)__pyx_v_child)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3252
          goto __pyx_L11;
 
3253
        }
 
3254
        /*else*/ {
 
3255
 
 
3256
          /* "bzrlib/_known_graph_pyx.pyx":339
 
3257
 *                         PyList_SetItem(pending, last_item, child)
 
3258
 *                     else:
 
3259
 *                         PyList_Append(pending, child)             # <<<<<<<<<<<<<<
 
3260
 *                     # We have queued this node, we don't need to track it
 
3261
 *                     # anymore
 
3262
 */
 
3263
          __pyx_t_5 = PyList_Append(__pyx_v_pending, ((PyObject *)__pyx_v_child)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3264
        }
 
3265
        __pyx_L11:;
 
3266
 
 
3267
        /* "bzrlib/_known_graph_pyx.pyx":342
 
3268
 *                     # We have queued this node, we don't need to track it
 
3269
 *                     # anymore
 
3270
 *                     child.seen = 0             # <<<<<<<<<<<<<<
 
3271
 * 
 
3272
 *     def add_node(self, key, parent_keys):
 
3273
 */
 
3274
        __pyx_v_child->seen = 0;
 
3275
        goto __pyx_L10;
 
3276
      }
 
3277
      __pyx_L10:;
 
3278
    }
 
3279
  }
 
3280
 
 
3281
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
3282
  goto __pyx_L0;
 
3283
  __pyx_L1_error:;
 
3284
  __Pyx_XDECREF(__pyx_t_1);
 
3285
  __Pyx_XDECREF(__pyx_t_2);
 
3286
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph._find_gdfo");
 
3287
  __pyx_r = NULL;
 
3288
  __pyx_L0:;
 
3289
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
3290
  __Pyx_DECREF((PyObject *)__pyx_v_child);
 
3291
  __Pyx_DECREF(__pyx_v_pending);
 
3292
  __Pyx_XGIVEREF(__pyx_r);
 
3293
  __Pyx_RefNannyFinishContext();
 
3294
  return __pyx_r;
 
3295
}
 
3296
 
 
3297
/* "bzrlib/_known_graph_pyx.pyx":344
 
3298
 *                     child.seen = 0
 
3299
 * 
 
3300
 *     def add_node(self, key, parent_keys):             # <<<<<<<<<<<<<<
 
3301
 *         """Add a new node to the graph.
 
3302
 * 
 
3303
 */
 
3304
 
 
3305
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6add_node(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
3306
static char __pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_6add_node[] = "Add a new node to the graph.\n\n        If this fills in a ghost, then the gdfos of all children will be\n        updated accordingly.\n        \n        :param key: The node being added. If this is a duplicate, this is a\n            no-op.\n        :param parent_keys: The parents of the given node.\n        :return: None (should we return if this was a ghost, etc?)\n        ";
 
3307
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6add_node(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
3308
  PyObject *__pyx_v_key = 0;
 
3309
  PyObject *__pyx_v_parent_keys = 0;
 
3310
  PyObject *__pyx_v_maybe_node;
 
3311
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
3312
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent_node;
 
3313
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_child_node;
 
3314
  long __pyx_v_parent_gdfo;
 
3315
  long __pyx_v_next_gdfo;
 
3316
  PyObject *__pyx_v_existing_parent_keys;
 
3317
  PyObject *__pyx_v_pending;
 
3318
  PyObject *__pyx_v_pending_popleft;
 
3319
  PyObject *__pyx_v_pending_append;
 
3320
  PyObject *__pyx_r = NULL;
 
3321
  PyObject *__pyx_t_1 = NULL;
 
3322
  int __pyx_t_2;
 
3323
  PyObject *__pyx_t_3 = NULL;
 
3324
  Py_ssize_t __pyx_t_4;
 
3325
  int __pyx_t_5;
 
3326
  PyObject *__pyx_t_6 = NULL;
 
3327
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__parent_keys,0};
 
3328
  __Pyx_RefNannySetupContext("add_node");
 
3329
  if (unlikely(__pyx_kwds)) {
 
3330
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
3331
    PyObject* values[2] = {0,0};
 
3332
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
3333
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
 
3334
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
3335
      case  0: break;
 
3336
      default: goto __pyx_L5_argtuple_error;
 
3337
    }
 
3338
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
3339
      case  0:
 
3340
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
 
3341
      if (likely(values[0])) kw_args--;
 
3342
      else goto __pyx_L5_argtuple_error;
 
3343
      case  1:
 
3344
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parent_keys);
 
3345
      if (likely(values[1])) kw_args--;
 
3346
      else {
 
3347
        __Pyx_RaiseArgtupleInvalid("add_node", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
3348
      }
 
3349
    }
 
3350
    if (unlikely(kw_args > 0)) {
 
3351
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "add_node") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
3352
    }
 
3353
    __pyx_v_key = values[0];
 
3354
    __pyx_v_parent_keys = values[1];
 
3355
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
 
3356
    goto __pyx_L5_argtuple_error;
 
3357
  } else {
 
3358
    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
 
3359
    __pyx_v_parent_keys = PyTuple_GET_ITEM(__pyx_args, 1);
 
3360
  }
 
3361
  goto __pyx_L4_argument_unpacking_done;
 
3362
  __pyx_L5_argtuple_error:;
 
3363
  __Pyx_RaiseArgtupleInvalid("add_node", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
3364
  __pyx_L3_error:;
 
3365
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.add_node");
 
3366
  __Pyx_RefNannyFinishContext();
 
3367
  return NULL;
 
3368
  __pyx_L4_argument_unpacking_done:;
 
3369
  __Pyx_INCREF(__pyx_v_parent_keys);
 
3370
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
3371
  __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
3372
  __pyx_v_child_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
3373
  __pyx_v_existing_parent_keys = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
3374
  __pyx_v_pending = Py_None; __Pyx_INCREF(Py_None);
 
3375
  __pyx_v_pending_popleft = Py_None; __Pyx_INCREF(Py_None);
 
3376
  __pyx_v_pending_append = Py_None; __Pyx_INCREF(Py_None);
 
3377
 
 
3378
  /* "bzrlib/_known_graph_pyx.pyx":359
 
3379
 *         cdef long parent_gdfo, next_gdfo
 
3380
 * 
 
3381
 *         maybe_node = PyDict_GetItem(self._nodes, key)             # <<<<<<<<<<<<<<
 
3382
 *         if maybe_node != NULL:
 
3383
 *             node = <_KnownGraphNode>maybe_node
 
3384
 */
 
3385
  __pyx_t_1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes;
 
3386
  __Pyx_INCREF(__pyx_t_1);
 
3387
  __pyx_v_maybe_node = PyDict_GetItem(__pyx_t_1, __pyx_v_key);
 
3388
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3389
 
 
3390
  /* "bzrlib/_known_graph_pyx.pyx":360
 
3391
 * 
 
3392
 *         maybe_node = PyDict_GetItem(self._nodes, key)
 
3393
 *         if maybe_node != NULL:             # <<<<<<<<<<<<<<
 
3394
 *             node = <_KnownGraphNode>maybe_node
 
3395
 *             if node.parents is None:
 
3396
 */
 
3397
  __pyx_t_2 = (__pyx_v_maybe_node != NULL);
 
3398
  if (__pyx_t_2) {
 
3399
 
 
3400
    /* "bzrlib/_known_graph_pyx.pyx":361
 
3401
 *         maybe_node = PyDict_GetItem(self._nodes, key)
 
3402
 *         if maybe_node != NULL:
 
3403
 *             node = <_KnownGraphNode>maybe_node             # <<<<<<<<<<<<<<
 
3404
 *             if node.parents is None:
 
3405
 *                 # We are filling in a ghost
 
3406
 */
 
3407
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_maybe_node)));
 
3408
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
3409
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_maybe_node);
 
3410
 
 
3411
    /* "bzrlib/_known_graph_pyx.pyx":362
 
3412
 *         if maybe_node != NULL:
 
3413
 *             node = <_KnownGraphNode>maybe_node
 
3414
 *             if node.parents is None:             # <<<<<<<<<<<<<<
 
3415
 *                 # We are filling in a ghost
 
3416
 *                 self._populate_parents(node, parent_keys)
 
3417
 */
 
3418
    __pyx_t_2 = (__pyx_v_node->parents == Py_None);
 
3419
    if (__pyx_t_2) {
 
3420
 
 
3421
      /* "bzrlib/_known_graph_pyx.pyx":364
 
3422
 *             if node.parents is None:
 
3423
 *                 # We are filling in a ghost
 
3424
 *                 self._populate_parents(node, parent_keys)             # <<<<<<<<<<<<<<
 
3425
 *                 # We can't trust cached heads anymore
 
3426
 *                 self._known_heads.clear()
 
3427
 */
 
3428
      __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx_KnownGraph *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->__pyx_vtab)->_populate_parents(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self), __pyx_v_node, __pyx_v_parent_keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3429
      __Pyx_GOTREF(__pyx_t_1);
 
3430
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3431
 
 
3432
      /* "bzrlib/_known_graph_pyx.pyx":366
 
3433
 *                 self._populate_parents(node, parent_keys)
 
3434
 *                 # We can't trust cached heads anymore
 
3435
 *                 self._known_heads.clear()             # <<<<<<<<<<<<<<
 
3436
 *             else: # Ensure that the parent_key list matches
 
3437
 *                 existing_parent_keys = []
 
3438
 */
 
3439
      __pyx_t_1 = PyObject_GetAttr(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads, __pyx_n_s__clear); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3440
      __Pyx_GOTREF(__pyx_t_1);
 
3441
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3442
      __Pyx_GOTREF(__pyx_t_3);
 
3443
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3444
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3445
      goto __pyx_L7;
 
3446
    }
 
3447
    /*else*/ {
 
3448
 
 
3449
      /* "bzrlib/_known_graph_pyx.pyx":368
 
3450
 *                 self._known_heads.clear()
 
3451
 *             else: # Ensure that the parent_key list matches
 
3452
 *                 existing_parent_keys = []             # <<<<<<<<<<<<<<
 
3453
 *                 for parent_node in node.parents:
 
3454
 *                     existing_parent_keys.append(parent_node.key)
 
3455
 */
 
3456
      __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3457
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
3458
      __Pyx_DECREF(((PyObject *)__pyx_v_existing_parent_keys));
 
3459
      __pyx_v_existing_parent_keys = __pyx_t_3;
 
3460
      __pyx_t_3 = 0;
 
3461
 
 
3462
      /* "bzrlib/_known_graph_pyx.pyx":369
 
3463
 *             else: # Ensure that the parent_key list matches
 
3464
 *                 existing_parent_keys = []
 
3465
 *                 for parent_node in node.parents:             # <<<<<<<<<<<<<<
 
3466
 *                     existing_parent_keys.append(parent_node.key)
 
3467
 *                 # Make sure we use a list for the comparison, in case it was a
 
3468
 */
 
3469
      if (PyList_CheckExact(__pyx_v_node->parents) || PyTuple_CheckExact(__pyx_v_node->parents)) {
 
3470
        __pyx_t_4 = 0; __pyx_t_3 = __pyx_v_node->parents; __Pyx_INCREF(__pyx_t_3);
 
3471
      } else {
 
3472
        __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_node->parents); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3473
        __Pyx_GOTREF(__pyx_t_3);
 
3474
      }
 
3475
      for (;;) {
 
3476
        if (likely(PyList_CheckExact(__pyx_t_3))) {
 
3477
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
 
3478
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++;
 
3479
        } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
 
3480
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
 
3481
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++;
 
3482
        } else {
 
3483
          __pyx_t_1 = PyIter_Next(__pyx_t_3);
 
3484
          if (!__pyx_t_1) {
 
3485
            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3486
            break;
 
3487
          }
 
3488
          __Pyx_GOTREF(__pyx_t_1);
 
3489
        }
 
3490
        if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3491
        __Pyx_DECREF(((PyObject *)__pyx_v_parent_node));
 
3492
        __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
 
3493
        __pyx_t_1 = 0;
 
3494
 
 
3495
        /* "bzrlib/_known_graph_pyx.pyx":370
 
3496
 *                 existing_parent_keys = []
 
3497
 *                 for parent_node in node.parents:
 
3498
 *                     existing_parent_keys.append(parent_node.key)             # <<<<<<<<<<<<<<
 
3499
 *                 # Make sure we use a list for the comparison, in case it was a
 
3500
 *                 # tuple, etc
 
3501
 */
 
3502
        if (unlikely(__pyx_v_existing_parent_keys == Py_None)) {
 
3503
          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
 
3504
        }
 
3505
        __pyx_t_1 = __pyx_v_parent_node->key;
 
3506
        __Pyx_INCREF(__pyx_t_1);
 
3507
        __pyx_t_5 = PyList_Append(__pyx_v_existing_parent_keys, __pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3508
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3509
      }
 
3510
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3511
 
 
3512
      /* "bzrlib/_known_graph_pyx.pyx":373
 
3513
 *                 # Make sure we use a list for the comparison, in case it was a
 
3514
 *                 # tuple, etc
 
3515
 *                 parent_keys = list(parent_keys)             # <<<<<<<<<<<<<<
 
3516
 *                 if existing_parent_keys == parent_keys:
 
3517
 *                     # Exact match, nothing more to do
 
3518
 */
 
3519
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3520
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
3521
      __Pyx_INCREF(__pyx_v_parent_keys);
 
3522
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_parent_keys);
 
3523
      __Pyx_GIVEREF(__pyx_v_parent_keys);
 
3524
      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3525
      __Pyx_GOTREF(__pyx_t_1);
 
3526
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
3527
      __Pyx_DECREF(__pyx_v_parent_keys);
 
3528
      __pyx_v_parent_keys = __pyx_t_1;
 
3529
      __pyx_t_1 = 0;
 
3530
 
 
3531
      /* "bzrlib/_known_graph_pyx.pyx":374
 
3532
 *                 # tuple, etc
 
3533
 *                 parent_keys = list(parent_keys)
 
3534
 *                 if existing_parent_keys == parent_keys:             # <<<<<<<<<<<<<<
 
3535
 *                     # Exact match, nothing more to do
 
3536
 *                     return
 
3537
 */
 
3538
      __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_existing_parent_keys), __pyx_v_parent_keys, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3539
      __Pyx_GOTREF(__pyx_t_1);
 
3540
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3541
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3542
      if (__pyx_t_2) {
 
3543
 
 
3544
        /* "bzrlib/_known_graph_pyx.pyx":376
 
3545
 *                 if existing_parent_keys == parent_keys:
 
3546
 *                     # Exact match, nothing more to do
 
3547
 *                     return             # <<<<<<<<<<<<<<
 
3548
 *                 else:
 
3549
 *                     raise ValueError('Parent key mismatch, existing node %s'
 
3550
 */
 
3551
        __Pyx_XDECREF(__pyx_r);
 
3552
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
3553
        goto __pyx_L0;
 
3554
        goto __pyx_L10;
 
3555
      }
 
3556
      /*else*/ {
 
3557
 
 
3558
        /* "bzrlib/_known_graph_pyx.pyx":380
 
3559
 *                     raise ValueError('Parent key mismatch, existing node %s'
 
3560
 *                         ' has parents of %s not %s'
 
3561
 *                         % (key, existing_parent_keys, parent_keys))             # <<<<<<<<<<<<<<
 
3562
 *         else:
 
3563
 *             node = _KnownGraphNode(key)
 
3564
 */
 
3565
        __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3566
        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
3567
        __Pyx_INCREF(__pyx_v_key);
 
3568
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_key);
 
3569
        __Pyx_GIVEREF(__pyx_v_key);
 
3570
        __Pyx_INCREF(((PyObject *)__pyx_v_existing_parent_keys));
 
3571
        PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_existing_parent_keys));
 
3572
        __Pyx_GIVEREF(((PyObject *)__pyx_v_existing_parent_keys));
 
3573
        __Pyx_INCREF(__pyx_v_parent_keys);
 
3574
        PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_parent_keys);
 
3575
        __Pyx_GIVEREF(__pyx_v_parent_keys);
 
3576
        __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3577
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
3578
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
3579
        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3580
        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
3581
        PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3));
 
3582
        __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
 
3583
        __pyx_t_3 = 0;
 
3584
        __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3585
        __Pyx_GOTREF(__pyx_t_3);
 
3586
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
3587
        __Pyx_Raise(__pyx_t_3, 0, 0);
 
3588
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3589
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3590
      }
 
3591
      __pyx_L10:;
 
3592
    }
 
3593
    __pyx_L7:;
 
3594
    goto __pyx_L6;
 
3595
  }
 
3596
  /*else*/ {
 
3597
 
 
3598
    /* "bzrlib/_known_graph_pyx.pyx":382
 
3599
 *                         % (key, existing_parent_keys, parent_keys))
 
3600
 *         else:
 
3601
 *             node = _KnownGraphNode(key)             # <<<<<<<<<<<<<<
 
3602
 *             PyDict_SetItem(self._nodes, key, node)
 
3603
 *             self._populate_parents(node, parent_keys)
 
3604
 */
 
3605
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3606
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
3607
    __Pyx_INCREF(__pyx_v_key);
 
3608
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_key);
 
3609
    __Pyx_GIVEREF(__pyx_v_key);
 
3610
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3611
    __Pyx_GOTREF(__pyx_t_1);
 
3612
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
3613
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
3614
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
 
3615
    __pyx_t_1 = 0;
 
3616
 
 
3617
    /* "bzrlib/_known_graph_pyx.pyx":383
 
3618
 *         else:
 
3619
 *             node = _KnownGraphNode(key)
 
3620
 *             PyDict_SetItem(self._nodes, key, node)             # <<<<<<<<<<<<<<
 
3621
 *             self._populate_parents(node, parent_keys)
 
3622
 *         parent_gdfo = 0
 
3623
 */
 
3624
    __pyx_t_1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes;
 
3625
    __Pyx_INCREF(__pyx_t_1);
 
3626
    __pyx_t_5 = PyDict_SetItem(__pyx_t_1, __pyx_v_key, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3627
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3628
 
 
3629
    /* "bzrlib/_known_graph_pyx.pyx":384
 
3630
 *             node = _KnownGraphNode(key)
 
3631
 *             PyDict_SetItem(self._nodes, key, node)
 
3632
 *             self._populate_parents(node, parent_keys)             # <<<<<<<<<<<<<<
 
3633
 *         parent_gdfo = 0
 
3634
 *         for parent_node in node.parents:
 
3635
 */
 
3636
    __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx_KnownGraph *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->__pyx_vtab)->_populate_parents(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self), __pyx_v_node, __pyx_v_parent_keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3637
    __Pyx_GOTREF(__pyx_t_1);
 
3638
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3639
  }
 
3640
  __pyx_L6:;
 
3641
 
 
3642
  /* "bzrlib/_known_graph_pyx.pyx":385
 
3643
 *             PyDict_SetItem(self._nodes, key, node)
 
3644
 *             self._populate_parents(node, parent_keys)
 
3645
 *         parent_gdfo = 0             # <<<<<<<<<<<<<<
 
3646
 *         for parent_node in node.parents:
 
3647
 *             if parent_node.gdfo == -1:
 
3648
 */
 
3649
  __pyx_v_parent_gdfo = 0;
 
3650
 
 
3651
  /* "bzrlib/_known_graph_pyx.pyx":386
 
3652
 *             self._populate_parents(node, parent_keys)
 
3653
 *         parent_gdfo = 0
 
3654
 *         for parent_node in node.parents:             # <<<<<<<<<<<<<<
 
3655
 *             if parent_node.gdfo == -1:
 
3656
 *                 # This is a newly introduced ghost, so it gets gdfo of 1
 
3657
 */
 
3658
  if (PyList_CheckExact(__pyx_v_node->parents) || PyTuple_CheckExact(__pyx_v_node->parents)) {
 
3659
    __pyx_t_4 = 0; __pyx_t_1 = __pyx_v_node->parents; __Pyx_INCREF(__pyx_t_1);
 
3660
  } else {
 
3661
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_node->parents); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3662
    __Pyx_GOTREF(__pyx_t_1);
 
3663
  }
 
3664
  for (;;) {
 
3665
    if (likely(PyList_CheckExact(__pyx_t_1))) {
 
3666
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
 
3667
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
 
3668
    } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
 
3669
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
 
3670
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
 
3671
    } else {
 
3672
      __pyx_t_3 = PyIter_Next(__pyx_t_1);
 
3673
      if (!__pyx_t_3) {
 
3674
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3675
        break;
 
3676
      }
 
3677
      __Pyx_GOTREF(__pyx_t_3);
 
3678
    }
 
3679
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3680
    __Pyx_DECREF(((PyObject *)__pyx_v_parent_node));
 
3681
    __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
 
3682
    __pyx_t_3 = 0;
 
3683
 
 
3684
    /* "bzrlib/_known_graph_pyx.pyx":387
 
3685
 *         parent_gdfo = 0
 
3686
 *         for parent_node in node.parents:
 
3687
 *             if parent_node.gdfo == -1:             # <<<<<<<<<<<<<<
 
3688
 *                 # This is a newly introduced ghost, so it gets gdfo of 1
 
3689
 *                 parent_node.gdfo = 1
 
3690
 */
 
3691
    __pyx_t_2 = (__pyx_v_parent_node->gdfo == -1);
 
3692
    if (__pyx_t_2) {
 
3693
 
 
3694
      /* "bzrlib/_known_graph_pyx.pyx":389
 
3695
 *             if parent_node.gdfo == -1:
 
3696
 *                 # This is a newly introduced ghost, so it gets gdfo of 1
 
3697
 *                 parent_node.gdfo = 1             # <<<<<<<<<<<<<<
 
3698
 *             if parent_gdfo < parent_node.gdfo:
 
3699
 *                 parent_gdfo = parent_node.gdfo
 
3700
 */
 
3701
      __pyx_v_parent_node->gdfo = 1;
 
3702
      goto __pyx_L13;
 
3703
    }
 
3704
    __pyx_L13:;
 
3705
 
 
3706
    /* "bzrlib/_known_graph_pyx.pyx":390
 
3707
 *                 # This is a newly introduced ghost, so it gets gdfo of 1
 
3708
 *                 parent_node.gdfo = 1
 
3709
 *             if parent_gdfo < parent_node.gdfo:             # <<<<<<<<<<<<<<
 
3710
 *                 parent_gdfo = parent_node.gdfo
 
3711
 *         node.gdfo = parent_gdfo + 1
 
3712
 */
 
3713
    __pyx_t_2 = (__pyx_v_parent_gdfo < __pyx_v_parent_node->gdfo);
 
3714
    if (__pyx_t_2) {
 
3715
 
 
3716
      /* "bzrlib/_known_graph_pyx.pyx":391
 
3717
 *                 parent_node.gdfo = 1
 
3718
 *             if parent_gdfo < parent_node.gdfo:
 
3719
 *                 parent_gdfo = parent_node.gdfo             # <<<<<<<<<<<<<<
 
3720
 *         node.gdfo = parent_gdfo + 1
 
3721
 *         # Now fill the gdfo to all children
 
3722
 */
 
3723
      __pyx_v_parent_gdfo = __pyx_v_parent_node->gdfo;
 
3724
      goto __pyx_L14;
 
3725
    }
 
3726
    __pyx_L14:;
 
3727
  }
 
3728
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3729
 
 
3730
  /* "bzrlib/_known_graph_pyx.pyx":392
 
3731
 *             if parent_gdfo < parent_node.gdfo:
 
3732
 *                 parent_gdfo = parent_node.gdfo
 
3733
 *         node.gdfo = parent_gdfo + 1             # <<<<<<<<<<<<<<
 
3734
 *         # Now fill the gdfo to all children
 
3735
 *         # Note that this loop is slightly inefficient, in that we may visit the
 
3736
 */
 
3737
  __pyx_v_node->gdfo = (__pyx_v_parent_gdfo + 1);
 
3738
 
 
3739
  /* "bzrlib/_known_graph_pyx.pyx":401
 
3740
 *         # than DFD. So that if a longer path is possible, we walk it before we
 
3741
 *         # get to the final child
 
3742
 *         pending = deque([node])             # <<<<<<<<<<<<<<
 
3743
 *         pending_popleft = pending.popleft
 
3744
 *         pending_append = pending.append
 
3745
 */
 
3746
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__deque); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3747
  __Pyx_GOTREF(__pyx_t_1);
 
3748
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3749
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
3750
  __Pyx_INCREF(((PyObject *)__pyx_v_node));
 
3751
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_node));
 
3752
  __Pyx_GIVEREF(((PyObject *)__pyx_v_node));
 
3753
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3754
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
 
3755
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_3));
 
3756
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
 
3757
  __pyx_t_3 = 0;
 
3758
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3759
  __Pyx_GOTREF(__pyx_t_3);
 
3760
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3761
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
 
3762
  __Pyx_DECREF(__pyx_v_pending);
 
3763
  __pyx_v_pending = __pyx_t_3;
 
3764
  __pyx_t_3 = 0;
 
3765
 
 
3766
  /* "bzrlib/_known_graph_pyx.pyx":402
 
3767
 *         # get to the final child
 
3768
 *         pending = deque([node])
 
3769
 *         pending_popleft = pending.popleft             # <<<<<<<<<<<<<<
 
3770
 *         pending_append = pending.append
 
3771
 *         while pending:
 
3772
 */
 
3773
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_pending, __pyx_n_s__popleft); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3774
  __Pyx_GOTREF(__pyx_t_3);
 
3775
  __Pyx_DECREF(__pyx_v_pending_popleft);
 
3776
  __pyx_v_pending_popleft = __pyx_t_3;
 
3777
  __pyx_t_3 = 0;
 
3778
 
 
3779
  /* "bzrlib/_known_graph_pyx.pyx":403
 
3780
 *         pending = deque([node])
 
3781
 *         pending_popleft = pending.popleft
 
3782
 *         pending_append = pending.append             # <<<<<<<<<<<<<<
 
3783
 *         while pending:
 
3784
 *             node = pending_popleft()
 
3785
 */
 
3786
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_pending, __pyx_n_s__append); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3787
  __Pyx_GOTREF(__pyx_t_3);
 
3788
  __Pyx_DECREF(__pyx_v_pending_append);
 
3789
  __pyx_v_pending_append = __pyx_t_3;
 
3790
  __pyx_t_3 = 0;
 
3791
 
 
3792
  /* "bzrlib/_known_graph_pyx.pyx":404
 
3793
 *         pending_popleft = pending.popleft
 
3794
 *         pending_append = pending.append
 
3795
 *         while pending:             # <<<<<<<<<<<<<<
 
3796
 *             node = pending_popleft()
 
3797
 *             next_gdfo = node.gdfo + 1
 
3798
 */
 
3799
  while (1) {
 
3800
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_pending); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3801
    if (!__pyx_t_2) break;
 
3802
 
 
3803
    /* "bzrlib/_known_graph_pyx.pyx":405
 
3804
 *         pending_append = pending.append
 
3805
 *         while pending:
 
3806
 *             node = pending_popleft()             # <<<<<<<<<<<<<<
 
3807
 *             next_gdfo = node.gdfo + 1
 
3808
 *             for child_node in node.children:
 
3809
 */
 
3810
    __pyx_t_3 = PyObject_Call(__pyx_v_pending_popleft, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3811
    __Pyx_GOTREF(__pyx_t_3);
 
3812
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3813
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
3814
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
 
3815
    __pyx_t_3 = 0;
 
3816
 
 
3817
    /* "bzrlib/_known_graph_pyx.pyx":406
 
3818
 *         while pending:
 
3819
 *             node = pending_popleft()
 
3820
 *             next_gdfo = node.gdfo + 1             # <<<<<<<<<<<<<<
 
3821
 *             for child_node in node.children:
 
3822
 *                 if child_node.gdfo < next_gdfo:
 
3823
 */
 
3824
    __pyx_v_next_gdfo = (__pyx_v_node->gdfo + 1);
 
3825
 
 
3826
    /* "bzrlib/_known_graph_pyx.pyx":407
 
3827
 *             node = pending_popleft()
 
3828
 *             next_gdfo = node.gdfo + 1
 
3829
 *             for child_node in node.children:             # <<<<<<<<<<<<<<
 
3830
 *                 if child_node.gdfo < next_gdfo:
 
3831
 *                     # This child is being updated, we need to check its
 
3832
 */
 
3833
    if (PyList_CheckExact(__pyx_v_node->children) || PyTuple_CheckExact(__pyx_v_node->children)) {
 
3834
      __pyx_t_4 = 0; __pyx_t_3 = __pyx_v_node->children; __Pyx_INCREF(__pyx_t_3);
 
3835
    } else {
 
3836
      __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_node->children); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3837
      __Pyx_GOTREF(__pyx_t_3);
 
3838
    }
 
3839
    for (;;) {
 
3840
      if (likely(PyList_CheckExact(__pyx_t_3))) {
 
3841
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
 
3842
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++;
 
3843
      } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
 
3844
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
 
3845
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++;
 
3846
      } else {
 
3847
        __pyx_t_6 = PyIter_Next(__pyx_t_3);
 
3848
        if (!__pyx_t_6) {
 
3849
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3850
          break;
 
3851
        }
 
3852
        __Pyx_GOTREF(__pyx_t_6);
 
3853
      }
 
3854
      if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3855
      __Pyx_DECREF(((PyObject *)__pyx_v_child_node));
 
3856
      __pyx_v_child_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_6);
 
3857
      __pyx_t_6 = 0;
 
3858
 
 
3859
      /* "bzrlib/_known_graph_pyx.pyx":408
 
3860
 *             next_gdfo = node.gdfo + 1
 
3861
 *             for child_node in node.children:
 
3862
 *                 if child_node.gdfo < next_gdfo:             # <<<<<<<<<<<<<<
 
3863
 *                     # This child is being updated, we need to check its
 
3864
 *                     # children
 
3865
 */
 
3866
      __pyx_t_2 = (__pyx_v_child_node->gdfo < __pyx_v_next_gdfo);
 
3867
      if (__pyx_t_2) {
 
3868
 
 
3869
        /* "bzrlib/_known_graph_pyx.pyx":411
 
3870
 *                     # This child is being updated, we need to check its
 
3871
 *                     # children
 
3872
 *                     child_node.gdfo = next_gdfo             # <<<<<<<<<<<<<<
 
3873
 *                     pending_append(child_node)
 
3874
 * 
 
3875
 */
 
3876
        __pyx_v_child_node->gdfo = __pyx_v_next_gdfo;
 
3877
 
 
3878
        /* "bzrlib/_known_graph_pyx.pyx":412
 
3879
 *                     # children
 
3880
 *                     child_node.gdfo = next_gdfo
 
3881
 *                     pending_append(child_node)             # <<<<<<<<<<<<<<
 
3882
 * 
 
3883
 *     def heads(self, keys):
 
3884
 */
 
3885
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3886
        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
 
3887
        __Pyx_INCREF(((PyObject *)__pyx_v_child_node));
 
3888
        PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_child_node));
 
3889
        __Pyx_GIVEREF(((PyObject *)__pyx_v_child_node));
 
3890
        __pyx_t_1 = PyObject_Call(__pyx_v_pending_append, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3891
        __Pyx_GOTREF(__pyx_t_1);
 
3892
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
 
3893
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3894
        goto __pyx_L19;
 
3895
      }
 
3896
      __pyx_L19:;
 
3897
    }
 
3898
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3899
  }
 
3900
 
 
3901
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
3902
  goto __pyx_L0;
 
3903
  __pyx_L1_error:;
 
3904
  __Pyx_XDECREF(__pyx_t_1);
 
3905
  __Pyx_XDECREF(__pyx_t_3);
 
3906
  __Pyx_XDECREF(__pyx_t_6);
 
3907
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.add_node");
 
3908
  __pyx_r = NULL;
 
3909
  __pyx_L0:;
 
3910
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
3911
  __Pyx_DECREF((PyObject *)__pyx_v_parent_node);
 
3912
  __Pyx_DECREF((PyObject *)__pyx_v_child_node);
 
3913
  __Pyx_DECREF(__pyx_v_existing_parent_keys);
 
3914
  __Pyx_DECREF(__pyx_v_pending);
 
3915
  __Pyx_DECREF(__pyx_v_pending_popleft);
 
3916
  __Pyx_DECREF(__pyx_v_pending_append);
 
3917
  __Pyx_DECREF(__pyx_v_parent_keys);
 
3918
  __Pyx_XGIVEREF(__pyx_r);
 
3919
  __Pyx_RefNannyFinishContext();
 
3920
  return __pyx_r;
 
3921
}
 
3922
 
 
3923
/* "bzrlib/_known_graph_pyx.pyx":414
 
3924
 *                     pending_append(child_node)
 
3925
 * 
 
3926
 *     def heads(self, keys):             # <<<<<<<<<<<<<<
 
3927
 *         """Return the heads from amongst keys.
 
3928
 * 
 
3929
 */
 
3930
 
 
3931
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_7heads(PyObject *__pyx_v_self, PyObject *__pyx_v_keys); /*proto*/
 
3932
static char __pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_7heads[] = "Return the heads from amongst keys.\n\n        This is done by searching the ancestries of each key.  Any key that is\n        reachable from another key is not returned; all the others are.\n\n        This operation scales with the relative depth between any two keys. It\n        uses gdfo to avoid walking all ancestry.\n\n        :param keys: An iterable of keys.\n        :return: A set of the heads. Note that as a set there is no ordering\n            information. Callers will need to filter their input to create\n            order if they need it.\n        ";
 
3933
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_7heads(PyObject *__pyx_v_self, PyObject *__pyx_v_keys) {
 
3934
  PyObject *__pyx_v_maybe_node;
 
3935
  PyObject *__pyx_v_maybe_heads;
 
3936
  PyObject *__pyx_v_temp_node;
 
3937
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
3938
  Py_ssize_t __pyx_v_pos;
 
3939
  Py_ssize_t __pyx_v_last_item;
 
3940
  long __pyx_v_min_gdfo;
 
3941
  PyObject *__pyx_v_heads_key;
 
3942
  PyObject *__pyx_v_candidate_nodes;
 
3943
  PyObject *__pyx_v_key;
 
3944
  PyObject *__pyx_v_cleanup;
 
3945
  PyObject *__pyx_v_pending;
 
3946
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent_node;
 
3947
  PyObject *__pyx_v_heads;
 
3948
  PyObject *__pyx_r = NULL;
 
3949
  PyObject *__pyx_t_1 = NULL;
 
3950
  PyObject *__pyx_t_2 = NULL;
 
3951
  int __pyx_t_3;
 
3952
  Py_ssize_t __pyx_t_4;
 
3953
  PyObject *__pyx_t_5 = NULL;
 
3954
  int __pyx_t_6;
 
3955
  int __pyx_t_7;
 
3956
  int __pyx_t_8;
 
3957
  __Pyx_RefNannySetupContext("heads");
 
3958
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
3959
  __pyx_v_heads_key = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
3960
  __pyx_v_candidate_nodes = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
3961
  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
 
3962
  __pyx_v_cleanup = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
3963
  __pyx_v_pending = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
3964
  __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
3965
  __pyx_v_heads = Py_None; __Pyx_INCREF(Py_None);
 
3966
 
 
3967
  /* "bzrlib/_known_graph_pyx.pyx":435
 
3968
 *         cdef long min_gdfo
 
3969
 * 
 
3970
 *         heads_key = frozenset(keys)             # <<<<<<<<<<<<<<
 
3971
 *         maybe_heads = PyDict_GetItem(self._known_heads, heads_key)
 
3972
 *         if maybe_heads != NULL:
 
3973
 */
 
3974
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3975
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
3976
  __Pyx_INCREF(__pyx_v_keys);
 
3977
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_keys);
 
3978
  __Pyx_GIVEREF(__pyx_v_keys);
 
3979
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyFrozenSet_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3980
  __Pyx_GOTREF(__pyx_t_2);
 
3981
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
3982
  __Pyx_DECREF(((PyObject *)__pyx_v_heads_key));
 
3983
  __pyx_v_heads_key = ((PyObject*)__pyx_t_2);
 
3984
  __pyx_t_2 = 0;
 
3985
 
 
3986
  /* "bzrlib/_known_graph_pyx.pyx":436
 
3987
 * 
 
3988
 *         heads_key = frozenset(keys)
 
3989
 *         maybe_heads = PyDict_GetItem(self._known_heads, heads_key)             # <<<<<<<<<<<<<<
 
3990
 *         if maybe_heads != NULL:
 
3991
 *             return <object>maybe_heads
 
3992
 */
 
3993
  __pyx_t_2 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads;
 
3994
  __Pyx_INCREF(__pyx_t_2);
 
3995
  __pyx_v_maybe_heads = PyDict_GetItem(__pyx_t_2, ((PyObject *)__pyx_v_heads_key));
 
3996
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
3997
 
 
3998
  /* "bzrlib/_known_graph_pyx.pyx":437
 
3999
 *         heads_key = frozenset(keys)
 
4000
 *         maybe_heads = PyDict_GetItem(self._known_heads, heads_key)
 
4001
 *         if maybe_heads != NULL:             # <<<<<<<<<<<<<<
 
4002
 *             return <object>maybe_heads
 
4003
 *         # Not cached, compute it ourselves
 
4004
 */
 
4005
  __pyx_t_3 = (__pyx_v_maybe_heads != NULL);
 
4006
  if (__pyx_t_3) {
 
4007
 
 
4008
    /* "bzrlib/_known_graph_pyx.pyx":438
 
4009
 *         maybe_heads = PyDict_GetItem(self._known_heads, heads_key)
 
4010
 *         if maybe_heads != NULL:
 
4011
 *             return <object>maybe_heads             # <<<<<<<<<<<<<<
 
4012
 *         # Not cached, compute it ourselves
 
4013
 *         candidate_nodes = {}
 
4014
 */
 
4015
    __Pyx_XDECREF(__pyx_r);
 
4016
    __Pyx_INCREF(((PyObject *)__pyx_v_maybe_heads));
 
4017
    __pyx_r = ((PyObject *)__pyx_v_maybe_heads);
 
4018
    goto __pyx_L0;
 
4019
    goto __pyx_L5;
 
4020
  }
 
4021
  __pyx_L5:;
 
4022
 
 
4023
  /* "bzrlib/_known_graph_pyx.pyx":440
 
4024
 *             return <object>maybe_heads
 
4025
 *         # Not cached, compute it ourselves
 
4026
 *         candidate_nodes = {}             # <<<<<<<<<<<<<<
 
4027
 *         for key in keys:
 
4028
 *             maybe_node = PyDict_GetItem(self._nodes, key)
 
4029
 */
 
4030
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4031
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
4032
  __Pyx_DECREF(((PyObject *)__pyx_v_candidate_nodes));
 
4033
  __pyx_v_candidate_nodes = __pyx_t_2;
 
4034
  __pyx_t_2 = 0;
 
4035
 
 
4036
  /* "bzrlib/_known_graph_pyx.pyx":441
 
4037
 *         # Not cached, compute it ourselves
 
4038
 *         candidate_nodes = {}
 
4039
 *         for key in keys:             # <<<<<<<<<<<<<<
 
4040
 *             maybe_node = PyDict_GetItem(self._nodes, key)
 
4041
 *             if maybe_node == NULL:
 
4042
 */
 
4043
  if (PyList_CheckExact(__pyx_v_keys) || PyTuple_CheckExact(__pyx_v_keys)) {
 
4044
    __pyx_t_4 = 0; __pyx_t_2 = __pyx_v_keys; __Pyx_INCREF(__pyx_t_2);
 
4045
  } else {
 
4046
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4047
    __Pyx_GOTREF(__pyx_t_2);
 
4048
  }
 
4049
  for (;;) {
 
4050
    if (likely(PyList_CheckExact(__pyx_t_2))) {
 
4051
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
 
4052
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++;
 
4053
    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
 
4054
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
 
4055
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++;
 
4056
    } else {
 
4057
      __pyx_t_1 = PyIter_Next(__pyx_t_2);
 
4058
      if (!__pyx_t_1) {
 
4059
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4060
        break;
 
4061
      }
 
4062
      __Pyx_GOTREF(__pyx_t_1);
 
4063
    }
 
4064
    __Pyx_DECREF(__pyx_v_key);
 
4065
    __pyx_v_key = __pyx_t_1;
 
4066
    __pyx_t_1 = 0;
 
4067
 
 
4068
    /* "bzrlib/_known_graph_pyx.pyx":442
 
4069
 *         candidate_nodes = {}
 
4070
 *         for key in keys:
 
4071
 *             maybe_node = PyDict_GetItem(self._nodes, key)             # <<<<<<<<<<<<<<
 
4072
 *             if maybe_node == NULL:
 
4073
 *                 raise KeyError('key %s not in nodes' % (key,))
 
4074
 */
 
4075
    __pyx_t_1 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes;
 
4076
    __Pyx_INCREF(__pyx_t_1);
 
4077
    __pyx_v_maybe_node = PyDict_GetItem(__pyx_t_1, __pyx_v_key);
 
4078
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
4079
 
 
4080
    /* "bzrlib/_known_graph_pyx.pyx":443
 
4081
 *         for key in keys:
 
4082
 *             maybe_node = PyDict_GetItem(self._nodes, key)
 
4083
 *             if maybe_node == NULL:             # <<<<<<<<<<<<<<
 
4084
 *                 raise KeyError('key %s not in nodes' % (key,))
 
4085
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)
 
4086
 */
 
4087
    __pyx_t_3 = (__pyx_v_maybe_node == NULL);
 
4088
    if (__pyx_t_3) {
 
4089
 
 
4090
      /* "bzrlib/_known_graph_pyx.pyx":444
 
4091
 *             maybe_node = PyDict_GetItem(self._nodes, key)
 
4092
 *             if maybe_node == NULL:
 
4093
 *                 raise KeyError('key %s not in nodes' % (key,))             # <<<<<<<<<<<<<<
 
4094
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)
 
4095
 *         maybe_node = PyDict_GetItem(candidate_nodes, NULL_REVISION)
 
4096
 */
 
4097
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4098
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
4099
      __Pyx_INCREF(__pyx_v_key);
 
4100
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_key);
 
4101
      __Pyx_GIVEREF(__pyx_v_key);
 
4102
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4103
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
 
4104
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
4105
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4106
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
4107
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5));
 
4108
      __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
 
4109
      __pyx_t_5 = 0;
 
4110
      __pyx_t_5 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4111
      __Pyx_GOTREF(__pyx_t_5);
 
4112
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
4113
      __Pyx_Raise(__pyx_t_5, 0, 0);
 
4114
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
4115
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4116
      goto __pyx_L8;
 
4117
    }
 
4118
    __pyx_L8:;
 
4119
 
 
4120
    /* "bzrlib/_known_graph_pyx.pyx":445
 
4121
 *             if maybe_node == NULL:
 
4122
 *                 raise KeyError('key %s not in nodes' % (key,))
 
4123
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)             # <<<<<<<<<<<<<<
 
4124
 *         maybe_node = PyDict_GetItem(candidate_nodes, NULL_REVISION)
 
4125
 *         if maybe_node != NULL:
 
4126
 */
 
4127
    __pyx_t_6 = PyDict_SetItem(((PyObject *)__pyx_v_candidate_nodes), __pyx_v_key, ((PyObject *)__pyx_v_maybe_node)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4128
  }
 
4129
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
4130
 
 
4131
  /* "bzrlib/_known_graph_pyx.pyx":446
 
4132
 *                 raise KeyError('key %s not in nodes' % (key,))
 
4133
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)
 
4134
 *         maybe_node = PyDict_GetItem(candidate_nodes, NULL_REVISION)             # <<<<<<<<<<<<<<
 
4135
 *         if maybe_node != NULL:
 
4136
 *             # NULL_REVISION is only a head if it is the only entry
 
4137
 */
 
4138
  __pyx_v_maybe_node = PyDict_GetItem(((PyObject *)__pyx_v_candidate_nodes), __pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
4139
 
 
4140
  /* "bzrlib/_known_graph_pyx.pyx":447
 
4141
 *             PyDict_SetItem(candidate_nodes, key, <object>maybe_node)
 
4142
 *         maybe_node = PyDict_GetItem(candidate_nodes, NULL_REVISION)
 
4143
 *         if maybe_node != NULL:             # <<<<<<<<<<<<<<
 
4144
 *             # NULL_REVISION is only a head if it is the only entry
 
4145
 *             candidate_nodes.pop(NULL_REVISION)
 
4146
 */
 
4147
  __pyx_t_3 = (__pyx_v_maybe_node != NULL);
 
4148
  if (__pyx_t_3) {
 
4149
 
 
4150
    /* "bzrlib/_known_graph_pyx.pyx":449
 
4151
 *         if maybe_node != NULL:
 
4152
 *             # NULL_REVISION is only a head if it is the only entry
 
4153
 *             candidate_nodes.pop(NULL_REVISION)             # <<<<<<<<<<<<<<
 
4154
 *             if not candidate_nodes:
 
4155
 *                 return frozenset([NULL_REVISION])
 
4156
 */
 
4157
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_candidate_nodes), __pyx_n_s__pop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4158
    __Pyx_GOTREF(__pyx_t_2);
 
4159
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4160
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
 
4161
    __Pyx_INCREF(__pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
4162
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
4163
    __Pyx_GIVEREF(__pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
4164
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4165
    __Pyx_GOTREF(__pyx_t_1);
 
4166
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
4167
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
 
4168
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
4169
 
 
4170
    /* "bzrlib/_known_graph_pyx.pyx":450
 
4171
 *             # NULL_REVISION is only a head if it is the only entry
 
4172
 *             candidate_nodes.pop(NULL_REVISION)
 
4173
 *             if not candidate_nodes:             # <<<<<<<<<<<<<<
 
4174
 *                 return frozenset([NULL_REVISION])
 
4175
 *             # The keys changed, so recalculate heads_key
 
4176
 */
 
4177
    __pyx_t_3 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_candidate_nodes)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4178
    __pyx_t_7 = (!__pyx_t_3);
 
4179
    if (__pyx_t_7) {
 
4180
 
 
4181
      /* "bzrlib/_known_graph_pyx.pyx":451
 
4182
 *             candidate_nodes.pop(NULL_REVISION)
 
4183
 *             if not candidate_nodes:
 
4184
 *                 return frozenset([NULL_REVISION])             # <<<<<<<<<<<<<<
 
4185
 *             # The keys changed, so recalculate heads_key
 
4186
 *             heads_key = frozenset(candidate_nodes)
 
4187
 */
 
4188
      __Pyx_XDECREF(__pyx_r);
 
4189
      __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4190
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
4191
      __Pyx_INCREF(__pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
4192
      PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
4193
      __Pyx_GIVEREF(__pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
4194
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4195
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
 
4196
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1));
 
4197
      __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
 
4198
      __pyx_t_1 = 0;
 
4199
      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyFrozenSet_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4200
      __Pyx_GOTREF(__pyx_t_1);
 
4201
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
 
4202
      __pyx_r = __pyx_t_1;
 
4203
      __pyx_t_1 = 0;
 
4204
      goto __pyx_L0;
 
4205
      goto __pyx_L10;
 
4206
    }
 
4207
    __pyx_L10:;
 
4208
 
 
4209
    /* "bzrlib/_known_graph_pyx.pyx":453
 
4210
 *                 return frozenset([NULL_REVISION])
 
4211
 *             # The keys changed, so recalculate heads_key
 
4212
 *             heads_key = frozenset(candidate_nodes)             # <<<<<<<<<<<<<<
 
4213
 *         if PyDict_Size(candidate_nodes) < 2:
 
4214
 *             return heads_key
 
4215
 */
 
4216
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4217
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
4218
    __Pyx_INCREF(((PyObject *)__pyx_v_candidate_nodes));
 
4219
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_candidate_nodes));
 
4220
    __Pyx_GIVEREF(((PyObject *)__pyx_v_candidate_nodes));
 
4221
    __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyFrozenSet_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4222
    __Pyx_GOTREF(__pyx_t_5);
 
4223
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
4224
    __Pyx_DECREF(((PyObject *)__pyx_v_heads_key));
 
4225
    __pyx_v_heads_key = ((PyObject*)__pyx_t_5);
 
4226
    __pyx_t_5 = 0;
 
4227
    goto __pyx_L9;
 
4228
  }
 
4229
  __pyx_L9:;
 
4230
 
 
4231
  /* "bzrlib/_known_graph_pyx.pyx":454
 
4232
 *             # The keys changed, so recalculate heads_key
 
4233
 *             heads_key = frozenset(candidate_nodes)
 
4234
 *         if PyDict_Size(candidate_nodes) < 2:             # <<<<<<<<<<<<<<
 
4235
 *             return heads_key
 
4236
 * 
 
4237
 */
 
4238
  __pyx_t_4 = PyDict_Size(((PyObject *)__pyx_v_candidate_nodes)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4239
  __pyx_t_7 = (__pyx_t_4 < 2);
 
4240
  if (__pyx_t_7) {
 
4241
 
 
4242
    /* "bzrlib/_known_graph_pyx.pyx":455
 
4243
 *             heads_key = frozenset(candidate_nodes)
 
4244
 *         if PyDict_Size(candidate_nodes) < 2:
 
4245
 *             return heads_key             # <<<<<<<<<<<<<<
 
4246
 * 
 
4247
 *         cleanup = []
 
4248
 */
 
4249
    __Pyx_XDECREF(__pyx_r);
 
4250
    __Pyx_INCREF(((PyObject *)__pyx_v_heads_key));
 
4251
    __pyx_r = ((PyObject *)__pyx_v_heads_key);
 
4252
    goto __pyx_L0;
 
4253
    goto __pyx_L11;
 
4254
  }
 
4255
  __pyx_L11:;
 
4256
 
 
4257
  /* "bzrlib/_known_graph_pyx.pyx":457
 
4258
 *             return heads_key
 
4259
 * 
 
4260
 *         cleanup = []             # <<<<<<<<<<<<<<
 
4261
 *         pending = []
 
4262
 *         # we know a gdfo cannot be longer than a linear chain of all nodes
 
4263
 */
 
4264
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4265
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
 
4266
  __Pyx_DECREF(((PyObject *)__pyx_v_cleanup));
 
4267
  __pyx_v_cleanup = __pyx_t_5;
 
4268
  __pyx_t_5 = 0;
 
4269
 
 
4270
  /* "bzrlib/_known_graph_pyx.pyx":458
 
4271
 * 
 
4272
 *         cleanup = []
 
4273
 *         pending = []             # <<<<<<<<<<<<<<
 
4274
 *         # we know a gdfo cannot be longer than a linear chain of all nodes
 
4275
 *         min_gdfo = PyDict_Size(self._nodes) + 1
 
4276
 */
 
4277
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4278
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
 
4279
  __Pyx_DECREF(((PyObject *)__pyx_v_pending));
 
4280
  __pyx_v_pending = __pyx_t_5;
 
4281
  __pyx_t_5 = 0;
 
4282
 
 
4283
  /* "bzrlib/_known_graph_pyx.pyx":460
 
4284
 *         pending = []
 
4285
 *         # we know a gdfo cannot be longer than a linear chain of all nodes
 
4286
 *         min_gdfo = PyDict_Size(self._nodes) + 1             # <<<<<<<<<<<<<<
 
4287
 *         # Build up nodes that need to be walked, note that starting nodes are
 
4288
 *         # not added to seen()
 
4289
 */
 
4290
  __pyx_t_5 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes;
 
4291
  __Pyx_INCREF(__pyx_t_5);
 
4292
  __pyx_t_4 = PyDict_Size(__pyx_t_5); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4293
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
4294
  __pyx_v_min_gdfo = (__pyx_t_4 + 1);
 
4295
 
 
4296
  /* "bzrlib/_known_graph_pyx.pyx":463
 
4297
 *         # Build up nodes that need to be walked, note that starting nodes are
 
4298
 *         # not added to seen()
 
4299
 *         pos = 0             # <<<<<<<<<<<<<<
 
4300
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 
4301
 *             node = <_KnownGraphNode>temp_node
 
4302
 */
 
4303
  __pyx_v_pos = 0;
 
4304
 
 
4305
  /* "bzrlib/_known_graph_pyx.pyx":464
 
4306
 *         # not added to seen()
 
4307
 *         pos = 0
 
4308
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):             # <<<<<<<<<<<<<<
 
4309
 *             node = <_KnownGraphNode>temp_node
 
4310
 *             if node.parents is not None:
 
4311
 */
 
4312
  while (1) {
 
4313
    __pyx_t_6 = PyDict_Next(((PyObject *)__pyx_v_candidate_nodes), (&__pyx_v_pos), NULL, (&__pyx_v_temp_node));
 
4314
    if (!__pyx_t_6) break;
 
4315
 
 
4316
    /* "bzrlib/_known_graph_pyx.pyx":465
 
4317
 *         pos = 0
 
4318
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 
4319
 *             node = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 
4320
 *             if node.parents is not None:
 
4321
 *                 pending.extend(node.parents)
 
4322
 */
 
4323
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node)));
 
4324
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
4325
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node);
 
4326
 
 
4327
    /* "bzrlib/_known_graph_pyx.pyx":466
 
4328
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 
4329
 *             node = <_KnownGraphNode>temp_node
 
4330
 *             if node.parents is not None:             # <<<<<<<<<<<<<<
 
4331
 *                 pending.extend(node.parents)
 
4332
 *             if node.gdfo < min_gdfo:
 
4333
 */
 
4334
    __pyx_t_7 = (__pyx_v_node->parents != Py_None);
 
4335
    if (__pyx_t_7) {
 
4336
 
 
4337
      /* "bzrlib/_known_graph_pyx.pyx":467
 
4338
 *             node = <_KnownGraphNode>temp_node
 
4339
 *             if node.parents is not None:
 
4340
 *                 pending.extend(node.parents)             # <<<<<<<<<<<<<<
 
4341
 *             if node.gdfo < min_gdfo:
 
4342
 *                 min_gdfo = node.gdfo
 
4343
 */
 
4344
      __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_pending), __pyx_n_s__extend); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4345
      __Pyx_GOTREF(__pyx_t_5);
 
4346
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4347
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
4348
      __Pyx_INCREF(__pyx_v_node->parents);
 
4349
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_node->parents);
 
4350
      __Pyx_GIVEREF(__pyx_v_node->parents);
 
4351
      __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4352
      __Pyx_GOTREF(__pyx_t_2);
 
4353
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
4354
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
4355
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
4356
      goto __pyx_L14;
 
4357
    }
 
4358
    __pyx_L14:;
 
4359
 
 
4360
    /* "bzrlib/_known_graph_pyx.pyx":468
 
4361
 *             if node.parents is not None:
 
4362
 *                 pending.extend(node.parents)
 
4363
 *             if node.gdfo < min_gdfo:             # <<<<<<<<<<<<<<
 
4364
 *                 min_gdfo = node.gdfo
 
4365
 * 
 
4366
 */
 
4367
    __pyx_t_7 = (__pyx_v_node->gdfo < __pyx_v_min_gdfo);
 
4368
    if (__pyx_t_7) {
 
4369
 
 
4370
      /* "bzrlib/_known_graph_pyx.pyx":469
 
4371
 *                 pending.extend(node.parents)
 
4372
 *             if node.gdfo < min_gdfo:
 
4373
 *                 min_gdfo = node.gdfo             # <<<<<<<<<<<<<<
 
4374
 * 
 
4375
 *         # Now do all the real work
 
4376
 */
 
4377
      __pyx_v_min_gdfo = __pyx_v_node->gdfo;
 
4378
      goto __pyx_L15;
 
4379
    }
 
4380
    __pyx_L15:;
 
4381
  }
 
4382
 
 
4383
  /* "bzrlib/_known_graph_pyx.pyx":472
 
4384
 * 
 
4385
 *         # Now do all the real work
 
4386
 *         last_item = PyList_GET_SIZE(pending) - 1             # <<<<<<<<<<<<<<
 
4387
 *         while last_item >= 0:
 
4388
 *             node = _get_list_node(pending, last_item)
 
4389
 */
 
4390
  __pyx_v_last_item = (PyList_GET_SIZE(((PyObject *)__pyx_v_pending)) - 1);
 
4391
 
 
4392
  /* "bzrlib/_known_graph_pyx.pyx":473
 
4393
 *         # Now do all the real work
 
4394
 *         last_item = PyList_GET_SIZE(pending) - 1
 
4395
 *         while last_item >= 0:             # <<<<<<<<<<<<<<
 
4396
 *             node = _get_list_node(pending, last_item)
 
4397
 *             last_item = last_item - 1
 
4398
 */
 
4399
  while (1) {
 
4400
    __pyx_t_7 = (__pyx_v_last_item >= 0);
 
4401
    if (!__pyx_t_7) break;
 
4402
 
 
4403
    /* "bzrlib/_known_graph_pyx.pyx":474
 
4404
 *         last_item = PyList_GET_SIZE(pending) - 1
 
4405
 *         while last_item >= 0:
 
4406
 *             node = _get_list_node(pending, last_item)             # <<<<<<<<<<<<<<
 
4407
 *             last_item = last_item - 1
 
4408
 *             if node.seen:
 
4409
 */
 
4410
    __pyx_t_2 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(((PyObject *)__pyx_v_pending), __pyx_v_last_item)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4411
    __Pyx_GOTREF(__pyx_t_2);
 
4412
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
4413
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_2);
 
4414
    __pyx_t_2 = 0;
 
4415
 
 
4416
    /* "bzrlib/_known_graph_pyx.pyx":475
 
4417
 *         while last_item >= 0:
 
4418
 *             node = _get_list_node(pending, last_item)
 
4419
 *             last_item = last_item - 1             # <<<<<<<<<<<<<<
 
4420
 *             if node.seen:
 
4421
 *                 # node already appears in some ancestry
 
4422
 */
 
4423
    __pyx_v_last_item = (__pyx_v_last_item - 1);
 
4424
 
 
4425
    /* "bzrlib/_known_graph_pyx.pyx":476
 
4426
 *             node = _get_list_node(pending, last_item)
 
4427
 *             last_item = last_item - 1
 
4428
 *             if node.seen:             # <<<<<<<<<<<<<<
 
4429
 *                 # node already appears in some ancestry
 
4430
 *                 continue
 
4431
 */
 
4432
    if (__pyx_v_node->seen) {
 
4433
 
 
4434
      /* "bzrlib/_known_graph_pyx.pyx":478
 
4435
 *             if node.seen:
 
4436
 *                 # node already appears in some ancestry
 
4437
 *                 continue             # <<<<<<<<<<<<<<
 
4438
 *             PyList_Append(cleanup, node)
 
4439
 *             node.seen = 1
 
4440
 */
 
4441
      goto __pyx_L16_continue;
 
4442
      goto __pyx_L18;
 
4443
    }
 
4444
    __pyx_L18:;
 
4445
 
 
4446
    /* "bzrlib/_known_graph_pyx.pyx":479
 
4447
 *                 # node already appears in some ancestry
 
4448
 *                 continue
 
4449
 *             PyList_Append(cleanup, node)             # <<<<<<<<<<<<<<
 
4450
 *             node.seen = 1
 
4451
 *             if node.gdfo <= min_gdfo:
 
4452
 */
 
4453
    __pyx_t_6 = PyList_Append(((PyObject *)__pyx_v_cleanup), ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4454
 
 
4455
    /* "bzrlib/_known_graph_pyx.pyx":480
 
4456
 *                 continue
 
4457
 *             PyList_Append(cleanup, node)
 
4458
 *             node.seen = 1             # <<<<<<<<<<<<<<
 
4459
 *             if node.gdfo <= min_gdfo:
 
4460
 *                 continue
 
4461
 */
 
4462
    __pyx_v_node->seen = 1;
 
4463
 
 
4464
    /* "bzrlib/_known_graph_pyx.pyx":481
 
4465
 *             PyList_Append(cleanup, node)
 
4466
 *             node.seen = 1
 
4467
 *             if node.gdfo <= min_gdfo:             # <<<<<<<<<<<<<<
 
4468
 *                 continue
 
4469
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:
 
4470
 */
 
4471
    __pyx_t_7 = (__pyx_v_node->gdfo <= __pyx_v_min_gdfo);
 
4472
    if (__pyx_t_7) {
 
4473
 
 
4474
      /* "bzrlib/_known_graph_pyx.pyx":482
 
4475
 *             node.seen = 1
 
4476
 *             if node.gdfo <= min_gdfo:
 
4477
 *                 continue             # <<<<<<<<<<<<<<
 
4478
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:
 
4479
 *                 for pos from 0 <= pos < PyTuple_GET_SIZE(node.parents):
 
4480
 */
 
4481
      goto __pyx_L16_continue;
 
4482
      goto __pyx_L19;
 
4483
    }
 
4484
    __pyx_L19:;
 
4485
 
 
4486
    /* "bzrlib/_known_graph_pyx.pyx":483
 
4487
 *             if node.gdfo <= min_gdfo:
 
4488
 *                 continue
 
4489
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:             # <<<<<<<<<<<<<<
 
4490
 *                 for pos from 0 <= pos < PyTuple_GET_SIZE(node.parents):
 
4491
 *                     parent_node = _get_tuple_node(node.parents, pos)
 
4492
 */
 
4493
    __pyx_t_7 = (__pyx_v_node->parents != Py_None);
 
4494
    if (__pyx_t_7) {
 
4495
      __pyx_t_2 = __pyx_v_node->parents;
 
4496
      __Pyx_INCREF(__pyx_t_2);
 
4497
      __pyx_t_3 = (PyTuple_GET_SIZE(__pyx_t_2) > 0);
 
4498
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
4499
      __pyx_t_8 = __pyx_t_3;
 
4500
    } else {
 
4501
      __pyx_t_8 = __pyx_t_7;
 
4502
    }
 
4503
    if (__pyx_t_8) {
 
4504
 
 
4505
      /* "bzrlib/_known_graph_pyx.pyx":484
 
4506
 *                 continue
 
4507
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:
 
4508
 *                 for pos from 0 <= pos < PyTuple_GET_SIZE(node.parents):             # <<<<<<<<<<<<<<
 
4509
 *                     parent_node = _get_tuple_node(node.parents, pos)
 
4510
 *                     last_item = last_item + 1
 
4511
 */
 
4512
      __pyx_t_2 = __pyx_v_node->parents;
 
4513
      __Pyx_INCREF(__pyx_t_2);
 
4514
      __pyx_t_4 = PyTuple_GET_SIZE(__pyx_t_2);
 
4515
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
4516
      for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_4; __pyx_v_pos++) {
 
4517
 
 
4518
        /* "bzrlib/_known_graph_pyx.pyx":485
 
4519
 *             if node.parents is not None and PyTuple_GET_SIZE(node.parents) > 0:
 
4520
 *                 for pos from 0 <= pos < PyTuple_GET_SIZE(node.parents):
 
4521
 *                     parent_node = _get_tuple_node(node.parents, pos)             # <<<<<<<<<<<<<<
 
4522
 *                     last_item = last_item + 1
 
4523
 *                     if last_item < PyList_GET_SIZE(pending):
 
4524
 */
 
4525
        __pyx_t_2 = __pyx_v_node->parents;
 
4526
        __Pyx_INCREF(__pyx_t_2);
 
4527
        __pyx_t_1 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_tuple_node(__pyx_t_2, __pyx_v_pos)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4528
        __Pyx_GOTREF(__pyx_t_1);
 
4529
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
4530
        __Pyx_DECREF(((PyObject *)__pyx_v_parent_node));
 
4531
        __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
 
4532
        __pyx_t_1 = 0;
 
4533
 
 
4534
        /* "bzrlib/_known_graph_pyx.pyx":486
 
4535
 *                 for pos from 0 <= pos < PyTuple_GET_SIZE(node.parents):
 
4536
 *                     parent_node = _get_tuple_node(node.parents, pos)
 
4537
 *                     last_item = last_item + 1             # <<<<<<<<<<<<<<
 
4538
 *                     if last_item < PyList_GET_SIZE(pending):
 
4539
 *                         Py_INCREF(parent_node) # SetItem steals a ref
 
4540
 */
 
4541
        __pyx_v_last_item = (__pyx_v_last_item + 1);
 
4542
 
 
4543
        /* "bzrlib/_known_graph_pyx.pyx":487
 
4544
 *                     parent_node = _get_tuple_node(node.parents, pos)
 
4545
 *                     last_item = last_item + 1
 
4546
 *                     if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 
4547
 *                         Py_INCREF(parent_node) # SetItem steals a ref
 
4548
 *                         PyList_SetItem(pending, last_item, parent_node)
 
4549
 */
 
4550
        __pyx_t_8 = (__pyx_v_last_item < PyList_GET_SIZE(((PyObject *)__pyx_v_pending)));
 
4551
        if (__pyx_t_8) {
 
4552
 
 
4553
          /* "bzrlib/_known_graph_pyx.pyx":488
 
4554
 *                     last_item = last_item + 1
 
4555
 *                     if last_item < PyList_GET_SIZE(pending):
 
4556
 *                         Py_INCREF(parent_node) # SetItem steals a ref             # <<<<<<<<<<<<<<
 
4557
 *                         PyList_SetItem(pending, last_item, parent_node)
 
4558
 *                     else:
 
4559
 */
 
4560
          Py_INCREF(((PyObject *)__pyx_v_parent_node));
 
4561
 
 
4562
          /* "bzrlib/_known_graph_pyx.pyx":489
 
4563
 *                     if last_item < PyList_GET_SIZE(pending):
 
4564
 *                         Py_INCREF(parent_node) # SetItem steals a ref
 
4565
 *                         PyList_SetItem(pending, last_item, parent_node)             # <<<<<<<<<<<<<<
 
4566
 *                     else:
 
4567
 *                         PyList_Append(pending, parent_node)
 
4568
 */
 
4569
          __pyx_t_6 = PyList_SetItem(((PyObject *)__pyx_v_pending), __pyx_v_last_item, ((PyObject *)__pyx_v_parent_node)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4570
          goto __pyx_L23;
 
4571
        }
 
4572
        /*else*/ {
 
4573
 
 
4574
          /* "bzrlib/_known_graph_pyx.pyx":491
 
4575
 *                         PyList_SetItem(pending, last_item, parent_node)
 
4576
 *                     else:
 
4577
 *                         PyList_Append(pending, parent_node)             # <<<<<<<<<<<<<<
 
4578
 *         heads = []
 
4579
 *         pos = 0
 
4580
 */
 
4581
          __pyx_t_6 = PyList_Append(((PyObject *)__pyx_v_pending), ((PyObject *)__pyx_v_parent_node)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4582
        }
 
4583
        __pyx_L23:;
 
4584
      }
 
4585
      goto __pyx_L20;
 
4586
    }
 
4587
    __pyx_L20:;
 
4588
    __pyx_L16_continue:;
 
4589
  }
 
4590
 
 
4591
  /* "bzrlib/_known_graph_pyx.pyx":492
 
4592
 *                     else:
 
4593
 *                         PyList_Append(pending, parent_node)
 
4594
 *         heads = []             # <<<<<<<<<<<<<<
 
4595
 *         pos = 0
 
4596
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 
4597
 */
 
4598
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4599
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
4600
  __Pyx_DECREF(__pyx_v_heads);
 
4601
  __pyx_v_heads = ((PyObject *)__pyx_t_1);
 
4602
  __pyx_t_1 = 0;
 
4603
 
 
4604
  /* "bzrlib/_known_graph_pyx.pyx":493
 
4605
 *                         PyList_Append(pending, parent_node)
 
4606
 *         heads = []
 
4607
 *         pos = 0             # <<<<<<<<<<<<<<
 
4608
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 
4609
 *             node = <_KnownGraphNode>temp_node
 
4610
 */
 
4611
  __pyx_v_pos = 0;
 
4612
 
 
4613
  /* "bzrlib/_known_graph_pyx.pyx":494
 
4614
 *         heads = []
 
4615
 *         pos = 0
 
4616
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):             # <<<<<<<<<<<<<<
 
4617
 *             node = <_KnownGraphNode>temp_node
 
4618
 *             if not node.seen:
 
4619
 */
 
4620
  while (1) {
 
4621
    __pyx_t_6 = PyDict_Next(((PyObject *)__pyx_v_candidate_nodes), (&__pyx_v_pos), NULL, (&__pyx_v_temp_node));
 
4622
    if (!__pyx_t_6) break;
 
4623
 
 
4624
    /* "bzrlib/_known_graph_pyx.pyx":495
 
4625
 *         pos = 0
 
4626
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 
4627
 *             node = <_KnownGraphNode>temp_node             # <<<<<<<<<<<<<<
 
4628
 *             if not node.seen:
 
4629
 *                 PyList_Append(heads, node.key)
 
4630
 */
 
4631
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node)));
 
4632
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
4633
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_v_temp_node);
 
4634
 
 
4635
    /* "bzrlib/_known_graph_pyx.pyx":496
 
4636
 *         while PyDict_Next(candidate_nodes, &pos, NULL, &temp_node):
 
4637
 *             node = <_KnownGraphNode>temp_node
 
4638
 *             if not node.seen:             # <<<<<<<<<<<<<<
 
4639
 *                 PyList_Append(heads, node.key)
 
4640
 *         heads = frozenset(heads)
 
4641
 */
 
4642
    __pyx_t_8 = (!__pyx_v_node->seen);
 
4643
    if (__pyx_t_8) {
 
4644
 
 
4645
      /* "bzrlib/_known_graph_pyx.pyx":497
 
4646
 *             node = <_KnownGraphNode>temp_node
 
4647
 *             if not node.seen:
 
4648
 *                 PyList_Append(heads, node.key)             # <<<<<<<<<<<<<<
 
4649
 *         heads = frozenset(heads)
 
4650
 *         for pos from 0 <= pos < PyList_GET_SIZE(cleanup):
 
4651
 */
 
4652
      __pyx_t_1 = __pyx_v_node->key;
 
4653
      __Pyx_INCREF(__pyx_t_1);
 
4654
      __pyx_t_6 = PyList_Append(__pyx_v_heads, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4655
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
4656
      goto __pyx_L26;
 
4657
    }
 
4658
    __pyx_L26:;
 
4659
  }
 
4660
 
 
4661
  /* "bzrlib/_known_graph_pyx.pyx":498
 
4662
 *             if not node.seen:
 
4663
 *                 PyList_Append(heads, node.key)
 
4664
 *         heads = frozenset(heads)             # <<<<<<<<<<<<<<
 
4665
 *         for pos from 0 <= pos < PyList_GET_SIZE(cleanup):
 
4666
 *             node = _get_list_node(cleanup, pos)
 
4667
 */
 
4668
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4669
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
4670
  __Pyx_INCREF(__pyx_v_heads);
 
4671
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_heads);
 
4672
  __Pyx_GIVEREF(__pyx_v_heads);
 
4673
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyFrozenSet_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4674
  __Pyx_GOTREF(__pyx_t_2);
 
4675
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
4676
  __Pyx_DECREF(__pyx_v_heads);
 
4677
  __pyx_v_heads = __pyx_t_2;
 
4678
  __pyx_t_2 = 0;
 
4679
 
 
4680
  /* "bzrlib/_known_graph_pyx.pyx":499
 
4681
 *                 PyList_Append(heads, node.key)
 
4682
 *         heads = frozenset(heads)
 
4683
 *         for pos from 0 <= pos < PyList_GET_SIZE(cleanup):             # <<<<<<<<<<<<<<
 
4684
 *             node = _get_list_node(cleanup, pos)
 
4685
 *             node.seen = 0
 
4686
 */
 
4687
  __pyx_t_4 = PyList_GET_SIZE(((PyObject *)__pyx_v_cleanup));
 
4688
  for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_4; __pyx_v_pos++) {
 
4689
 
 
4690
    /* "bzrlib/_known_graph_pyx.pyx":500
 
4691
 *         heads = frozenset(heads)
 
4692
 *         for pos from 0 <= pos < PyList_GET_SIZE(cleanup):
 
4693
 *             node = _get_list_node(cleanup, pos)             # <<<<<<<<<<<<<<
 
4694
 *             node.seen = 0
 
4695
 *         if self.do_cache:
 
4696
 */
 
4697
    __pyx_t_2 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(((PyObject *)__pyx_v_cleanup), __pyx_v_pos)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4698
    __Pyx_GOTREF(__pyx_t_2);
 
4699
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
4700
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_2);
 
4701
    __pyx_t_2 = 0;
 
4702
 
 
4703
    /* "bzrlib/_known_graph_pyx.pyx":501
 
4704
 *         for pos from 0 <= pos < PyList_GET_SIZE(cleanup):
 
4705
 *             node = _get_list_node(cleanup, pos)
 
4706
 *             node.seen = 0             # <<<<<<<<<<<<<<
 
4707
 *         if self.do_cache:
 
4708
 *             PyDict_SetItem(self._known_heads, heads_key, heads)
 
4709
 */
 
4710
    __pyx_v_node->seen = 0;
 
4711
  }
 
4712
 
 
4713
  /* "bzrlib/_known_graph_pyx.pyx":502
 
4714
 *             node = _get_list_node(cleanup, pos)
 
4715
 *             node.seen = 0
 
4716
 *         if self.do_cache:             # <<<<<<<<<<<<<<
 
4717
 *             PyDict_SetItem(self._known_heads, heads_key, heads)
 
4718
 *         return heads
 
4719
 */
 
4720
  if (((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->do_cache) {
 
4721
 
 
4722
    /* "bzrlib/_known_graph_pyx.pyx":503
 
4723
 *             node.seen = 0
 
4724
 *         if self.do_cache:
 
4725
 *             PyDict_SetItem(self._known_heads, heads_key, heads)             # <<<<<<<<<<<<<<
 
4726
 *         return heads
 
4727
 * 
 
4728
 */
 
4729
    __pyx_t_2 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads;
 
4730
    __Pyx_INCREF(__pyx_t_2);
 
4731
    __pyx_t_6 = PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_v_heads_key), __pyx_v_heads); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4732
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
4733
    goto __pyx_L29;
 
4734
  }
 
4735
  __pyx_L29:;
 
4736
 
 
4737
  /* "bzrlib/_known_graph_pyx.pyx":504
 
4738
 *         if self.do_cache:
 
4739
 *             PyDict_SetItem(self._known_heads, heads_key, heads)
 
4740
 *         return heads             # <<<<<<<<<<<<<<
 
4741
 * 
 
4742
 *     def topo_sort(self):
 
4743
 */
 
4744
  __Pyx_XDECREF(__pyx_r);
 
4745
  __Pyx_INCREF(__pyx_v_heads);
 
4746
  __pyx_r = __pyx_v_heads;
 
4747
  goto __pyx_L0;
 
4748
 
 
4749
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
4750
  goto __pyx_L0;
 
4751
  __pyx_L1_error:;
 
4752
  __Pyx_XDECREF(__pyx_t_1);
 
4753
  __Pyx_XDECREF(__pyx_t_2);
 
4754
  __Pyx_XDECREF(__pyx_t_5);
 
4755
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.heads");
 
4756
  __pyx_r = NULL;
 
4757
  __pyx_L0:;
 
4758
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
4759
  __Pyx_DECREF(__pyx_v_heads_key);
 
4760
  __Pyx_DECREF(__pyx_v_candidate_nodes);
 
4761
  __Pyx_DECREF(__pyx_v_key);
 
4762
  __Pyx_DECREF(__pyx_v_cleanup);
 
4763
  __Pyx_DECREF(__pyx_v_pending);
 
4764
  __Pyx_DECREF((PyObject *)__pyx_v_parent_node);
 
4765
  __Pyx_DECREF(__pyx_v_heads);
 
4766
  __Pyx_XGIVEREF(__pyx_r);
 
4767
  __Pyx_RefNannyFinishContext();
 
4768
  return __pyx_r;
 
4769
}
 
4770
 
 
4771
/* "bzrlib/_known_graph_pyx.pyx":506
 
4772
 *         return heads
 
4773
 * 
 
4774
 *     def topo_sort(self):             # <<<<<<<<<<<<<<
 
4775
 *         """Return the nodes in topological order.
 
4776
 * 
 
4777
 */
 
4778
 
 
4779
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_8topo_sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
 
4780
static char __pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_8topo_sort[] = "Return the nodes in topological order.\n\n        All parents must occur before all children.\n        ";
 
4781
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_8topo_sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
 
4782
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
4783
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_child;
 
4784
  Py_ssize_t __pyx_v_pos;
 
4785
  Py_ssize_t __pyx_v_last_item;
 
4786
  PyObject *__pyx_v_pending;
 
4787
  PyObject *__pyx_v_topo_order;
 
4788
  PyObject *__pyx_r = NULL;
 
4789
  PyObject *__pyx_t_1 = NULL;
 
4790
  PyObject *__pyx_t_2 = NULL;
 
4791
  int __pyx_t_3;
 
4792
  Py_ssize_t __pyx_t_4;
 
4793
  int __pyx_t_5;
 
4794
  int __pyx_t_6;
 
4795
  PyObject *__pyx_t_7 = NULL;
 
4796
  int __pyx_t_8;
 
4797
  __Pyx_RefNannySetupContext("topo_sort");
 
4798
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
4799
  __pyx_v_child = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
4800
  __pyx_v_pending = Py_None; __Pyx_INCREF(Py_None);
 
4801
  __pyx_v_topo_order = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
4802
 
 
4803
  /* "bzrlib/_known_graph_pyx.pyx":523
 
4804
 *         cdef Py_ssize_t last_item
 
4805
 * 
 
4806
 *         pending = self._find_tails()             # <<<<<<<<<<<<<<
 
4807
 *         if PyList_GET_SIZE(pending) == 0 and len(self._nodes) > 0:
 
4808
 *             raise errors.GraphCycleError(self._nodes)
 
4809
 */
 
4810
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___find_tails); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4811
  __Pyx_GOTREF(__pyx_t_1);
 
4812
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4813
  __Pyx_GOTREF(__pyx_t_2);
 
4814
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
4815
  __Pyx_DECREF(__pyx_v_pending);
 
4816
  __pyx_v_pending = __pyx_t_2;
 
4817
  __pyx_t_2 = 0;
 
4818
 
 
4819
  /* "bzrlib/_known_graph_pyx.pyx":524
 
4820
 * 
 
4821
 *         pending = self._find_tails()
 
4822
 *         if PyList_GET_SIZE(pending) == 0 and len(self._nodes) > 0:             # <<<<<<<<<<<<<<
 
4823
 *             raise errors.GraphCycleError(self._nodes)
 
4824
 * 
 
4825
 */
 
4826
  __pyx_t_3 = (PyList_GET_SIZE(__pyx_v_pending) == 0);
 
4827
  if (__pyx_t_3) {
 
4828
    __pyx_t_2 = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes;
 
4829
    __Pyx_INCREF(__pyx_t_2);
 
4830
    __pyx_t_4 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4831
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
4832
    __pyx_t_5 = (__pyx_t_4 > 0);
 
4833
    __pyx_t_6 = __pyx_t_5;
 
4834
  } else {
 
4835
    __pyx_t_6 = __pyx_t_3;
 
4836
  }
 
4837
  if (__pyx_t_6) {
 
4838
 
 
4839
    /* "bzrlib/_known_graph_pyx.pyx":525
 
4840
 *         pending = self._find_tails()
 
4841
 *         if PyList_GET_SIZE(pending) == 0 and len(self._nodes) > 0:
 
4842
 *             raise errors.GraphCycleError(self._nodes)             # <<<<<<<<<<<<<<
 
4843
 * 
 
4844
 *         topo_order = []
 
4845
 */
 
4846
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__errors); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4847
    __Pyx_GOTREF(__pyx_t_2);
 
4848
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__GraphCycleError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4849
    __Pyx_GOTREF(__pyx_t_1);
 
4850
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
4851
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4852
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
4853
    __Pyx_INCREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
4854
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
4855
    __Pyx_GIVEREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
4856
    __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4857
    __Pyx_GOTREF(__pyx_t_7);
 
4858
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
4859
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
4860
    __Pyx_Raise(__pyx_t_7, 0, 0);
 
4861
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
4862
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4863
    goto __pyx_L5;
 
4864
  }
 
4865
  __pyx_L5:;
 
4866
 
 
4867
  /* "bzrlib/_known_graph_pyx.pyx":527
 
4868
 *             raise errors.GraphCycleError(self._nodes)
 
4869
 * 
 
4870
 *         topo_order = []             # <<<<<<<<<<<<<<
 
4871
 * 
 
4872
 *         last_item = PyList_GET_SIZE(pending) - 1
 
4873
 */
 
4874
  __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4875
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
 
4876
  __Pyx_DECREF(((PyObject *)__pyx_v_topo_order));
 
4877
  __pyx_v_topo_order = __pyx_t_7;
 
4878
  __pyx_t_7 = 0;
 
4879
 
 
4880
  /* "bzrlib/_known_graph_pyx.pyx":529
 
4881
 *         topo_order = []
 
4882
 * 
 
4883
 *         last_item = PyList_GET_SIZE(pending) - 1             # <<<<<<<<<<<<<<
 
4884
 *         while last_item >= 0:
 
4885
 *             # Avoid pop followed by push, instead, peek, and replace
 
4886
 */
 
4887
  __pyx_v_last_item = (PyList_GET_SIZE(__pyx_v_pending) - 1);
 
4888
 
 
4889
  /* "bzrlib/_known_graph_pyx.pyx":530
 
4890
 * 
 
4891
 *         last_item = PyList_GET_SIZE(pending) - 1
 
4892
 *         while last_item >= 0:             # <<<<<<<<<<<<<<
 
4893
 *             # Avoid pop followed by push, instead, peek, and replace
 
4894
 *             # timing shows this is 930ms => 770ms for OOo
 
4895
 */
 
4896
  while (1) {
 
4897
    __pyx_t_6 = (__pyx_v_last_item >= 0);
 
4898
    if (!__pyx_t_6) break;
 
4899
 
 
4900
    /* "bzrlib/_known_graph_pyx.pyx":533
 
4901
 *             # Avoid pop followed by push, instead, peek, and replace
 
4902
 *             # timing shows this is 930ms => 770ms for OOo
 
4903
 *             node = _get_list_node(pending, last_item)             # <<<<<<<<<<<<<<
 
4904
 *             last_item = last_item - 1
 
4905
 *             if node.parents is not None:
 
4906
 */
 
4907
    __pyx_t_7 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_v_pending, __pyx_v_last_item)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4908
    __Pyx_GOTREF(__pyx_t_7);
 
4909
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
4910
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_7);
 
4911
    __pyx_t_7 = 0;
 
4912
 
 
4913
    /* "bzrlib/_known_graph_pyx.pyx":534
 
4914
 *             # timing shows this is 930ms => 770ms for OOo
 
4915
 *             node = _get_list_node(pending, last_item)
 
4916
 *             last_item = last_item - 1             # <<<<<<<<<<<<<<
 
4917
 *             if node.parents is not None:
 
4918
 *                 # We don't include ghost parents
 
4919
 */
 
4920
    __pyx_v_last_item = (__pyx_v_last_item - 1);
 
4921
 
 
4922
    /* "bzrlib/_known_graph_pyx.pyx":535
 
4923
 *             node = _get_list_node(pending, last_item)
 
4924
 *             last_item = last_item - 1
 
4925
 *             if node.parents is not None:             # <<<<<<<<<<<<<<
 
4926
 *                 # We don't include ghost parents
 
4927
 *                 PyList_Append(topo_order, node.key)
 
4928
 */
 
4929
    __pyx_t_6 = (__pyx_v_node->parents != Py_None);
 
4930
    if (__pyx_t_6) {
 
4931
 
 
4932
      /* "bzrlib/_known_graph_pyx.pyx":537
 
4933
 *             if node.parents is not None:
 
4934
 *                 # We don't include ghost parents
 
4935
 *                 PyList_Append(topo_order, node.key)             # <<<<<<<<<<<<<<
 
4936
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 
4937
 *                 child = _get_list_node(node.children, pos)
 
4938
 */
 
4939
      __pyx_t_7 = __pyx_v_node->key;
 
4940
      __Pyx_INCREF(__pyx_t_7);
 
4941
      __pyx_t_8 = PyList_Append(((PyObject *)__pyx_v_topo_order), __pyx_t_7); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4942
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
4943
      goto __pyx_L8;
 
4944
    }
 
4945
    __pyx_L8:;
 
4946
 
 
4947
    /* "bzrlib/_known_graph_pyx.pyx":538
 
4948
 *                 # We don't include ghost parents
 
4949
 *                 PyList_Append(topo_order, node.key)
 
4950
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):             # <<<<<<<<<<<<<<
 
4951
 *                 child = _get_list_node(node.children, pos)
 
4952
 *                 if child.gdfo == -1:
 
4953
 */
 
4954
    __pyx_t_7 = __pyx_v_node->children;
 
4955
    __Pyx_INCREF(__pyx_t_7);
 
4956
    __pyx_t_4 = PyList_GET_SIZE(__pyx_t_7);
 
4957
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
4958
    for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_4; __pyx_v_pos++) {
 
4959
 
 
4960
      /* "bzrlib/_known_graph_pyx.pyx":539
 
4961
 *                 PyList_Append(topo_order, node.key)
 
4962
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 
4963
 *                 child = _get_list_node(node.children, pos)             # <<<<<<<<<<<<<<
 
4964
 *                 if child.gdfo == -1:
 
4965
 *                     # We know we have a graph cycle because a node has a parent
 
4966
 */
 
4967
      __pyx_t_7 = __pyx_v_node->children;
 
4968
      __Pyx_INCREF(__pyx_t_7);
 
4969
      __pyx_t_2 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_t_7, __pyx_v_pos)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4970
      __Pyx_GOTREF(__pyx_t_2);
 
4971
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
4972
      __Pyx_DECREF(((PyObject *)__pyx_v_child));
 
4973
      __pyx_v_child = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_2);
 
4974
      __pyx_t_2 = 0;
 
4975
 
 
4976
      /* "bzrlib/_known_graph_pyx.pyx":540
 
4977
 *             for pos from 0 <= pos < PyList_GET_SIZE(node.children):
 
4978
 *                 child = _get_list_node(node.children, pos)
 
4979
 *                 if child.gdfo == -1:             # <<<<<<<<<<<<<<
 
4980
 *                     # We know we have a graph cycle because a node has a parent
 
4981
 *                     # which we couldn't find
 
4982
 */
 
4983
      __pyx_t_6 = (__pyx_v_child->gdfo == -1);
 
4984
      if (__pyx_t_6) {
 
4985
 
 
4986
        /* "bzrlib/_known_graph_pyx.pyx":543
 
4987
 *                     # We know we have a graph cycle because a node has a parent
 
4988
 *                     # which we couldn't find
 
4989
 *                     raise errors.GraphCycleError(self._nodes)             # <<<<<<<<<<<<<<
 
4990
 *                 child.seen = child.seen + 1
 
4991
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):
 
4992
 */
 
4993
        __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__errors); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4994
        __Pyx_GOTREF(__pyx_t_2);
 
4995
        __pyx_t_7 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__GraphCycleError); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4996
        __Pyx_GOTREF(__pyx_t_7);
 
4997
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
4998
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4999
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
5000
        __Pyx_INCREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
5001
        PyTuple_SET_ITEM(__pyx_t_2, 0, ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
5002
        __Pyx_GIVEREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
5003
        __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5004
        __Pyx_GOTREF(__pyx_t_1);
 
5005
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
5006
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
5007
        __Pyx_Raise(__pyx_t_1, 0, 0);
 
5008
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
5009
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5010
        goto __pyx_L11;
 
5011
      }
 
5012
      __pyx_L11:;
 
5013
 
 
5014
      /* "bzrlib/_known_graph_pyx.pyx":544
 
5015
 *                     # which we couldn't find
 
5016
 *                     raise errors.GraphCycleError(self._nodes)
 
5017
 *                 child.seen = child.seen + 1             # <<<<<<<<<<<<<<
 
5018
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):
 
5019
 *                     # All parents of this child have been yielded, queue this
 
5020
 */
 
5021
      __pyx_v_child->seen = (__pyx_v_child->seen + 1);
 
5022
 
 
5023
      /* "bzrlib/_known_graph_pyx.pyx":545
 
5024
 *                     raise errors.GraphCycleError(self._nodes)
 
5025
 *                 child.seen = child.seen + 1
 
5026
 *                 if child.seen == PyTuple_GET_SIZE(child.parents):             # <<<<<<<<<<<<<<
 
5027
 *                     # All parents of this child have been yielded, queue this
 
5028
 *                     # one to be yielded as well
 
5029
 */
 
5030
      __pyx_t_1 = __pyx_v_child->parents;
 
5031
      __Pyx_INCREF(__pyx_t_1);
 
5032
      __pyx_t_6 = (__pyx_v_child->seen == PyTuple_GET_SIZE(__pyx_t_1));
 
5033
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
5034
      if (__pyx_t_6) {
 
5035
 
 
5036
        /* "bzrlib/_known_graph_pyx.pyx":548
 
5037
 *                     # All parents of this child have been yielded, queue this
 
5038
 *                     # one to be yielded as well
 
5039
 *                     last_item = last_item + 1             # <<<<<<<<<<<<<<
 
5040
 *                     if last_item < PyList_GET_SIZE(pending):
 
5041
 *                         Py_INCREF(child) # SetItem steals a ref
 
5042
 */
 
5043
        __pyx_v_last_item = (__pyx_v_last_item + 1);
 
5044
 
 
5045
        /* "bzrlib/_known_graph_pyx.pyx":549
 
5046
 *                     # one to be yielded as well
 
5047
 *                     last_item = last_item + 1
 
5048
 *                     if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 
5049
 *                         Py_INCREF(child) # SetItem steals a ref
 
5050
 *                         PyList_SetItem(pending, last_item, child)
 
5051
 */
 
5052
        __pyx_t_6 = (__pyx_v_last_item < PyList_GET_SIZE(__pyx_v_pending));
 
5053
        if (__pyx_t_6) {
 
5054
 
 
5055
          /* "bzrlib/_known_graph_pyx.pyx":550
 
5056
 *                     last_item = last_item + 1
 
5057
 *                     if last_item < PyList_GET_SIZE(pending):
 
5058
 *                         Py_INCREF(child) # SetItem steals a ref             # <<<<<<<<<<<<<<
 
5059
 *                         PyList_SetItem(pending, last_item, child)
 
5060
 *                     else:
 
5061
 */
 
5062
          Py_INCREF(((PyObject *)__pyx_v_child));
 
5063
 
 
5064
          /* "bzrlib/_known_graph_pyx.pyx":551
 
5065
 *                     if last_item < PyList_GET_SIZE(pending):
 
5066
 *                         Py_INCREF(child) # SetItem steals a ref
 
5067
 *                         PyList_SetItem(pending, last_item, child)             # <<<<<<<<<<<<<<
 
5068
 *                     else:
 
5069
 *                         PyList_Append(pending, child)
 
5070
 */
 
5071
          __pyx_t_8 = PyList_SetItem(__pyx_v_pending, __pyx_v_last_item, ((PyObject *)__pyx_v_child)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5072
          goto __pyx_L13;
 
5073
        }
 
5074
        /*else*/ {
 
5075
 
 
5076
          /* "bzrlib/_known_graph_pyx.pyx":553
 
5077
 *                         PyList_SetItem(pending, last_item, child)
 
5078
 *                     else:
 
5079
 *                         PyList_Append(pending, child)             # <<<<<<<<<<<<<<
 
5080
 *                     # We have queued this node, we don't need to track it
 
5081
 *                     # anymore
 
5082
 */
 
5083
          __pyx_t_8 = PyList_Append(__pyx_v_pending, ((PyObject *)__pyx_v_child)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5084
        }
 
5085
        __pyx_L13:;
 
5086
 
 
5087
        /* "bzrlib/_known_graph_pyx.pyx":556
 
5088
 *                     # We have queued this node, we don't need to track it
 
5089
 *                     # anymore
 
5090
 *                     child.seen = 0             # <<<<<<<<<<<<<<
 
5091
 *         # We started from the parents, so we don't need to do anymore work
 
5092
 *         return topo_order
 
5093
 */
 
5094
        __pyx_v_child->seen = 0;
 
5095
        goto __pyx_L12;
 
5096
      }
 
5097
      __pyx_L12:;
 
5098
    }
 
5099
  }
 
5100
 
 
5101
  /* "bzrlib/_known_graph_pyx.pyx":558
 
5102
 *                     child.seen = 0
 
5103
 *         # We started from the parents, so we don't need to do anymore work
 
5104
 *         return topo_order             # <<<<<<<<<<<<<<
 
5105
 * 
 
5106
 *     def gc_sort(self):
 
5107
 */
 
5108
  __Pyx_XDECREF(__pyx_r);
 
5109
  __Pyx_INCREF(((PyObject *)__pyx_v_topo_order));
 
5110
  __pyx_r = ((PyObject *)__pyx_v_topo_order);
 
5111
  goto __pyx_L0;
 
5112
 
 
5113
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
5114
  goto __pyx_L0;
 
5115
  __pyx_L1_error:;
 
5116
  __Pyx_XDECREF(__pyx_t_1);
 
5117
  __Pyx_XDECREF(__pyx_t_2);
 
5118
  __Pyx_XDECREF(__pyx_t_7);
 
5119
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.topo_sort");
 
5120
  __pyx_r = NULL;
 
5121
  __pyx_L0:;
 
5122
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
5123
  __Pyx_DECREF((PyObject *)__pyx_v_child);
 
5124
  __Pyx_DECREF(__pyx_v_pending);
 
5125
  __Pyx_DECREF(__pyx_v_topo_order);
 
5126
  __Pyx_XGIVEREF(__pyx_r);
 
5127
  __Pyx_RefNannyFinishContext();
 
5128
  return __pyx_r;
 
5129
}
 
5130
 
 
5131
/* "bzrlib/_known_graph_pyx.pyx":560
 
5132
 *         return topo_order
 
5133
 * 
 
5134
 *     def gc_sort(self):             # <<<<<<<<<<<<<<
 
5135
 *         """Return a reverse topological ordering which is 'stable'.
 
5136
 * 
 
5137
 */
 
5138
 
 
5139
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_9gc_sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
 
5140
static char __pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_9gc_sort[] = "Return a reverse topological ordering which is 'stable'.\n\n        There are a few constraints:\n          1) Reverse topological (all children before all parents)\n          2) Grouped by prefix\n          3) 'stable' sorting, so that we get the same result, independent of\n             machine, or extra data.\n        To do this, we use the same basic algorithm as topo_sort, but when we\n        aren't sure what node to access next, we sort them lexicographically.\n        ";
 
5141
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_9gc_sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
 
5142
  PyObject *__pyx_v_temp;
 
5143
  Py_ssize_t __pyx_v_pos;
 
5144
  Py_ssize_t __pyx_v_last_item;
 
5145
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
5146
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent_node;
 
5147
  PyObject *__pyx_v_tips;
 
5148
  PyObject *__pyx_v_prefix_tips;
 
5149
  PyObject *__pyx_v_prefix;
 
5150
  PyObject *__pyx_v_tip_nodes;
 
5151
  PyObject *__pyx_v_result;
 
5152
  PyObject *__pyx_v_pending;
 
5153
  PyObject *__pyx_v_parents;
 
5154
  PyObject *__pyx_r = NULL;
 
5155
  PyObject *__pyx_t_1 = NULL;
 
5156
  PyObject *__pyx_t_2 = NULL;
 
5157
  Py_ssize_t __pyx_t_3;
 
5158
  Py_ssize_t __pyx_t_4;
 
5159
  int __pyx_t_5;
 
5160
  int __pyx_t_6;
 
5161
  int __pyx_t_7;
 
5162
  PyObject *__pyx_t_8 = NULL;
 
5163
  __Pyx_RefNannySetupContext("gc_sort");
 
5164
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
5165
  __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
5166
  __pyx_v_tips = Py_None; __Pyx_INCREF(Py_None);
 
5167
  __pyx_v_prefix_tips = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
5168
  __pyx_v_prefix = Py_None; __Pyx_INCREF(Py_None);
 
5169
  __pyx_v_tip_nodes = Py_None; __Pyx_INCREF(Py_None);
 
5170
  __pyx_v_result = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
5171
  __pyx_v_pending = Py_None; __Pyx_INCREF(Py_None);
 
5172
  __pyx_v_parents = Py_None; __Pyx_INCREF(Py_None);
 
5173
 
 
5174
  /* "bzrlib/_known_graph_pyx.pyx":575
 
5175
 *         cdef _KnownGraphNode node, node2, parent_node
 
5176
 * 
 
5177
 *         tips = self._find_tips()             # <<<<<<<<<<<<<<
 
5178
 *         # Split the tips based on prefix
 
5179
 *         prefix_tips = {}
 
5180
 */
 
5181
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___find_tips); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5182
  __Pyx_GOTREF(__pyx_t_1);
 
5183
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5184
  __Pyx_GOTREF(__pyx_t_2);
 
5185
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
5186
  __Pyx_DECREF(__pyx_v_tips);
 
5187
  __pyx_v_tips = __pyx_t_2;
 
5188
  __pyx_t_2 = 0;
 
5189
 
 
5190
  /* "bzrlib/_known_graph_pyx.pyx":577
 
5191
 *         tips = self._find_tips()
 
5192
 *         # Split the tips based on prefix
 
5193
 *         prefix_tips = {}             # <<<<<<<<<<<<<<
 
5194
 *         for pos from 0 <= pos < PyList_GET_SIZE(tips):
 
5195
 *             node = _get_list_node(tips, pos)
 
5196
 */
 
5197
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5198
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
5199
  __Pyx_DECREF(((PyObject *)__pyx_v_prefix_tips));
 
5200
  __pyx_v_prefix_tips = __pyx_t_2;
 
5201
  __pyx_t_2 = 0;
 
5202
 
 
5203
  /* "bzrlib/_known_graph_pyx.pyx":578
 
5204
 *         # Split the tips based on prefix
 
5205
 *         prefix_tips = {}
 
5206
 *         for pos from 0 <= pos < PyList_GET_SIZE(tips):             # <<<<<<<<<<<<<<
 
5207
 *             node = _get_list_node(tips, pos)
 
5208
 *             if PyString_CheckExact(node.key) or len(node.key) == 1:
 
5209
 */
 
5210
  __pyx_t_3 = PyList_GET_SIZE(__pyx_v_tips);
 
5211
  for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_3; __pyx_v_pos++) {
 
5212
 
 
5213
    /* "bzrlib/_known_graph_pyx.pyx":579
 
5214
 *         prefix_tips = {}
 
5215
 *         for pos from 0 <= pos < PyList_GET_SIZE(tips):
 
5216
 *             node = _get_list_node(tips, pos)             # <<<<<<<<<<<<<<
 
5217
 *             if PyString_CheckExact(node.key) or len(node.key) == 1:
 
5218
 *                 prefix = ''
 
5219
 */
 
5220
    __pyx_t_2 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_v_tips, __pyx_v_pos)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5221
    __Pyx_GOTREF(__pyx_t_2);
 
5222
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
5223
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_2);
 
5224
    __pyx_t_2 = 0;
 
5225
 
 
5226
    /* "bzrlib/_known_graph_pyx.pyx":580
 
5227
 *         for pos from 0 <= pos < PyList_GET_SIZE(tips):
 
5228
 *             node = _get_list_node(tips, pos)
 
5229
 *             if PyString_CheckExact(node.key) or len(node.key) == 1:             # <<<<<<<<<<<<<<
 
5230
 *                 prefix = ''
 
5231
 *             else:
 
5232
 */
 
5233
    __pyx_t_2 = __pyx_v_node->key;
 
5234
    __Pyx_INCREF(__pyx_t_2);
 
5235
    if (!PyString_CheckExact(__pyx_t_2)) {
 
5236
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
5237
      __pyx_t_1 = __pyx_v_node->key;
 
5238
      __Pyx_INCREF(__pyx_t_1);
 
5239
      __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5240
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
5241
      __pyx_t_5 = (__pyx_t_4 == 1);
 
5242
      __pyx_t_6 = __pyx_t_5;
 
5243
    } else {
 
5244
      __pyx_t_6 = PyString_CheckExact(__pyx_t_2);
 
5245
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
5246
    }
 
5247
    if (__pyx_t_6) {
 
5248
 
 
5249
      /* "bzrlib/_known_graph_pyx.pyx":581
 
5250
 *             node = _get_list_node(tips, pos)
 
5251
 *             if PyString_CheckExact(node.key) or len(node.key) == 1:
 
5252
 *                 prefix = ''             # <<<<<<<<<<<<<<
 
5253
 *             else:
 
5254
 *                 prefix = node.key[0]
 
5255
 */
 
5256
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_9));
 
5257
      __Pyx_DECREF(__pyx_v_prefix);
 
5258
      __pyx_v_prefix = ((PyObject *)__pyx_kp_s_9);
 
5259
      goto __pyx_L7;
 
5260
    }
 
5261
    /*else*/ {
 
5262
 
 
5263
      /* "bzrlib/_known_graph_pyx.pyx":583
 
5264
 *                 prefix = ''
 
5265
 *             else:
 
5266
 *                 prefix = node.key[0]             # <<<<<<<<<<<<<<
 
5267
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 
5268
 *             if temp == NULL:
 
5269
 */
 
5270
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_node->key, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5271
      __Pyx_GOTREF(__pyx_t_2);
 
5272
      __Pyx_DECREF(__pyx_v_prefix);
 
5273
      __pyx_v_prefix = __pyx_t_2;
 
5274
      __pyx_t_2 = 0;
 
5275
    }
 
5276
    __pyx_L7:;
 
5277
 
 
5278
    /* "bzrlib/_known_graph_pyx.pyx":584
 
5279
 *             else:
 
5280
 *                 prefix = node.key[0]
 
5281
 *             temp = PyDict_GetItem(prefix_tips, prefix)             # <<<<<<<<<<<<<<
 
5282
 *             if temp == NULL:
 
5283
 *                 prefix_tips[prefix] = [node]
 
5284
 */
 
5285
    __pyx_v_temp = PyDict_GetItem(((PyObject *)__pyx_v_prefix_tips), __pyx_v_prefix);
 
5286
 
 
5287
    /* "bzrlib/_known_graph_pyx.pyx":585
 
5288
 *                 prefix = node.key[0]
 
5289
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 
5290
 *             if temp == NULL:             # <<<<<<<<<<<<<<
 
5291
 *                 prefix_tips[prefix] = [node]
 
5292
 *             else:
 
5293
 */
 
5294
    __pyx_t_6 = (__pyx_v_temp == NULL);
 
5295
    if (__pyx_t_6) {
 
5296
 
 
5297
      /* "bzrlib/_known_graph_pyx.pyx":586
 
5298
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 
5299
 *             if temp == NULL:
 
5300
 *                 prefix_tips[prefix] = [node]             # <<<<<<<<<<<<<<
 
5301
 *             else:
 
5302
 *                 tip_nodes = <object>temp
 
5303
 */
 
5304
      __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5305
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
5306
      __Pyx_INCREF(((PyObject *)__pyx_v_node));
 
5307
      PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_node));
 
5308
      __Pyx_GIVEREF(((PyObject *)__pyx_v_node));
 
5309
      if (PyDict_SetItem(((PyObject *)__pyx_v_prefix_tips), __pyx_v_prefix, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5310
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
5311
      goto __pyx_L8;
 
5312
    }
 
5313
    /*else*/ {
 
5314
 
 
5315
      /* "bzrlib/_known_graph_pyx.pyx":588
 
5316
 *                 prefix_tips[prefix] = [node]
 
5317
 *             else:
 
5318
 *                 tip_nodes = <object>temp             # <<<<<<<<<<<<<<
 
5319
 *                 PyList_Append(tip_nodes, node)
 
5320
 * 
 
5321
 */
 
5322
      __Pyx_INCREF(((PyObject *)__pyx_v_temp));
 
5323
      __Pyx_DECREF(__pyx_v_tip_nodes);
 
5324
      __pyx_v_tip_nodes = ((PyObject *)__pyx_v_temp);
 
5325
 
 
5326
      /* "bzrlib/_known_graph_pyx.pyx":589
 
5327
 *             else:
 
5328
 *                 tip_nodes = <object>temp
 
5329
 *                 PyList_Append(tip_nodes, node)             # <<<<<<<<<<<<<<
 
5330
 * 
 
5331
 *         result = []
 
5332
 */
 
5333
      __pyx_t_7 = PyList_Append(__pyx_v_tip_nodes, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5334
    }
 
5335
    __pyx_L8:;
 
5336
  }
 
5337
 
 
5338
  /* "bzrlib/_known_graph_pyx.pyx":591
 
5339
 *                 PyList_Append(tip_nodes, node)
 
5340
 * 
 
5341
 *         result = []             # <<<<<<<<<<<<<<
 
5342
 *         for prefix in sorted(prefix_tips):
 
5343
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 
5344
 */
 
5345
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5346
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
5347
  __Pyx_DECREF(((PyObject *)__pyx_v_result));
 
5348
  __pyx_v_result = __pyx_t_2;
 
5349
  __pyx_t_2 = 0;
 
5350
 
 
5351
  /* "bzrlib/_known_graph_pyx.pyx":592
 
5352
 * 
 
5353
 *         result = []
 
5354
 *         for prefix in sorted(prefix_tips):             # <<<<<<<<<<<<<<
 
5355
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 
5356
 *             assert temp != NULL
 
5357
 */
 
5358
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5359
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
5360
  __Pyx_INCREF(((PyObject *)__pyx_v_prefix_tips));
 
5361
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_prefix_tips));
 
5362
  __Pyx_GIVEREF(((PyObject *)__pyx_v_prefix_tips));
 
5363
  __pyx_t_1 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5364
  __Pyx_GOTREF(__pyx_t_1);
 
5365
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
5366
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
 
5367
    __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2);
 
5368
  } else {
 
5369
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5370
    __Pyx_GOTREF(__pyx_t_2);
 
5371
  }
 
5372
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
5373
  for (;;) {
 
5374
    if (likely(PyList_CheckExact(__pyx_t_2))) {
 
5375
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
 
5376
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
 
5377
    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
 
5378
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
 
5379
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
 
5380
    } else {
 
5381
      __pyx_t_1 = PyIter_Next(__pyx_t_2);
 
5382
      if (!__pyx_t_1) {
 
5383
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5384
        break;
 
5385
      }
 
5386
      __Pyx_GOTREF(__pyx_t_1);
 
5387
    }
 
5388
    __Pyx_DECREF(__pyx_v_prefix);
 
5389
    __pyx_v_prefix = __pyx_t_1;
 
5390
    __pyx_t_1 = 0;
 
5391
 
 
5392
    /* "bzrlib/_known_graph_pyx.pyx":593
 
5393
 *         result = []
 
5394
 *         for prefix in sorted(prefix_tips):
 
5395
 *             temp = PyDict_GetItem(prefix_tips, prefix)             # <<<<<<<<<<<<<<
 
5396
 *             assert temp != NULL
 
5397
 *             tip_nodes = <object>temp
 
5398
 */
 
5399
    __pyx_v_temp = PyDict_GetItem(((PyObject *)__pyx_v_prefix_tips), __pyx_v_prefix);
 
5400
 
 
5401
    /* "bzrlib/_known_graph_pyx.pyx":594
 
5402
 *         for prefix in sorted(prefix_tips):
 
5403
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 
5404
 *             assert temp != NULL             # <<<<<<<<<<<<<<
 
5405
 *             tip_nodes = <object>temp
 
5406
 *             pending = _sort_list_nodes(tip_nodes, 1)
 
5407
 */
 
5408
    #ifndef CYTHON_WITHOUT_ASSERTIONS
 
5409
    if (unlikely(!(__pyx_v_temp != NULL))) {
 
5410
      PyErr_SetNone(PyExc_AssertionError);
 
5411
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5412
    }
 
5413
    #endif
 
5414
 
 
5415
    /* "bzrlib/_known_graph_pyx.pyx":595
 
5416
 *             temp = PyDict_GetItem(prefix_tips, prefix)
 
5417
 *             assert temp != NULL
 
5418
 *             tip_nodes = <object>temp             # <<<<<<<<<<<<<<
 
5419
 *             pending = _sort_list_nodes(tip_nodes, 1)
 
5420
 *             last_item = PyList_GET_SIZE(pending) - 1
 
5421
 */
 
5422
    __Pyx_INCREF(((PyObject *)__pyx_v_temp));
 
5423
    __Pyx_DECREF(__pyx_v_tip_nodes);
 
5424
    __pyx_v_tip_nodes = ((PyObject *)__pyx_v_temp);
 
5425
 
 
5426
    /* "bzrlib/_known_graph_pyx.pyx":596
 
5427
 *             assert temp != NULL
 
5428
 *             tip_nodes = <object>temp
 
5429
 *             pending = _sort_list_nodes(tip_nodes, 1)             # <<<<<<<<<<<<<<
 
5430
 *             last_item = PyList_GET_SIZE(pending) - 1
 
5431
 *             while last_item >= 0:
 
5432
 */
 
5433
    __pyx_t_1 = __pyx_f_6bzrlib_16_known_graph_pyx__sort_list_nodes(__pyx_v_tip_nodes, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5434
    __Pyx_GOTREF(__pyx_t_1);
 
5435
    __Pyx_DECREF(__pyx_v_pending);
 
5436
    __pyx_v_pending = __pyx_t_1;
 
5437
    __pyx_t_1 = 0;
 
5438
 
 
5439
    /* "bzrlib/_known_graph_pyx.pyx":597
 
5440
 *             tip_nodes = <object>temp
 
5441
 *             pending = _sort_list_nodes(tip_nodes, 1)
 
5442
 *             last_item = PyList_GET_SIZE(pending) - 1             # <<<<<<<<<<<<<<
 
5443
 *             while last_item >= 0:
 
5444
 *                 node = _get_list_node(pending, last_item)
 
5445
 */
 
5446
    __pyx_v_last_item = (PyList_GET_SIZE(__pyx_v_pending) - 1);
 
5447
 
 
5448
    /* "bzrlib/_known_graph_pyx.pyx":598
 
5449
 *             pending = _sort_list_nodes(tip_nodes, 1)
 
5450
 *             last_item = PyList_GET_SIZE(pending) - 1
 
5451
 *             while last_item >= 0:             # <<<<<<<<<<<<<<
 
5452
 *                 node = _get_list_node(pending, last_item)
 
5453
 *                 last_item = last_item - 1
 
5454
 */
 
5455
    while (1) {
 
5456
      __pyx_t_6 = (__pyx_v_last_item >= 0);
 
5457
      if (!__pyx_t_6) break;
 
5458
 
 
5459
      /* "bzrlib/_known_graph_pyx.pyx":599
 
5460
 *             last_item = PyList_GET_SIZE(pending) - 1
 
5461
 *             while last_item >= 0:
 
5462
 *                 node = _get_list_node(pending, last_item)             # <<<<<<<<<<<<<<
 
5463
 *                 last_item = last_item - 1
 
5464
 *                 if node.parents is None:
 
5465
 */
 
5466
      __pyx_t_1 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_v_pending, __pyx_v_last_item)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5467
      __Pyx_GOTREF(__pyx_t_1);
 
5468
      __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
5469
      __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
 
5470
      __pyx_t_1 = 0;
 
5471
 
 
5472
      /* "bzrlib/_known_graph_pyx.pyx":600
 
5473
 *             while last_item >= 0:
 
5474
 *                 node = _get_list_node(pending, last_item)
 
5475
 *                 last_item = last_item - 1             # <<<<<<<<<<<<<<
 
5476
 *                 if node.parents is None:
 
5477
 *                     # Ghost
 
5478
 */
 
5479
      __pyx_v_last_item = (__pyx_v_last_item - 1);
 
5480
 
 
5481
      /* "bzrlib/_known_graph_pyx.pyx":601
 
5482
 *                 node = _get_list_node(pending, last_item)
 
5483
 *                 last_item = last_item - 1
 
5484
 *                 if node.parents is None:             # <<<<<<<<<<<<<<
 
5485
 *                     # Ghost
 
5486
 *                     continue
 
5487
 */
 
5488
      __pyx_t_6 = (__pyx_v_node->parents == Py_None);
 
5489
      if (__pyx_t_6) {
 
5490
 
 
5491
        /* "bzrlib/_known_graph_pyx.pyx":603
 
5492
 *                 if node.parents is None:
 
5493
 *                     # Ghost
 
5494
 *                     continue             # <<<<<<<<<<<<<<
 
5495
 *                 PyList_Append(result, node.key)
 
5496
 *                 # Sorting the parent keys isn't strictly necessary for stable
 
5497
 */
 
5498
        goto __pyx_L11_continue;
 
5499
        goto __pyx_L13;
 
5500
      }
 
5501
      __pyx_L13:;
 
5502
 
 
5503
      /* "bzrlib/_known_graph_pyx.pyx":604
 
5504
 *                     # Ghost
 
5505
 *                     continue
 
5506
 *                 PyList_Append(result, node.key)             # <<<<<<<<<<<<<<
 
5507
 *                 # Sorting the parent keys isn't strictly necessary for stable
 
5508
 *                 # sorting of a given graph. But it does help minimize the
 
5509
 */
 
5510
      __pyx_t_1 = __pyx_v_node->key;
 
5511
      __Pyx_INCREF(__pyx_t_1);
 
5512
      __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_result), __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5513
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
5514
 
 
5515
      /* "bzrlib/_known_graph_pyx.pyx":611
 
5516
 *                 #   4.73ms  no sort
 
5517
 *                 #   7.73ms  RichCompareBool sort
 
5518
 *                 parents = _sort_list_nodes(node.parents, 1)             # <<<<<<<<<<<<<<
 
5519
 *                 for pos from 0 <= pos < len(parents):
 
5520
 *                     if PyTuple_CheckExact(parents):
 
5521
 */
 
5522
      __pyx_t_1 = __pyx_v_node->parents;
 
5523
      __Pyx_INCREF(__pyx_t_1);
 
5524
      __pyx_t_8 = __pyx_f_6bzrlib_16_known_graph_pyx__sort_list_nodes(__pyx_t_1, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5525
      __Pyx_GOTREF(__pyx_t_8);
 
5526
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
5527
      __Pyx_DECREF(__pyx_v_parents);
 
5528
      __pyx_v_parents = __pyx_t_8;
 
5529
      __pyx_t_8 = 0;
 
5530
 
 
5531
      /* "bzrlib/_known_graph_pyx.pyx":612
 
5532
 *                 #   7.73ms  RichCompareBool sort
 
5533
 *                 parents = _sort_list_nodes(node.parents, 1)
 
5534
 *                 for pos from 0 <= pos < len(parents):             # <<<<<<<<<<<<<<
 
5535
 *                     if PyTuple_CheckExact(parents):
 
5536
 *                         parent_node = _get_tuple_node(parents, pos)
 
5537
 */
 
5538
      __pyx_t_4 = PyObject_Length(__pyx_v_parents); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5539
      for (__pyx_v_pos = 0; __pyx_v_pos < __pyx_t_4; __pyx_v_pos++) {
 
5540
 
 
5541
        /* "bzrlib/_known_graph_pyx.pyx":613
 
5542
 *                 parents = _sort_list_nodes(node.parents, 1)
 
5543
 *                 for pos from 0 <= pos < len(parents):
 
5544
 *                     if PyTuple_CheckExact(parents):             # <<<<<<<<<<<<<<
 
5545
 *                         parent_node = _get_tuple_node(parents, pos)
 
5546
 *                     else:
 
5547
 */
 
5548
        __pyx_t_7 = PyTuple_CheckExact(__pyx_v_parents);
 
5549
        if (__pyx_t_7) {
 
5550
 
 
5551
          /* "bzrlib/_known_graph_pyx.pyx":614
 
5552
 *                 for pos from 0 <= pos < len(parents):
 
5553
 *                     if PyTuple_CheckExact(parents):
 
5554
 *                         parent_node = _get_tuple_node(parents, pos)             # <<<<<<<<<<<<<<
 
5555
 *                     else:
 
5556
 *                         parent_node = _get_list_node(parents, pos)
 
5557
 */
 
5558
          __pyx_t_8 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_tuple_node(__pyx_v_parents, __pyx_v_pos)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5559
          __Pyx_GOTREF(__pyx_t_8);
 
5560
          __Pyx_DECREF(((PyObject *)__pyx_v_parent_node));
 
5561
          __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_8);
 
5562
          __pyx_t_8 = 0;
 
5563
          goto __pyx_L16;
 
5564
        }
 
5565
        /*else*/ {
 
5566
 
 
5567
          /* "bzrlib/_known_graph_pyx.pyx":616
 
5568
 *                         parent_node = _get_tuple_node(parents, pos)
 
5569
 *                     else:
 
5570
 *                         parent_node = _get_list_node(parents, pos)             # <<<<<<<<<<<<<<
 
5571
 *                     # TODO: GraphCycle detection
 
5572
 *                     parent_node.seen = parent_node.seen + 1
 
5573
 */
 
5574
          __pyx_t_8 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_v_parents, __pyx_v_pos)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5575
          __Pyx_GOTREF(__pyx_t_8);
 
5576
          __Pyx_DECREF(((PyObject *)__pyx_v_parent_node));
 
5577
          __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_8);
 
5578
          __pyx_t_8 = 0;
 
5579
        }
 
5580
        __pyx_L16:;
 
5581
 
 
5582
        /* "bzrlib/_known_graph_pyx.pyx":618
 
5583
 *                         parent_node = _get_list_node(parents, pos)
 
5584
 *                     # TODO: GraphCycle detection
 
5585
 *                     parent_node.seen = parent_node.seen + 1             # <<<<<<<<<<<<<<
 
5586
 *                     if (parent_node.seen
 
5587
 *                         == PyList_GET_SIZE(parent_node.children)):
 
5588
 */
 
5589
        __pyx_v_parent_node->seen = (__pyx_v_parent_node->seen + 1);
 
5590
 
 
5591
        /* "bzrlib/_known_graph_pyx.pyx":620
 
5592
 *                     parent_node.seen = parent_node.seen + 1
 
5593
 *                     if (parent_node.seen
 
5594
 *                         == PyList_GET_SIZE(parent_node.children)):             # <<<<<<<<<<<<<<
 
5595
 *                         # All children have been processed, queue up this
 
5596
 *                         # parent
 
5597
 */
 
5598
        __pyx_t_8 = __pyx_v_parent_node->children;
 
5599
        __Pyx_INCREF(__pyx_t_8);
 
5600
        __pyx_t_6 = (__pyx_v_parent_node->seen == PyList_GET_SIZE(__pyx_t_8));
 
5601
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
5602
        if (__pyx_t_6) {
 
5603
 
 
5604
          /* "bzrlib/_known_graph_pyx.pyx":623
 
5605
 *                         # All children have been processed, queue up this
 
5606
 *                         # parent
 
5607
 *                         last_item = last_item + 1             # <<<<<<<<<<<<<<
 
5608
 *                         if last_item < PyList_GET_SIZE(pending):
 
5609
 *                             Py_INCREF(parent_node) # SetItem steals a ref
 
5610
 */
 
5611
          __pyx_v_last_item = (__pyx_v_last_item + 1);
 
5612
 
 
5613
          /* "bzrlib/_known_graph_pyx.pyx":624
 
5614
 *                         # parent
 
5615
 *                         last_item = last_item + 1
 
5616
 *                         if last_item < PyList_GET_SIZE(pending):             # <<<<<<<<<<<<<<
 
5617
 *                             Py_INCREF(parent_node) # SetItem steals a ref
 
5618
 *                             PyList_SetItem(pending, last_item, parent_node)
 
5619
 */
 
5620
          __pyx_t_6 = (__pyx_v_last_item < PyList_GET_SIZE(__pyx_v_pending));
 
5621
          if (__pyx_t_6) {
 
5622
 
 
5623
            /* "bzrlib/_known_graph_pyx.pyx":625
 
5624
 *                         last_item = last_item + 1
 
5625
 *                         if last_item < PyList_GET_SIZE(pending):
 
5626
 *                             Py_INCREF(parent_node) # SetItem steals a ref             # <<<<<<<<<<<<<<
 
5627
 *                             PyList_SetItem(pending, last_item, parent_node)
 
5628
 *                         else:
 
5629
 */
 
5630
            Py_INCREF(((PyObject *)__pyx_v_parent_node));
 
5631
 
 
5632
            /* "bzrlib/_known_graph_pyx.pyx":626
 
5633
 *                         if last_item < PyList_GET_SIZE(pending):
 
5634
 *                             Py_INCREF(parent_node) # SetItem steals a ref
 
5635
 *                             PyList_SetItem(pending, last_item, parent_node)             # <<<<<<<<<<<<<<
 
5636
 *                         else:
 
5637
 *                             PyList_Append(pending, parent_node)
 
5638
 */
 
5639
            __pyx_t_7 = PyList_SetItem(__pyx_v_pending, __pyx_v_last_item, ((PyObject *)__pyx_v_parent_node)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5640
            goto __pyx_L18;
 
5641
          }
 
5642
          /*else*/ {
 
5643
 
 
5644
            /* "bzrlib/_known_graph_pyx.pyx":628
 
5645
 *                             PyList_SetItem(pending, last_item, parent_node)
 
5646
 *                         else:
 
5647
 *                             PyList_Append(pending, parent_node)             # <<<<<<<<<<<<<<
 
5648
 *                         parent_node.seen = 0
 
5649
 *         return result
 
5650
 */
 
5651
            __pyx_t_7 = PyList_Append(__pyx_v_pending, ((PyObject *)__pyx_v_parent_node)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5652
          }
 
5653
          __pyx_L18:;
 
5654
 
 
5655
          /* "bzrlib/_known_graph_pyx.pyx":629
 
5656
 *                         else:
 
5657
 *                             PyList_Append(pending, parent_node)
 
5658
 *                         parent_node.seen = 0             # <<<<<<<<<<<<<<
 
5659
 *         return result
 
5660
 * 
 
5661
 */
 
5662
          __pyx_v_parent_node->seen = 0;
 
5663
          goto __pyx_L17;
 
5664
        }
 
5665
        __pyx_L17:;
 
5666
      }
 
5667
      __pyx_L11_continue:;
 
5668
    }
 
5669
  }
 
5670
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
5671
 
 
5672
  /* "bzrlib/_known_graph_pyx.pyx":630
 
5673
 *                             PyList_Append(pending, parent_node)
 
5674
 *                         parent_node.seen = 0
 
5675
 *         return result             # <<<<<<<<<<<<<<
 
5676
 * 
 
5677
 *     def merge_sort(self, tip_key):
 
5678
 */
 
5679
  __Pyx_XDECREF(__pyx_r);
 
5680
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
 
5681
  __pyx_r = ((PyObject *)__pyx_v_result);
 
5682
  goto __pyx_L0;
 
5683
 
 
5684
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
5685
  goto __pyx_L0;
 
5686
  __pyx_L1_error:;
 
5687
  __Pyx_XDECREF(__pyx_t_1);
 
5688
  __Pyx_XDECREF(__pyx_t_2);
 
5689
  __Pyx_XDECREF(__pyx_t_8);
 
5690
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.gc_sort");
 
5691
  __pyx_r = NULL;
 
5692
  __pyx_L0:;
 
5693
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
5694
  __Pyx_DECREF((PyObject *)__pyx_v_parent_node);
 
5695
  __Pyx_DECREF(__pyx_v_tips);
 
5696
  __Pyx_DECREF(__pyx_v_prefix_tips);
 
5697
  __Pyx_DECREF(__pyx_v_prefix);
 
5698
  __Pyx_DECREF(__pyx_v_tip_nodes);
 
5699
  __Pyx_DECREF(__pyx_v_result);
 
5700
  __Pyx_DECREF(__pyx_v_pending);
 
5701
  __Pyx_DECREF(__pyx_v_parents);
 
5702
  __Pyx_XGIVEREF(__pyx_r);
 
5703
  __Pyx_RefNannyFinishContext();
 
5704
  return __pyx_r;
 
5705
}
 
5706
 
 
5707
/* "bzrlib/_known_graph_pyx.pyx":632
 
5708
 *         return result
 
5709
 * 
 
5710
 *     def merge_sort(self, tip_key):             # <<<<<<<<<<<<<<
 
5711
 *         """Compute the merge sorted graph output."""
 
5712
 *         cdef _MergeSorter sorter
 
5713
 */
 
5714
 
 
5715
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_10merge_sort(PyObject *__pyx_v_self, PyObject *__pyx_v_tip_key); /*proto*/
 
5716
static char __pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_10merge_sort[] = "Compute the merge sorted graph output.";
 
5717
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_10merge_sort(PyObject *__pyx_v_self, PyObject *__pyx_v_tip_key) {
 
5718
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *__pyx_v_sorter;
 
5719
  PyObject *__pyx_r = NULL;
 
5720
  PyObject *__pyx_t_1 = NULL;
 
5721
  PyObject *__pyx_t_2 = NULL;
 
5722
  __Pyx_RefNannySetupContext("merge_sort");
 
5723
  __pyx_v_sorter = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)Py_None); __Pyx_INCREF(Py_None);
 
5724
 
 
5725
  /* "bzrlib/_known_graph_pyx.pyx":639
 
5726
 *         #       that won't be collectable anyway. real world testing has not
 
5727
 *         #       shown a specific impact, yet.
 
5728
 *         sorter = _MergeSorter(self, tip_key)             # <<<<<<<<<<<<<<
 
5729
 *         return sorter.topo_order()
 
5730
 * 
 
5731
 */
 
5732
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5733
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
5734
  __Pyx_INCREF(__pyx_v_self);
 
5735
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
 
5736
  __Pyx_GIVEREF(__pyx_v_self);
 
5737
  __Pyx_INCREF(__pyx_v_tip_key);
 
5738
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_tip_key);
 
5739
  __Pyx_GIVEREF(__pyx_v_tip_key);
 
5740
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_16_known_graph_pyx__MergeSorter)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5741
  __Pyx_GOTREF(__pyx_t_2);
 
5742
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
5743
  __Pyx_DECREF(((PyObject *)__pyx_v_sorter));
 
5744
  __pyx_v_sorter = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_t_2);
 
5745
  __pyx_t_2 = 0;
 
5746
 
 
5747
  /* "bzrlib/_known_graph_pyx.pyx":640
 
5748
 *         #       shown a specific impact, yet.
 
5749
 *         sorter = _MergeSorter(self, tip_key)
 
5750
 *         return sorter.topo_order()             # <<<<<<<<<<<<<<
 
5751
 * 
 
5752
 *     def get_parent_keys(self, key):
 
5753
 */
 
5754
  __Pyx_XDECREF(__pyx_r);
 
5755
  __pyx_t_2 = ((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_sorter->__pyx_vtab)->topo_order(__pyx_v_sorter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5756
  __Pyx_GOTREF(__pyx_t_2);
 
5757
  __pyx_r = __pyx_t_2;
 
5758
  __pyx_t_2 = 0;
 
5759
  goto __pyx_L0;
 
5760
 
 
5761
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
5762
  goto __pyx_L0;
 
5763
  __pyx_L1_error:;
 
5764
  __Pyx_XDECREF(__pyx_t_1);
 
5765
  __Pyx_XDECREF(__pyx_t_2);
 
5766
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.merge_sort");
 
5767
  __pyx_r = NULL;
 
5768
  __pyx_L0:;
 
5769
  __Pyx_DECREF((PyObject *)__pyx_v_sorter);
 
5770
  __Pyx_XGIVEREF(__pyx_r);
 
5771
  __Pyx_RefNannyFinishContext();
 
5772
  return __pyx_r;
 
5773
}
 
5774
 
 
5775
/* "bzrlib/_known_graph_pyx.pyx":642
 
5776
 *         return sorter.topo_order()
 
5777
 * 
 
5778
 *     def get_parent_keys(self, key):             # <<<<<<<<<<<<<<
 
5779
 *         """Get the parents for a key
 
5780
 * 
 
5781
 */
 
5782
 
 
5783
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_11get_parent_keys(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
 
5784
static char __pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_11get_parent_keys[] = "Get the parents for a key\n        \n        Returns a list containg the parents keys. If the key is a ghost,\n        None is returned. A KeyError will be raised if the key is not in\n        the graph.\n        \n        :param keys: Key to check (eg revision_id)\n        :return: A list of parents\n        ";
 
5785
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_11get_parent_keys(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
 
5786
  PyObject *__pyx_r = NULL;
 
5787
  PyObject *__pyx_t_1 = NULL;
 
5788
  PyObject *__pyx_t_2 = NULL;
 
5789
  __Pyx_RefNannySetupContext("get_parent_keys");
 
5790
 
 
5791
  /* "bzrlib/_known_graph_pyx.pyx":652
 
5792
 *         :return: A list of parents
 
5793
 *         """
 
5794
 *         return self._nodes[key].parent_keys             # <<<<<<<<<<<<<<
 
5795
 * 
 
5796
 *     def get_child_keys(self, key):
 
5797
 */
 
5798
  __Pyx_XDECREF(__pyx_r);
 
5799
  __pyx_t_1 = PyObject_GetItem(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5800
  __Pyx_GOTREF(__pyx_t_1);
 
5801
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__parent_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5802
  __Pyx_GOTREF(__pyx_t_2);
 
5803
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
5804
  __pyx_r = __pyx_t_2;
 
5805
  __pyx_t_2 = 0;
 
5806
  goto __pyx_L0;
 
5807
 
 
5808
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
5809
  goto __pyx_L0;
 
5810
  __pyx_L1_error:;
 
5811
  __Pyx_XDECREF(__pyx_t_1);
 
5812
  __Pyx_XDECREF(__pyx_t_2);
 
5813
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.get_parent_keys");
 
5814
  __pyx_r = NULL;
 
5815
  __pyx_L0:;
 
5816
  __Pyx_XGIVEREF(__pyx_r);
 
5817
  __Pyx_RefNannyFinishContext();
 
5818
  return __pyx_r;
 
5819
}
 
5820
 
 
5821
/* "bzrlib/_known_graph_pyx.pyx":654
 
5822
 *         return self._nodes[key].parent_keys
 
5823
 * 
 
5824
 *     def get_child_keys(self, key):             # <<<<<<<<<<<<<<
 
5825
 *         """Get the children for a key
 
5826
 * 
 
5827
 */
 
5828
 
 
5829
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12get_child_keys(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
 
5830
static char __pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_12get_child_keys[] = "Get the children for a key\n        \n        Returns a list containg the children keys. A KeyError will be raised\n        if the key is not in the graph.\n        \n        :param keys: Key to check (eg revision_id)\n        :return: A list of children\n        ";
 
5831
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12get_child_keys(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
 
5832
  PyObject *__pyx_r = NULL;
 
5833
  PyObject *__pyx_t_1 = NULL;
 
5834
  PyObject *__pyx_t_2 = NULL;
 
5835
  __Pyx_RefNannySetupContext("get_child_keys");
 
5836
 
 
5837
  /* "bzrlib/_known_graph_pyx.pyx":663
 
5838
 *         :return: A list of children
 
5839
 *         """
 
5840
 *         return self._nodes[key].child_keys             # <<<<<<<<<<<<<<
 
5841
 * 
 
5842
 * 
 
5843
 */
 
5844
  __Pyx_XDECREF(__pyx_r);
 
5845
  __pyx_t_1 = PyObject_GetItem(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5846
  __Pyx_GOTREF(__pyx_t_1);
 
5847
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__child_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5848
  __Pyx_GOTREF(__pyx_t_2);
 
5849
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
5850
  __pyx_r = __pyx_t_2;
 
5851
  __pyx_t_2 = 0;
 
5852
  goto __pyx_L0;
 
5853
 
 
5854
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
5855
  goto __pyx_L0;
 
5856
  __pyx_L1_error:;
 
5857
  __Pyx_XDECREF(__pyx_t_1);
 
5858
  __Pyx_XDECREF(__pyx_t_2);
 
5859
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.get_child_keys");
 
5860
  __pyx_r = NULL;
 
5861
  __pyx_L0:;
 
5862
  __Pyx_XGIVEREF(__pyx_r);
 
5863
  __Pyx_RefNannyFinishContext();
 
5864
  return __pyx_r;
 
5865
}
 
5866
 
 
5867
/* "bzrlib/_known_graph_pyx.pyx":195
 
5868
 *     """This is a class which assumes we already know the full graph."""
 
5869
 * 
 
5870
 *     cdef public object _nodes             # <<<<<<<<<<<<<<
 
5871
 *     cdef public object _known_heads
 
5872
 *     cdef public int do_cache
 
5873
 */
 
5874
 
 
5875
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6_nodes___get__(PyObject *__pyx_v_self); /*proto*/
 
5876
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6_nodes___get__(PyObject *__pyx_v_self) {
 
5877
  PyObject *__pyx_r = NULL;
 
5878
  __Pyx_RefNannySetupContext("__get__");
 
5879
  __Pyx_XDECREF(__pyx_r);
 
5880
  __Pyx_INCREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
5881
  __pyx_r = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes;
 
5882
  goto __pyx_L0;
 
5883
 
 
5884
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
5885
  __pyx_L0:;
 
5886
  __Pyx_XGIVEREF(__pyx_r);
 
5887
  __Pyx_RefNannyFinishContext();
 
5888
  return __pyx_r;
 
5889
}
 
5890
 
 
5891
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6_nodes_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
 
5892
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6_nodes_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
 
5893
  int __pyx_r;
 
5894
  __Pyx_RefNannySetupContext("__set__");
 
5895
  __Pyx_INCREF(__pyx_v_value);
 
5896
  __Pyx_GIVEREF(__pyx_v_value);
 
5897
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
5898
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
5899
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes = __pyx_v_value;
 
5900
 
 
5901
  __pyx_r = 0;
 
5902
  __Pyx_RefNannyFinishContext();
 
5903
  return __pyx_r;
 
5904
}
 
5905
 
 
5906
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6_nodes_2__del__(PyObject *__pyx_v_self); /*proto*/
 
5907
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6_nodes_2__del__(PyObject *__pyx_v_self) {
 
5908
  int __pyx_r;
 
5909
  __Pyx_RefNannySetupContext("__del__");
 
5910
  __Pyx_INCREF(Py_None);
 
5911
  __Pyx_GIVEREF(Py_None);
 
5912
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
5913
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes);
 
5914
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_nodes = Py_None;
 
5915
 
 
5916
  __pyx_r = 0;
 
5917
  __Pyx_RefNannyFinishContext();
 
5918
  return __pyx_r;
 
5919
}
 
5920
 
 
5921
/* "bzrlib/_known_graph_pyx.pyx":196
 
5922
 * 
 
5923
 *     cdef public object _nodes
 
5924
 *     cdef public object _known_heads             # <<<<<<<<<<<<<<
 
5925
 *     cdef public int do_cache
 
5926
 * 
 
5927
 */
 
5928
 
 
5929
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12_known_heads___get__(PyObject *__pyx_v_self); /*proto*/
 
5930
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12_known_heads___get__(PyObject *__pyx_v_self) {
 
5931
  PyObject *__pyx_r = NULL;
 
5932
  __Pyx_RefNannySetupContext("__get__");
 
5933
  __Pyx_XDECREF(__pyx_r);
 
5934
  __Pyx_INCREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads);
 
5935
  __pyx_r = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads;
 
5936
  goto __pyx_L0;
 
5937
 
 
5938
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
5939
  __pyx_L0:;
 
5940
  __Pyx_XGIVEREF(__pyx_r);
 
5941
  __Pyx_RefNannyFinishContext();
 
5942
  return __pyx_r;
 
5943
}
 
5944
 
 
5945
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12_known_heads_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
 
5946
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12_known_heads_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
 
5947
  int __pyx_r;
 
5948
  __Pyx_RefNannySetupContext("__set__");
 
5949
  __Pyx_INCREF(__pyx_v_value);
 
5950
  __Pyx_GIVEREF(__pyx_v_value);
 
5951
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads);
 
5952
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads);
 
5953
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads = __pyx_v_value;
 
5954
 
 
5955
  __pyx_r = 0;
 
5956
  __Pyx_RefNannyFinishContext();
 
5957
  return __pyx_r;
 
5958
}
 
5959
 
 
5960
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12_known_heads_2__del__(PyObject *__pyx_v_self); /*proto*/
 
5961
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12_known_heads_2__del__(PyObject *__pyx_v_self) {
 
5962
  int __pyx_r;
 
5963
  __Pyx_RefNannySetupContext("__del__");
 
5964
  __Pyx_INCREF(Py_None);
 
5965
  __Pyx_GIVEREF(Py_None);
 
5966
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads);
 
5967
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads);
 
5968
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->_known_heads = Py_None;
 
5969
 
 
5970
  __pyx_r = 0;
 
5971
  __Pyx_RefNannyFinishContext();
 
5972
  return __pyx_r;
 
5973
}
 
5974
 
 
5975
/* "bzrlib/_known_graph_pyx.pyx":197
 
5976
 *     cdef public object _nodes
 
5977
 *     cdef public object _known_heads
 
5978
 *     cdef public int do_cache             # <<<<<<<<<<<<<<
 
5979
 * 
 
5980
 *     def __init__(self, parent_map, do_cache=True):
 
5981
 */
 
5982
 
 
5983
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_8do_cache___get__(PyObject *__pyx_v_self); /*proto*/
 
5984
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_8do_cache___get__(PyObject *__pyx_v_self) {
 
5985
  PyObject *__pyx_r = NULL;
 
5986
  PyObject *__pyx_t_1 = NULL;
 
5987
  __Pyx_RefNannySetupContext("__get__");
 
5988
  __Pyx_XDECREF(__pyx_r);
 
5989
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->do_cache); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
5990
  __Pyx_GOTREF(__pyx_t_1);
 
5991
  __pyx_r = __pyx_t_1;
 
5992
  __pyx_t_1 = 0;
 
5993
  goto __pyx_L0;
 
5994
 
 
5995
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
5996
  goto __pyx_L0;
 
5997
  __pyx_L1_error:;
 
5998
  __Pyx_XDECREF(__pyx_t_1);
 
5999
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.do_cache.__get__");
 
6000
  __pyx_r = NULL;
 
6001
  __pyx_L0:;
 
6002
  __Pyx_XGIVEREF(__pyx_r);
 
6003
  __Pyx_RefNannyFinishContext();
 
6004
  return __pyx_r;
 
6005
}
 
6006
 
 
6007
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_8do_cache_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
 
6008
static int __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_8do_cache_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
 
6009
  int __pyx_r;
 
6010
  int __pyx_t_1;
 
6011
  __Pyx_RefNannySetupContext("__set__");
 
6012
  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6013
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_self)->do_cache = __pyx_t_1;
 
6014
 
 
6015
  __pyx_r = 0;
 
6016
  goto __pyx_L0;
 
6017
  __pyx_L1_error:;
 
6018
  __Pyx_AddTraceback("bzrlib._known_graph_pyx.KnownGraph.do_cache.__set__");
 
6019
  __pyx_r = -1;
 
6020
  __pyx_L0:;
 
6021
  __Pyx_RefNannyFinishContext();
 
6022
  return __pyx_r;
 
6023
}
 
6024
 
 
6025
/* "bzrlib/_known_graph_pyx.pyx":686
 
6026
 *     cdef int completed # Fully Processed
 
6027
 * 
 
6028
 *     def __init__(self, key):             # <<<<<<<<<<<<<<
 
6029
 *         self.key = key
 
6030
 *         self.merge_depth = -1
 
6031
 */
 
6032
 
 
6033
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
6034
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
6035
  PyObject *__pyx_v_key = 0;
 
6036
  int __pyx_r;
 
6037
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,0};
 
6038
  __Pyx_RefNannySetupContext("__init__");
 
6039
  if (unlikely(__pyx_kwds)) {
 
6040
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
6041
    PyObject* values[1] = {0};
 
6042
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
6043
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
6044
      case  0: break;
 
6045
      default: goto __pyx_L5_argtuple_error;
 
6046
    }
 
6047
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
6048
      case  0:
 
6049
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
 
6050
      if (likely(values[0])) kw_args--;
 
6051
      else goto __pyx_L5_argtuple_error;
 
6052
    }
 
6053
    if (unlikely(kw_args > 0)) {
 
6054
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
6055
    }
 
6056
    __pyx_v_key = values[0];
 
6057
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
 
6058
    goto __pyx_L5_argtuple_error;
 
6059
  } else {
 
6060
    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
 
6061
  }
 
6062
  goto __pyx_L4_argument_unpacking_done;
 
6063
  __pyx_L5_argtuple_error:;
 
6064
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
6065
  __pyx_L3_error:;
 
6066
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSortNode.__init__");
 
6067
  __Pyx_RefNannyFinishContext();
 
6068
  return -1;
 
6069
  __pyx_L4_argument_unpacking_done:;
 
6070
 
 
6071
  /* "bzrlib/_known_graph_pyx.pyx":687
 
6072
 * 
 
6073
 *     def __init__(self, key):
 
6074
 *         self.key = key             # <<<<<<<<<<<<<<
 
6075
 *         self.merge_depth = -1
 
6076
 *         self.left_parent = None
 
6077
 */
 
6078
  __Pyx_INCREF(__pyx_v_key);
 
6079
  __Pyx_GIVEREF(__pyx_v_key);
 
6080
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key);
 
6081
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key);
 
6082
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key = __pyx_v_key;
 
6083
 
 
6084
  /* "bzrlib/_known_graph_pyx.pyx":688
 
6085
 *     def __init__(self, key):
 
6086
 *         self.key = key
 
6087
 *         self.merge_depth = -1             # <<<<<<<<<<<<<<
 
6088
 *         self.left_parent = None
 
6089
 *         self.left_pending_parent = None
 
6090
 */
 
6091
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->merge_depth = -1;
 
6092
 
 
6093
  /* "bzrlib/_known_graph_pyx.pyx":689
 
6094
 *         self.key = key
 
6095
 *         self.merge_depth = -1
 
6096
 *         self.left_parent = None             # <<<<<<<<<<<<<<
 
6097
 *         self.left_pending_parent = None
 
6098
 *         self.pending_parents = None
 
6099
 */
 
6100
  __Pyx_INCREF(Py_None);
 
6101
  __Pyx_GIVEREF(Py_None);
 
6102
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->left_parent);
 
6103
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->left_parent));
 
6104
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->left_parent = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None);
 
6105
 
 
6106
  /* "bzrlib/_known_graph_pyx.pyx":690
 
6107
 *         self.merge_depth = -1
 
6108
 *         self.left_parent = None
 
6109
 *         self.left_pending_parent = None             # <<<<<<<<<<<<<<
 
6110
 *         self.pending_parents = None
 
6111
 *         self._revno_first = -1
 
6112
 */
 
6113
  __Pyx_INCREF(Py_None);
 
6114
  __Pyx_GIVEREF(Py_None);
 
6115
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->left_pending_parent);
 
6116
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->left_pending_parent));
 
6117
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->left_pending_parent = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None);
 
6118
 
 
6119
  /* "bzrlib/_known_graph_pyx.pyx":691
 
6120
 *         self.left_parent = None
 
6121
 *         self.left_pending_parent = None
 
6122
 *         self.pending_parents = None             # <<<<<<<<<<<<<<
 
6123
 *         self._revno_first = -1
 
6124
 *         self._revno_second = -1
 
6125
 */
 
6126
  __Pyx_INCREF(Py_None);
 
6127
  __Pyx_GIVEREF(Py_None);
 
6128
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->pending_parents);
 
6129
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->pending_parents);
 
6130
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->pending_parents = Py_None;
 
6131
 
 
6132
  /* "bzrlib/_known_graph_pyx.pyx":692
 
6133
 *         self.left_pending_parent = None
 
6134
 *         self.pending_parents = None
 
6135
 *         self._revno_first = -1             # <<<<<<<<<<<<<<
 
6136
 *         self._revno_second = -1
 
6137
 *         self._revno_last = -1
 
6138
 */
 
6139
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->_revno_first = -1;
 
6140
 
 
6141
  /* "bzrlib/_known_graph_pyx.pyx":693
 
6142
 *         self.pending_parents = None
 
6143
 *         self._revno_first = -1
 
6144
 *         self._revno_second = -1             # <<<<<<<<<<<<<<
 
6145
 *         self._revno_last = -1
 
6146
 *         self.is_first_child = 0
 
6147
 */
 
6148
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->_revno_second = -1;
 
6149
 
 
6150
  /* "bzrlib/_known_graph_pyx.pyx":694
 
6151
 *         self._revno_first = -1
 
6152
 *         self._revno_second = -1
 
6153
 *         self._revno_last = -1             # <<<<<<<<<<<<<<
 
6154
 *         self.is_first_child = 0
 
6155
 *         self.seen_by_child = 0
 
6156
 */
 
6157
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->_revno_last = -1;
 
6158
 
 
6159
  /* "bzrlib/_known_graph_pyx.pyx":695
 
6160
 *         self._revno_second = -1
 
6161
 *         self._revno_last = -1
 
6162
 *         self.is_first_child = 0             # <<<<<<<<<<<<<<
 
6163
 *         self.seen_by_child = 0
 
6164
 *         self.completed = 0
 
6165
 */
 
6166
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->is_first_child = 0;
 
6167
 
 
6168
  /* "bzrlib/_known_graph_pyx.pyx":696
 
6169
 *         self._revno_last = -1
 
6170
 *         self.is_first_child = 0
 
6171
 *         self.seen_by_child = 0             # <<<<<<<<<<<<<<
 
6172
 *         self.completed = 0
 
6173
 * 
 
6174
 */
 
6175
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->seen_by_child = 0;
 
6176
 
 
6177
  /* "bzrlib/_known_graph_pyx.pyx":697
 
6178
 *         self.is_first_child = 0
 
6179
 *         self.seen_by_child = 0
 
6180
 *         self.completed = 0             # <<<<<<<<<<<<<<
 
6181
 * 
 
6182
 *     def __repr__(self):
 
6183
 */
 
6184
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->completed = 0;
 
6185
 
 
6186
  __pyx_r = 0;
 
6187
  __Pyx_RefNannyFinishContext();
 
6188
  return __pyx_r;
 
6189
}
 
6190
 
 
6191
/* "bzrlib/_known_graph_pyx.pyx":699
 
6192
 *         self.completed = 0
 
6193
 * 
 
6194
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 
6195
 *         return '%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)' % (
 
6196
 *             self.__class__.__name__, self.key,
 
6197
 */
 
6198
 
 
6199
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_1__repr__(PyObject *__pyx_v_self); /*proto*/
 
6200
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_1__repr__(PyObject *__pyx_v_self) {
 
6201
  PyObject *__pyx_r = NULL;
 
6202
  PyObject *__pyx_t_1 = NULL;
 
6203
  PyObject *__pyx_t_2 = NULL;
 
6204
  PyObject *__pyx_t_3 = NULL;
 
6205
  PyObject *__pyx_t_4 = NULL;
 
6206
  PyObject *__pyx_t_5 = NULL;
 
6207
  PyObject *__pyx_t_6 = NULL;
 
6208
  PyObject *__pyx_t_7 = NULL;
 
6209
  PyObject *__pyx_t_8 = NULL;
 
6210
  __Pyx_RefNannySetupContext("__repr__");
 
6211
 
 
6212
  /* "bzrlib/_known_graph_pyx.pyx":700
 
6213
 * 
 
6214
 *     def __repr__(self):
 
6215
 *         return '%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)' % (             # <<<<<<<<<<<<<<
 
6216
 *             self.__class__.__name__, self.key,
 
6217
 *             self.merge_depth,
 
6218
 */
 
6219
  __Pyx_XDECREF(__pyx_r);
 
6220
 
 
6221
  /* "bzrlib/_known_graph_pyx.pyx":701
 
6222
 *     def __repr__(self):
 
6223
 *         return '%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)' % (
 
6224
 *             self.__class__.__name__, self.key,             # <<<<<<<<<<<<<<
 
6225
 *             self.merge_depth,
 
6226
 *             self._revno_first, self._revno_second, self._revno_last,
 
6227
 */
 
6228
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6229
  __Pyx_GOTREF(__pyx_t_1);
 
6230
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____name__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6231
  __Pyx_GOTREF(__pyx_t_2);
 
6232
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
6233
 
 
6234
  /* "bzrlib/_known_graph_pyx.pyx":702
 
6235
 *         return '%s(%s depth:%s rev:%s,%s,%s first:%s seen:%s)' % (
 
6236
 *             self.__class__.__name__, self.key,
 
6237
 *             self.merge_depth,             # <<<<<<<<<<<<<<
 
6238
 *             self._revno_first, self._revno_second, self._revno_last,
 
6239
 *             self.is_first_child, self.seen_by_child)
 
6240
 */
 
6241
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->merge_depth); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6242
  __Pyx_GOTREF(__pyx_t_1);
 
6243
 
 
6244
  /* "bzrlib/_known_graph_pyx.pyx":703
 
6245
 *             self.__class__.__name__, self.key,
 
6246
 *             self.merge_depth,
 
6247
 *             self._revno_first, self._revno_second, self._revno_last,             # <<<<<<<<<<<<<<
 
6248
 *             self.is_first_child, self.seen_by_child)
 
6249
 * 
 
6250
 */
 
6251
  __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->_revno_first); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6252
  __Pyx_GOTREF(__pyx_t_3);
 
6253
  __pyx_t_4 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->_revno_second); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6254
  __Pyx_GOTREF(__pyx_t_4);
 
6255
  __pyx_t_5 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->_revno_last); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6256
  __Pyx_GOTREF(__pyx_t_5);
 
6257
 
 
6258
  /* "bzrlib/_known_graph_pyx.pyx":704
 
6259
 *             self.merge_depth,
 
6260
 *             self._revno_first, self._revno_second, self._revno_last,
 
6261
 *             self.is_first_child, self.seen_by_child)             # <<<<<<<<<<<<<<
 
6262
 * 
 
6263
 *     cdef int has_pending_parents(self): # cannot_raise
 
6264
 */
 
6265
  __pyx_t_6 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->is_first_child); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6266
  __Pyx_GOTREF(__pyx_t_6);
 
6267
  __pyx_t_7 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->seen_by_child); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6268
  __Pyx_GOTREF(__pyx_t_7);
 
6269
  __pyx_t_8 = PyTuple_New(8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6270
  __Pyx_GOTREF(((PyObject *)__pyx_t_8));
 
6271
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
 
6272
  __Pyx_GIVEREF(__pyx_t_2);
 
6273
  __Pyx_INCREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key);
 
6274
  PyTuple_SET_ITEM(__pyx_t_8, 1, ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key);
 
6275
  __Pyx_GIVEREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key);
 
6276
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_1);
 
6277
  __Pyx_GIVEREF(__pyx_t_1);
 
6278
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_3);
 
6279
  __Pyx_GIVEREF(__pyx_t_3);
 
6280
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_t_4);
 
6281
  __Pyx_GIVEREF(__pyx_t_4);
 
6282
  PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_5);
 
6283
  __Pyx_GIVEREF(__pyx_t_5);
 
6284
  PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_t_6);
 
6285
  __Pyx_GIVEREF(__pyx_t_6);
 
6286
  PyTuple_SET_ITEM(__pyx_t_8, 7, __pyx_t_7);
 
6287
  __Pyx_GIVEREF(__pyx_t_7);
 
6288
  __pyx_t_2 = 0;
 
6289
  __pyx_t_1 = 0;
 
6290
  __pyx_t_3 = 0;
 
6291
  __pyx_t_4 = 0;
 
6292
  __pyx_t_5 = 0;
 
6293
  __pyx_t_6 = 0;
 
6294
  __pyx_t_7 = 0;
 
6295
  __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6296
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
 
6297
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
 
6298
  __pyx_r = ((PyObject *)__pyx_t_7);
 
6299
  __pyx_t_7 = 0;
 
6300
  goto __pyx_L0;
 
6301
 
 
6302
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
6303
  goto __pyx_L0;
 
6304
  __pyx_L1_error:;
 
6305
  __Pyx_XDECREF(__pyx_t_1);
 
6306
  __Pyx_XDECREF(__pyx_t_2);
 
6307
  __Pyx_XDECREF(__pyx_t_3);
 
6308
  __Pyx_XDECREF(__pyx_t_4);
 
6309
  __Pyx_XDECREF(__pyx_t_5);
 
6310
  __Pyx_XDECREF(__pyx_t_6);
 
6311
  __Pyx_XDECREF(__pyx_t_7);
 
6312
  __Pyx_XDECREF(__pyx_t_8);
 
6313
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSortNode.__repr__");
 
6314
  __pyx_r = NULL;
 
6315
  __pyx_L0:;
 
6316
  __Pyx_XGIVEREF(__pyx_r);
 
6317
  __Pyx_RefNannyFinishContext();
 
6318
  return __pyx_r;
 
6319
}
 
6320
 
 
6321
/* "bzrlib/_known_graph_pyx.pyx":706
 
6322
 *             self.is_first_child, self.seen_by_child)
 
6323
 * 
 
6324
 *     cdef int has_pending_parents(self): # cannot_raise             # <<<<<<<<<<<<<<
 
6325
 *         if self.left_pending_parent is not None or self.pending_parents:
 
6326
 *             return 1
 
6327
 */
 
6328
 
 
6329
static  int __pyx_f_6bzrlib_16_known_graph_pyx_14_MergeSortNode_has_pending_parents(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
 
6330
  int __pyx_r;
 
6331
  int __pyx_t_1;
 
6332
  int __pyx_t_2;
 
6333
  int __pyx_t_3;
 
6334
  __Pyx_RefNannySetupContext("has_pending_parents");
 
6335
 
 
6336
  /* "bzrlib/_known_graph_pyx.pyx":707
 
6337
 * 
 
6338
 *     cdef int has_pending_parents(self): # cannot_raise
 
6339
 *         if self.left_pending_parent is not None or self.pending_parents:             # <<<<<<<<<<<<<<
 
6340
 *             return 1
 
6341
 *         return 0
 
6342
 */
 
6343
  __pyx_t_1 = (((PyObject *)__pyx_v_self->left_pending_parent) != Py_None);
 
6344
  if (!__pyx_t_1) {
 
6345
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->pending_parents); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6346
    __pyx_t_3 = __pyx_t_2;
 
6347
  } else {
 
6348
    __pyx_t_3 = __pyx_t_1;
 
6349
  }
 
6350
  if (__pyx_t_3) {
 
6351
 
 
6352
    /* "bzrlib/_known_graph_pyx.pyx":708
 
6353
 *     cdef int has_pending_parents(self): # cannot_raise
 
6354
 *         if self.left_pending_parent is not None or self.pending_parents:
 
6355
 *             return 1             # <<<<<<<<<<<<<<
 
6356
 *         return 0
 
6357
 * 
 
6358
 */
 
6359
    __pyx_r = 1;
 
6360
    goto __pyx_L0;
 
6361
    goto __pyx_L3;
 
6362
  }
 
6363
  __pyx_L3:;
 
6364
 
 
6365
  /* "bzrlib/_known_graph_pyx.pyx":709
 
6366
 *         if self.left_pending_parent is not None or self.pending_parents:
 
6367
 *             return 1
 
6368
 *         return 0             # <<<<<<<<<<<<<<
 
6369
 * 
 
6370
 *     cdef object _revno(self):
 
6371
 */
 
6372
  __pyx_r = 0;
 
6373
  goto __pyx_L0;
 
6374
 
 
6375
  __pyx_r = 0;
 
6376
  goto __pyx_L0;
 
6377
  __pyx_L1_error:;
 
6378
  __Pyx_WriteUnraisable("bzrlib._known_graph_pyx._MergeSortNode.has_pending_parents");
 
6379
  __pyx_r = 0;
 
6380
  __pyx_L0:;
 
6381
  __Pyx_RefNannyFinishContext();
 
6382
  return __pyx_r;
 
6383
}
 
6384
 
 
6385
/* "bzrlib/_known_graph_pyx.pyx":711
 
6386
 *         return 0
 
6387
 * 
 
6388
 *     cdef object _revno(self):             # <<<<<<<<<<<<<<
 
6389
 *         if self._revno_first == -1:
 
6390
 *             if self._revno_second != -1:
 
6391
 */
 
6392
 
 
6393
static  PyObject *__pyx_f_6bzrlib_16_known_graph_pyx_14_MergeSortNode__revno(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_v_self) {
 
6394
  PyObject *__pyx_r = NULL;
 
6395
  int __pyx_t_1;
 
6396
  PyObject *__pyx_t_2 = NULL;
 
6397
  PyObject *__pyx_t_3 = NULL;
 
6398
  PyObject *__pyx_t_4 = NULL;
 
6399
  PyObject *__pyx_t_5 = NULL;
 
6400
  __Pyx_RefNannySetupContext("_revno");
 
6401
 
 
6402
  /* "bzrlib/_known_graph_pyx.pyx":712
 
6403
 * 
 
6404
 *     cdef object _revno(self):
 
6405
 *         if self._revno_first == -1:             # <<<<<<<<<<<<<<
 
6406
 *             if self._revno_second != -1:
 
6407
 *                 raise RuntimeError('Something wrong with: %s' % (self,))
 
6408
 */
 
6409
  __pyx_t_1 = (__pyx_v_self->_revno_first == -1);
 
6410
  if (__pyx_t_1) {
 
6411
 
 
6412
    /* "bzrlib/_known_graph_pyx.pyx":713
 
6413
 *     cdef object _revno(self):
 
6414
 *         if self._revno_first == -1:
 
6415
 *             if self._revno_second != -1:             # <<<<<<<<<<<<<<
 
6416
 *                 raise RuntimeError('Something wrong with: %s' % (self,))
 
6417
 *             return (self._revno_last,)
 
6418
 */
 
6419
    __pyx_t_1 = (__pyx_v_self->_revno_second != -1);
 
6420
    if (__pyx_t_1) {
 
6421
 
 
6422
      /* "bzrlib/_known_graph_pyx.pyx":714
 
6423
 *         if self._revno_first == -1:
 
6424
 *             if self._revno_second != -1:
 
6425
 *                 raise RuntimeError('Something wrong with: %s' % (self,))             # <<<<<<<<<<<<<<
 
6426
 *             return (self._revno_last,)
 
6427
 *         else:
 
6428
 */
 
6429
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6430
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
6431
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
 
6432
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
 
6433
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
 
6434
      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6435
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
6436
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
6437
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6438
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
6439
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
 
6440
      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
 
6441
      __pyx_t_3 = 0;
 
6442
      __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6443
      __Pyx_GOTREF(__pyx_t_3);
 
6444
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
6445
      __Pyx_Raise(__pyx_t_3, 0, 0);
 
6446
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
6447
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6448
      goto __pyx_L4;
 
6449
    }
 
6450
    __pyx_L4:;
 
6451
 
 
6452
    /* "bzrlib/_known_graph_pyx.pyx":715
 
6453
 *             if self._revno_second != -1:
 
6454
 *                 raise RuntimeError('Something wrong with: %s' % (self,))
 
6455
 *             return (self._revno_last,)             # <<<<<<<<<<<<<<
 
6456
 *         else:
 
6457
 *             return (self._revno_first, self._revno_second, self._revno_last)
 
6458
 */
 
6459
    __Pyx_XDECREF(__pyx_r);
 
6460
    __pyx_t_3 = PyInt_FromLong(__pyx_v_self->_revno_last); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6461
    __Pyx_GOTREF(__pyx_t_3);
 
6462
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6463
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
6464
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
 
6465
    __Pyx_GIVEREF(__pyx_t_3);
 
6466
    __pyx_t_3 = 0;
 
6467
    __pyx_r = ((PyObject *)__pyx_t_2);
 
6468
    __pyx_t_2 = 0;
 
6469
    goto __pyx_L0;
 
6470
    goto __pyx_L3;
 
6471
  }
 
6472
  /*else*/ {
 
6473
 
 
6474
    /* "bzrlib/_known_graph_pyx.pyx":717
 
6475
 *             return (self._revno_last,)
 
6476
 *         else:
 
6477
 *             return (self._revno_first, self._revno_second, self._revno_last)             # <<<<<<<<<<<<<<
 
6478
 * 
 
6479
 *     property revno:
 
6480
 */
 
6481
    __Pyx_XDECREF(__pyx_r);
 
6482
    __pyx_t_2 = PyInt_FromLong(__pyx_v_self->_revno_first); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6483
    __Pyx_GOTREF(__pyx_t_2);
 
6484
    __pyx_t_3 = PyInt_FromLong(__pyx_v_self->_revno_second); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6485
    __Pyx_GOTREF(__pyx_t_3);
 
6486
    __pyx_t_4 = PyInt_FromLong(__pyx_v_self->_revno_last); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6487
    __Pyx_GOTREF(__pyx_t_4);
 
6488
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6489
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
 
6490
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
 
6491
    __Pyx_GIVEREF(__pyx_t_2);
 
6492
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
 
6493
    __Pyx_GIVEREF(__pyx_t_3);
 
6494
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
 
6495
    __Pyx_GIVEREF(__pyx_t_4);
 
6496
    __pyx_t_2 = 0;
 
6497
    __pyx_t_3 = 0;
 
6498
    __pyx_t_4 = 0;
 
6499
    __pyx_r = ((PyObject *)__pyx_t_5);
 
6500
    __pyx_t_5 = 0;
 
6501
    goto __pyx_L0;
 
6502
  }
 
6503
  __pyx_L3:;
 
6504
 
 
6505
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
6506
  goto __pyx_L0;
 
6507
  __pyx_L1_error:;
 
6508
  __Pyx_XDECREF(__pyx_t_2);
 
6509
  __Pyx_XDECREF(__pyx_t_3);
 
6510
  __Pyx_XDECREF(__pyx_t_4);
 
6511
  __Pyx_XDECREF(__pyx_t_5);
 
6512
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSortNode._revno");
 
6513
  __pyx_r = 0;
 
6514
  __pyx_L0:;
 
6515
  __Pyx_XGIVEREF(__pyx_r);
 
6516
  __Pyx_RefNannyFinishContext();
 
6517
  return __pyx_r;
 
6518
}
 
6519
 
 
6520
/* "bzrlib/_known_graph_pyx.pyx":720
 
6521
 * 
 
6522
 *     property revno:
 
6523
 *         def __get__(self):             # <<<<<<<<<<<<<<
 
6524
 *             return self._revno()
 
6525
 * 
 
6526
 */
 
6527
 
 
6528
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_5revno___get__(PyObject *__pyx_v_self); /*proto*/
 
6529
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_5revno___get__(PyObject *__pyx_v_self) {
 
6530
  PyObject *__pyx_r = NULL;
 
6531
  PyObject *__pyx_t_1 = NULL;
 
6532
  __Pyx_RefNannySetupContext("__get__");
 
6533
 
 
6534
  /* "bzrlib/_known_graph_pyx.pyx":721
 
6535
 *     property revno:
 
6536
 *         def __get__(self):
 
6537
 *             return self._revno()             # <<<<<<<<<<<<<<
 
6538
 * 
 
6539
 * 
 
6540
 */
 
6541
  __Pyx_XDECREF(__pyx_r);
 
6542
  __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSortNode *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->__pyx_vtab)->_revno(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6543
  __Pyx_GOTREF(__pyx_t_1);
 
6544
  __pyx_r = __pyx_t_1;
 
6545
  __pyx_t_1 = 0;
 
6546
  goto __pyx_L0;
 
6547
 
 
6548
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
6549
  goto __pyx_L0;
 
6550
  __pyx_L1_error:;
 
6551
  __Pyx_XDECREF(__pyx_t_1);
 
6552
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSortNode.revno.__get__");
 
6553
  __pyx_r = NULL;
 
6554
  __pyx_L0:;
 
6555
  __Pyx_XGIVEREF(__pyx_r);
 
6556
  __Pyx_RefNannyFinishContext();
 
6557
  return __pyx_r;
 
6558
}
 
6559
 
 
6560
/* "bzrlib/_known_graph_pyx.pyx":670
 
6561
 * 
 
6562
 *     # Public api
 
6563
 *     cdef public object key             # <<<<<<<<<<<<<<
 
6564
 *     cdef public long merge_depth
 
6565
 *     cdef public object end_of_merge # True/False Is this the end of the current merge
 
6566
 */
 
6567
 
 
6568
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_3key___get__(PyObject *__pyx_v_self); /*proto*/
 
6569
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_3key___get__(PyObject *__pyx_v_self) {
 
6570
  PyObject *__pyx_r = NULL;
 
6571
  __Pyx_RefNannySetupContext("__get__");
 
6572
  __Pyx_XDECREF(__pyx_r);
 
6573
  __Pyx_INCREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key);
 
6574
  __pyx_r = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key;
 
6575
  goto __pyx_L0;
 
6576
 
 
6577
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
6578
  __pyx_L0:;
 
6579
  __Pyx_XGIVEREF(__pyx_r);
 
6580
  __Pyx_RefNannyFinishContext();
 
6581
  return __pyx_r;
 
6582
}
 
6583
 
 
6584
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_3key_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
 
6585
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_3key_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
 
6586
  int __pyx_r;
 
6587
  __Pyx_RefNannySetupContext("__set__");
 
6588
  __Pyx_INCREF(__pyx_v_value);
 
6589
  __Pyx_GIVEREF(__pyx_v_value);
 
6590
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key);
 
6591
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key);
 
6592
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key = __pyx_v_value;
 
6593
 
 
6594
  __pyx_r = 0;
 
6595
  __Pyx_RefNannyFinishContext();
 
6596
  return __pyx_r;
 
6597
}
 
6598
 
 
6599
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_3key_2__del__(PyObject *__pyx_v_self); /*proto*/
 
6600
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_3key_2__del__(PyObject *__pyx_v_self) {
 
6601
  int __pyx_r;
 
6602
  __Pyx_RefNannySetupContext("__del__");
 
6603
  __Pyx_INCREF(Py_None);
 
6604
  __Pyx_GIVEREF(Py_None);
 
6605
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key);
 
6606
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key);
 
6607
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->key = Py_None;
 
6608
 
 
6609
  __pyx_r = 0;
 
6610
  __Pyx_RefNannyFinishContext();
 
6611
  return __pyx_r;
 
6612
}
 
6613
 
 
6614
/* "bzrlib/_known_graph_pyx.pyx":671
 
6615
 *     # Public api
 
6616
 *     cdef public object key
 
6617
 *     cdef public long merge_depth             # <<<<<<<<<<<<<<
 
6618
 *     cdef public object end_of_merge # True/False Is this the end of the current merge
 
6619
 * 
 
6620
 */
 
6621
 
 
6622
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_11merge_depth___get__(PyObject *__pyx_v_self); /*proto*/
 
6623
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_11merge_depth___get__(PyObject *__pyx_v_self) {
 
6624
  PyObject *__pyx_r = NULL;
 
6625
  PyObject *__pyx_t_1 = NULL;
 
6626
  __Pyx_RefNannySetupContext("__get__");
 
6627
  __Pyx_XDECREF(__pyx_r);
 
6628
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->merge_depth); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6629
  __Pyx_GOTREF(__pyx_t_1);
 
6630
  __pyx_r = __pyx_t_1;
 
6631
  __pyx_t_1 = 0;
 
6632
  goto __pyx_L0;
 
6633
 
 
6634
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
6635
  goto __pyx_L0;
 
6636
  __pyx_L1_error:;
 
6637
  __Pyx_XDECREF(__pyx_t_1);
 
6638
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSortNode.merge_depth.__get__");
 
6639
  __pyx_r = NULL;
 
6640
  __pyx_L0:;
 
6641
  __Pyx_XGIVEREF(__pyx_r);
 
6642
  __Pyx_RefNannyFinishContext();
 
6643
  return __pyx_r;
 
6644
}
 
6645
 
 
6646
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_11merge_depth_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
 
6647
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_11merge_depth_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
 
6648
  int __pyx_r;
 
6649
  long __pyx_t_1;
 
6650
  __Pyx_RefNannySetupContext("__set__");
 
6651
  __pyx_t_1 = __Pyx_PyInt_AsLong(__pyx_v_value); if (unlikely((__pyx_t_1 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6652
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->merge_depth = __pyx_t_1;
 
6653
 
 
6654
  __pyx_r = 0;
 
6655
  goto __pyx_L0;
 
6656
  __pyx_L1_error:;
 
6657
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSortNode.merge_depth.__set__");
 
6658
  __pyx_r = -1;
 
6659
  __pyx_L0:;
 
6660
  __Pyx_RefNannyFinishContext();
 
6661
  return __pyx_r;
 
6662
}
 
6663
 
 
6664
/* "bzrlib/_known_graph_pyx.pyx":672
 
6665
 *     cdef public object key
 
6666
 *     cdef public long merge_depth
 
6667
 *     cdef public object end_of_merge # True/False Is this the end of the current merge             # <<<<<<<<<<<<<<
 
6668
 * 
 
6669
 *     # Private api, used while computing the information
 
6670
 */
 
6671
 
 
6672
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_12end_of_merge___get__(PyObject *__pyx_v_self); /*proto*/
 
6673
static PyObject *__pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_12end_of_merge___get__(PyObject *__pyx_v_self) {
 
6674
  PyObject *__pyx_r = NULL;
 
6675
  __Pyx_RefNannySetupContext("__get__");
 
6676
  __Pyx_XDECREF(__pyx_r);
 
6677
  __Pyx_INCREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->end_of_merge);
 
6678
  __pyx_r = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->end_of_merge;
 
6679
  goto __pyx_L0;
 
6680
 
 
6681
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
6682
  __pyx_L0:;
 
6683
  __Pyx_XGIVEREF(__pyx_r);
 
6684
  __Pyx_RefNannyFinishContext();
 
6685
  return __pyx_r;
 
6686
}
 
6687
 
 
6688
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
 
6689
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
 
6690
  int __pyx_r;
 
6691
  __Pyx_RefNannySetupContext("__set__");
 
6692
  __Pyx_INCREF(__pyx_v_value);
 
6693
  __Pyx_GIVEREF(__pyx_v_value);
 
6694
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->end_of_merge);
 
6695
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->end_of_merge);
 
6696
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->end_of_merge = __pyx_v_value;
 
6697
 
 
6698
  __pyx_r = 0;
 
6699
  __Pyx_RefNannyFinishContext();
 
6700
  return __pyx_r;
 
6701
}
 
6702
 
 
6703
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_2__del__(PyObject *__pyx_v_self); /*proto*/
 
6704
static int __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_2__del__(PyObject *__pyx_v_self) {
 
6705
  int __pyx_r;
 
6706
  __Pyx_RefNannySetupContext("__del__");
 
6707
  __Pyx_INCREF(Py_None);
 
6708
  __Pyx_GIVEREF(Py_None);
 
6709
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->end_of_merge);
 
6710
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->end_of_merge);
 
6711
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_self)->end_of_merge = Py_None;
 
6712
 
 
6713
  __pyx_r = 0;
 
6714
  __Pyx_RefNannyFinishContext();
 
6715
  return __pyx_r;
 
6716
}
 
6717
 
 
6718
/* "bzrlib/_known_graph_pyx.pyx":743
 
6719
 *     cdef object _scheduled_nodes # List of nodes ready to be yielded
 
6720
 * 
 
6721
 *     def __init__(self, known_graph, tip_key):             # <<<<<<<<<<<<<<
 
6722
 *         cdef _KnownGraphNode node
 
6723
 * 
 
6724
 */
 
6725
 
 
6726
static int __pyx_pf_6bzrlib_16_known_graph_pyx_12_MergeSorter___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
6727
static int __pyx_pf_6bzrlib_16_known_graph_pyx_12_MergeSorter___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
6728
  PyObject *__pyx_v_known_graph = 0;
 
6729
  PyObject *__pyx_v_tip_key = 0;
 
6730
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
6731
  int __pyx_r;
 
6732
  PyObject *__pyx_t_1 = NULL;
 
6733
  int __pyx_t_2;
 
6734
  int __pyx_t_3;
 
6735
  PyObject *__pyx_t_4 = NULL;
 
6736
  int __pyx_t_5;
 
6737
  int __pyx_t_6;
 
6738
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__known_graph,&__pyx_n_s__tip_key,0};
 
6739
  __Pyx_RefNannySetupContext("__init__");
 
6740
  if (unlikely(__pyx_kwds)) {
 
6741
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
6742
    PyObject* values[2] = {0,0};
 
6743
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
6744
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
 
6745
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
6746
      case  0: break;
 
6747
      default: goto __pyx_L5_argtuple_error;
 
6748
    }
 
6749
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
6750
      case  0:
 
6751
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__known_graph);
 
6752
      if (likely(values[0])) kw_args--;
 
6753
      else goto __pyx_L5_argtuple_error;
 
6754
      case  1:
 
6755
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tip_key);
 
6756
      if (likely(values[1])) kw_args--;
 
6757
      else {
 
6758
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
6759
      }
 
6760
    }
 
6761
    if (unlikely(kw_args > 0)) {
 
6762
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
6763
    }
 
6764
    __pyx_v_known_graph = values[0];
 
6765
    __pyx_v_tip_key = values[1];
 
6766
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
 
6767
    goto __pyx_L5_argtuple_error;
 
6768
  } else {
 
6769
    __pyx_v_known_graph = PyTuple_GET_ITEM(__pyx_args, 0);
 
6770
    __pyx_v_tip_key = PyTuple_GET_ITEM(__pyx_args, 1);
 
6771
  }
 
6772
  goto __pyx_L4_argument_unpacking_done;
 
6773
  __pyx_L5_argtuple_error:;
 
6774
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
6775
  __pyx_L3_error:;
 
6776
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSorter.__init__");
 
6777
  __Pyx_RefNannyFinishContext();
 
6778
  return -1;
 
6779
  __pyx_L4_argument_unpacking_done:;
 
6780
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
6781
 
 
6782
  /* "bzrlib/_known_graph_pyx.pyx":746
 
6783
 *         cdef _KnownGraphNode node
 
6784
 * 
 
6785
 *         self.graph = known_graph             # <<<<<<<<<<<<<<
 
6786
 *         # self._ms_nodes = {}
 
6787
 *         self._revno_to_branch_count = {}
 
6788
 */
 
6789
  if (!(likely(((__pyx_v_known_graph) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_known_graph, __pyx_ptype_6bzrlib_16_known_graph_pyx_KnownGraph))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6790
  __Pyx_INCREF(__pyx_v_known_graph);
 
6791
  __Pyx_GIVEREF(__pyx_v_known_graph);
 
6792
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->graph);
 
6793
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->graph));
 
6794
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->graph = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)__pyx_v_known_graph);
 
6795
 
 
6796
  /* "bzrlib/_known_graph_pyx.pyx":748
 
6797
 *         self.graph = known_graph
 
6798
 *         # self._ms_nodes = {}
 
6799
 *         self._revno_to_branch_count = {}             # <<<<<<<<<<<<<<
 
6800
 *         self._depth_first_stack = []
 
6801
 *         self._last_stack_item = -1
 
6802
 */
 
6803
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6804
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
6805
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
 
6806
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->_revno_to_branch_count);
 
6807
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->_revno_to_branch_count);
 
6808
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->_revno_to_branch_count = ((PyObject *)__pyx_t_1);
 
6809
  __pyx_t_1 = 0;
 
6810
 
 
6811
  /* "bzrlib/_known_graph_pyx.pyx":749
 
6812
 *         # self._ms_nodes = {}
 
6813
 *         self._revno_to_branch_count = {}
 
6814
 *         self._depth_first_stack = []             # <<<<<<<<<<<<<<
 
6815
 *         self._last_stack_item = -1
 
6816
 *         self._scheduled_nodes = []
 
6817
 */
 
6818
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6819
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
6820
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
 
6821
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->_depth_first_stack);
 
6822
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->_depth_first_stack);
 
6823
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->_depth_first_stack = ((PyObject *)__pyx_t_1);
 
6824
  __pyx_t_1 = 0;
 
6825
 
 
6826
  /* "bzrlib/_known_graph_pyx.pyx":750
 
6827
 *         self._revno_to_branch_count = {}
 
6828
 *         self._depth_first_stack = []
 
6829
 *         self._last_stack_item = -1             # <<<<<<<<<<<<<<
 
6830
 *         self._scheduled_nodes = []
 
6831
 *         if (tip_key is not None and tip_key != NULL_REVISION
 
6832
 */
 
6833
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->_last_stack_item = -1;
 
6834
 
 
6835
  /* "bzrlib/_known_graph_pyx.pyx":751
 
6836
 *         self._depth_first_stack = []
 
6837
 *         self._last_stack_item = -1
 
6838
 *         self._scheduled_nodes = []             # <<<<<<<<<<<<<<
 
6839
 *         if (tip_key is not None and tip_key != NULL_REVISION
 
6840
 *             and tip_key != (NULL_REVISION,)):
 
6841
 */
 
6842
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6843
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
6844
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
 
6845
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->_scheduled_nodes);
 
6846
  __Pyx_DECREF(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->_scheduled_nodes);
 
6847
  ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->_scheduled_nodes = ((PyObject *)__pyx_t_1);
 
6848
  __pyx_t_1 = 0;
 
6849
 
 
6850
  /* "bzrlib/_known_graph_pyx.pyx":752
 
6851
 *         self._last_stack_item = -1
 
6852
 *         self._scheduled_nodes = []
 
6853
 *         if (tip_key is not None and tip_key != NULL_REVISION             # <<<<<<<<<<<<<<
 
6854
 *             and tip_key != (NULL_REVISION,)):
 
6855
 *             node = self.graph._nodes[tip_key]
 
6856
 */
 
6857
  __pyx_t_2 = (__pyx_v_tip_key != Py_None);
 
6858
  if (__pyx_t_2) {
 
6859
 
 
6860
    /* "bzrlib/_known_graph_pyx.pyx":753
 
6861
 *         self._scheduled_nodes = []
 
6862
 *         if (tip_key is not None and tip_key != NULL_REVISION
 
6863
 *             and tip_key != (NULL_REVISION,)):             # <<<<<<<<<<<<<<
 
6864
 *             node = self.graph._nodes[tip_key]
 
6865
 *             self._push_node(node, 0)
 
6866
 */
 
6867
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_tip_key, __pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6868
    __Pyx_GOTREF(__pyx_t_1);
 
6869
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6870
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
6871
    if (__pyx_t_3) {
 
6872
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6873
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
6874
      __Pyx_INCREF(__pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
6875
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
6876
      __Pyx_GIVEREF(__pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
6877
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_tip_key, ((PyObject *)__pyx_t_1), Py_NE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6878
      __Pyx_GOTREF(__pyx_t_4);
 
6879
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
6880
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6881
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
6882
      __pyx_t_6 = __pyx_t_5;
 
6883
    } else {
 
6884
      __pyx_t_6 = __pyx_t_3;
 
6885
    }
 
6886
    __pyx_t_3 = __pyx_t_6;
 
6887
  } else {
 
6888
    __pyx_t_3 = __pyx_t_2;
 
6889
  }
 
6890
  if (__pyx_t_3) {
 
6891
 
 
6892
    /* "bzrlib/_known_graph_pyx.pyx":754
 
6893
 *         if (tip_key is not None and tip_key != NULL_REVISION
 
6894
 *             and tip_key != (NULL_REVISION,)):
 
6895
 *             node = self.graph._nodes[tip_key]             # <<<<<<<<<<<<<<
 
6896
 *             self._push_node(node, 0)
 
6897
 * 
 
6898
 */
 
6899
    __pyx_t_4 = PyObject_GetItem(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->graph->_nodes, __pyx_v_tip_key); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6900
    __Pyx_GOTREF(__pyx_t_4);
 
6901
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6902
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
6903
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4);
 
6904
    __pyx_t_4 = 0;
 
6905
 
 
6906
    /* "bzrlib/_known_graph_pyx.pyx":755
 
6907
 *             and tip_key != (NULL_REVISION,)):
 
6908
 *             node = self.graph._nodes[tip_key]
 
6909
 *             self._push_node(node, 0)             # <<<<<<<<<<<<<<
 
6910
 * 
 
6911
 *     cdef _MergeSortNode _get_ms_node(self, _KnownGraphNode node):
 
6912
 */
 
6913
    __pyx_t_4 = ((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self)->__pyx_vtab)->_push_node(((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self), __pyx_v_node, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6914
    __Pyx_GOTREF(__pyx_t_4);
 
6915
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
6916
    goto __pyx_L6;
 
6917
  }
 
6918
  __pyx_L6:;
 
6919
 
 
6920
  __pyx_r = 0;
 
6921
  goto __pyx_L0;
 
6922
  __pyx_L1_error:;
 
6923
  __Pyx_XDECREF(__pyx_t_1);
 
6924
  __Pyx_XDECREF(__pyx_t_4);
 
6925
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSorter.__init__");
 
6926
  __pyx_r = -1;
 
6927
  __pyx_L0:;
 
6928
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
6929
  __Pyx_RefNannyFinishContext();
 
6930
  return __pyx_r;
 
6931
}
 
6932
 
 
6933
/* "bzrlib/_known_graph_pyx.pyx":757
 
6934
 *             self._push_node(node, 0)
 
6935
 * 
 
6936
 *     cdef _MergeSortNode _get_ms_node(self, _KnownGraphNode node):             # <<<<<<<<<<<<<<
 
6937
 *         cdef PyObject *temp_node
 
6938
 *         cdef _MergeSortNode ms_node
 
6939
 */
 
6940
 
 
6941
static  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_f_6bzrlib_16_known_graph_pyx_12_MergeSorter__get_ms_node(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *__pyx_v_self, struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node) {
 
6942
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_node;
 
6943
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_r = NULL;
 
6944
  int __pyx_t_1;
 
6945
  PyObject *__pyx_t_2 = NULL;
 
6946
  PyObject *__pyx_t_3 = NULL;
 
6947
  __Pyx_RefNannySetupContext("_get_ms_node");
 
6948
  __pyx_v_ms_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)Py_None); __Pyx_INCREF(Py_None);
 
6949
 
 
6950
  /* "bzrlib/_known_graph_pyx.pyx":761
 
6951
 *         cdef _MergeSortNode ms_node
 
6952
 * 
 
6953
 *         if node.extra is None:             # <<<<<<<<<<<<<<
 
6954
 *             ms_node = _MergeSortNode(node.key)
 
6955
 *             node.extra = ms_node
 
6956
 */
 
6957
  __pyx_t_1 = (__pyx_v_node->extra == Py_None);
 
6958
  if (__pyx_t_1) {
 
6959
 
 
6960
    /* "bzrlib/_known_graph_pyx.pyx":762
 
6961
 * 
 
6962
 *         if node.extra is None:
 
6963
 *             ms_node = _MergeSortNode(node.key)             # <<<<<<<<<<<<<<
 
6964
 *             node.extra = ms_node
 
6965
 *         else:
 
6966
 */
 
6967
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6968
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
6969
    __Pyx_INCREF(__pyx_v_node->key);
 
6970
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_node->key);
 
6971
    __Pyx_GIVEREF(__pyx_v_node->key);
 
6972
    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_16_known_graph_pyx__MergeSortNode)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
6973
    __Pyx_GOTREF(__pyx_t_3);
 
6974
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
6975
    __Pyx_DECREF(((PyObject *)__pyx_v_ms_node));
 
6976
    __pyx_v_ms_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_t_3);
 
6977
    __pyx_t_3 = 0;
 
6978
 
 
6979
    /* "bzrlib/_known_graph_pyx.pyx":763
 
6980
 *         if node.extra is None:
 
6981
 *             ms_node = _MergeSortNode(node.key)
 
6982
 *             node.extra = ms_node             # <<<<<<<<<<<<<<
 
6983
 *         else:
 
6984
 *             ms_node = <_MergeSortNode>node.extra
 
6985
 */
 
6986
    __Pyx_INCREF(((PyObject *)__pyx_v_ms_node));
 
6987
    __Pyx_GIVEREF(((PyObject *)__pyx_v_ms_node));
 
6988
    __Pyx_GOTREF(__pyx_v_node->extra);
 
6989
    __Pyx_DECREF(__pyx_v_node->extra);
 
6990
    __pyx_v_node->extra = ((PyObject *)__pyx_v_ms_node);
 
6991
    goto __pyx_L3;
 
6992
  }
 
6993
  /*else*/ {
 
6994
 
 
6995
    /* "bzrlib/_known_graph_pyx.pyx":765
 
6996
 *             node.extra = ms_node
 
6997
 *         else:
 
6998
 *             ms_node = <_MergeSortNode>node.extra             # <<<<<<<<<<<<<<
 
6999
 *         return ms_node
 
7000
 * 
 
7001
 */
 
7002
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_node->extra)));
 
7003
    __Pyx_DECREF(((PyObject *)__pyx_v_ms_node));
 
7004
    __pyx_v_ms_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_node->extra);
 
7005
  }
 
7006
  __pyx_L3:;
 
7007
 
 
7008
  /* "bzrlib/_known_graph_pyx.pyx":766
 
7009
 *         else:
 
7010
 *             ms_node = <_MergeSortNode>node.extra
 
7011
 *         return ms_node             # <<<<<<<<<<<<<<
 
7012
 * 
 
7013
 *     cdef _push_node(self, _KnownGraphNode node, long merge_depth):
 
7014
 */
 
7015
  __Pyx_XDECREF(((PyObject *)__pyx_r));
 
7016
  __Pyx_INCREF(((PyObject *)__pyx_v_ms_node));
 
7017
  __pyx_r = __pyx_v_ms_node;
 
7018
  goto __pyx_L0;
 
7019
 
 
7020
  __pyx_r = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)Py_None); __Pyx_INCREF(Py_None);
 
7021
  goto __pyx_L0;
 
7022
  __pyx_L1_error:;
 
7023
  __Pyx_XDECREF(__pyx_t_2);
 
7024
  __Pyx_XDECREF(__pyx_t_3);
 
7025
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSorter._get_ms_node");
 
7026
  __pyx_r = 0;
 
7027
  __pyx_L0:;
 
7028
  __Pyx_DECREF((PyObject *)__pyx_v_ms_node);
 
7029
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
 
7030
  __Pyx_RefNannyFinishContext();
 
7031
  return __pyx_r;
 
7032
}
 
7033
 
 
7034
/* "bzrlib/_known_graph_pyx.pyx":768
 
7035
 *         return ms_node
 
7036
 * 
 
7037
 *     cdef _push_node(self, _KnownGraphNode node, long merge_depth):             # <<<<<<<<<<<<<<
 
7038
 *         cdef _KnownGraphNode parent_node
 
7039
 *         cdef _MergeSortNode ms_node, ms_parent_node
 
7040
 */
 
7041
 
 
7042
static  PyObject *__pyx_f_6bzrlib_16_known_graph_pyx_12_MergeSorter__push_node(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *__pyx_v_self, struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node, long __pyx_v_merge_depth) {
 
7043
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_parent_node;
 
7044
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_node;
 
7045
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_parent_node;
 
7046
  Py_ssize_t __pyx_v_pos;
 
7047
  PyObject *__pyx_r = NULL;
 
7048
  PyObject *__pyx_t_1 = NULL;
 
7049
  int __pyx_t_2;
 
7050
  PyObject *__pyx_t_3 = NULL;
 
7051
  Py_ssize_t __pyx_t_4;
 
7052
  int __pyx_t_5;
 
7053
  __Pyx_RefNannySetupContext("_push_node");
 
7054
  __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
7055
  __pyx_v_ms_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)Py_None); __Pyx_INCREF(Py_None);
 
7056
  __pyx_v_ms_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)Py_None); __Pyx_INCREF(Py_None);
 
7057
 
 
7058
  /* "bzrlib/_known_graph_pyx.pyx":773
 
7059
 *         cdef Py_ssize_t pos
 
7060
 * 
 
7061
 *         ms_node = self._get_ms_node(node)             # <<<<<<<<<<<<<<
 
7062
 *         ms_node.merge_depth = merge_depth
 
7063
 *         if node.parents is None:
 
7064
 */
 
7065
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_get_ms_node(__pyx_v_self, __pyx_v_node)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7066
  __Pyx_GOTREF(__pyx_t_1);
 
7067
  __Pyx_DECREF(((PyObject *)__pyx_v_ms_node));
 
7068
  __pyx_v_ms_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_t_1);
 
7069
  __pyx_t_1 = 0;
 
7070
 
 
7071
  /* "bzrlib/_known_graph_pyx.pyx":774
 
7072
 * 
 
7073
 *         ms_node = self._get_ms_node(node)
 
7074
 *         ms_node.merge_depth = merge_depth             # <<<<<<<<<<<<<<
 
7075
 *         if node.parents is None:
 
7076
 *             raise RuntimeError('ghost nodes should not be pushed'
 
7077
 */
 
7078
  __pyx_v_ms_node->merge_depth = __pyx_v_merge_depth;
 
7079
 
 
7080
  /* "bzrlib/_known_graph_pyx.pyx":775
 
7081
 *         ms_node = self._get_ms_node(node)
 
7082
 *         ms_node.merge_depth = merge_depth
 
7083
 *         if node.parents is None:             # <<<<<<<<<<<<<<
 
7084
 *             raise RuntimeError('ghost nodes should not be pushed'
 
7085
 *                                ' onto the stack: %s' % (node,))
 
7086
 */
 
7087
  __pyx_t_2 = (__pyx_v_node->parents == Py_None);
 
7088
  if (__pyx_t_2) {
 
7089
 
 
7090
    /* "bzrlib/_known_graph_pyx.pyx":777
 
7091
 *         if node.parents is None:
 
7092
 *             raise RuntimeError('ghost nodes should not be pushed'
 
7093
 *                                ' onto the stack: %s' % (node,))             # <<<<<<<<<<<<<<
 
7094
 *         if PyTuple_GET_SIZE(node.parents) > 0:
 
7095
 *             parent_node = _get_tuple_node(node.parents, 0)
 
7096
 */
 
7097
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7098
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
7099
    __Pyx_INCREF(((PyObject *)__pyx_v_node));
 
7100
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_node));
 
7101
    __Pyx_GIVEREF(((PyObject *)__pyx_v_node));
 
7102
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_13), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7103
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
7104
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
7105
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7106
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
7107
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3));
 
7108
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
 
7109
    __pyx_t_3 = 0;
 
7110
    __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7111
    __Pyx_GOTREF(__pyx_t_3);
 
7112
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
7113
    __Pyx_Raise(__pyx_t_3, 0, 0);
 
7114
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
7115
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7116
    goto __pyx_L3;
 
7117
  }
 
7118
  __pyx_L3:;
 
7119
 
 
7120
  /* "bzrlib/_known_graph_pyx.pyx":778
 
7121
 *             raise RuntimeError('ghost nodes should not be pushed'
 
7122
 *                                ' onto the stack: %s' % (node,))
 
7123
 *         if PyTuple_GET_SIZE(node.parents) > 0:             # <<<<<<<<<<<<<<
 
7124
 *             parent_node = _get_tuple_node(node.parents, 0)
 
7125
 *             ms_node.left_parent = parent_node
 
7126
 */
 
7127
  __pyx_t_3 = __pyx_v_node->parents;
 
7128
  __Pyx_INCREF(__pyx_t_3);
 
7129
  __pyx_t_2 = (PyTuple_GET_SIZE(__pyx_t_3) > 0);
 
7130
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
7131
  if (__pyx_t_2) {
 
7132
 
 
7133
    /* "bzrlib/_known_graph_pyx.pyx":779
 
7134
 *                                ' onto the stack: %s' % (node,))
 
7135
 *         if PyTuple_GET_SIZE(node.parents) > 0:
 
7136
 *             parent_node = _get_tuple_node(node.parents, 0)             # <<<<<<<<<<<<<<
 
7137
 *             ms_node.left_parent = parent_node
 
7138
 *             if parent_node.parents is None: # left-hand ghost
 
7139
 */
 
7140
    __pyx_t_3 = __pyx_v_node->parents;
 
7141
    __Pyx_INCREF(__pyx_t_3);
 
7142
    __pyx_t_1 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_tuple_node(__pyx_t_3, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7143
    __Pyx_GOTREF(__pyx_t_1);
 
7144
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
7145
    __Pyx_DECREF(((PyObject *)__pyx_v_parent_node));
 
7146
    __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_1);
 
7147
    __pyx_t_1 = 0;
 
7148
 
 
7149
    /* "bzrlib/_known_graph_pyx.pyx":780
 
7150
 *         if PyTuple_GET_SIZE(node.parents) > 0:
 
7151
 *             parent_node = _get_tuple_node(node.parents, 0)
 
7152
 *             ms_node.left_parent = parent_node             # <<<<<<<<<<<<<<
 
7153
 *             if parent_node.parents is None: # left-hand ghost
 
7154
 *                 ms_node.left_pending_parent = None
 
7155
 */
 
7156
    __Pyx_INCREF(((PyObject *)__pyx_v_parent_node));
 
7157
    __Pyx_GIVEREF(((PyObject *)__pyx_v_parent_node));
 
7158
    __Pyx_GOTREF(__pyx_v_ms_node->left_parent);
 
7159
    __Pyx_DECREF(((PyObject *)__pyx_v_ms_node->left_parent));
 
7160
    __pyx_v_ms_node->left_parent = __pyx_v_parent_node;
 
7161
 
 
7162
    /* "bzrlib/_known_graph_pyx.pyx":781
 
7163
 *             parent_node = _get_tuple_node(node.parents, 0)
 
7164
 *             ms_node.left_parent = parent_node
 
7165
 *             if parent_node.parents is None: # left-hand ghost             # <<<<<<<<<<<<<<
 
7166
 *                 ms_node.left_pending_parent = None
 
7167
 *                 ms_node.left_parent = None
 
7168
 */
 
7169
    __pyx_t_2 = (__pyx_v_parent_node->parents == Py_None);
 
7170
    if (__pyx_t_2) {
 
7171
 
 
7172
      /* "bzrlib/_known_graph_pyx.pyx":782
 
7173
 *             ms_node.left_parent = parent_node
 
7174
 *             if parent_node.parents is None: # left-hand ghost
 
7175
 *                 ms_node.left_pending_parent = None             # <<<<<<<<<<<<<<
 
7176
 *                 ms_node.left_parent = None
 
7177
 *             else:
 
7178
 */
 
7179
      __Pyx_INCREF(Py_None);
 
7180
      __Pyx_GIVEREF(Py_None);
 
7181
      __Pyx_GOTREF(__pyx_v_ms_node->left_pending_parent);
 
7182
      __Pyx_DECREF(((PyObject *)__pyx_v_ms_node->left_pending_parent));
 
7183
      __pyx_v_ms_node->left_pending_parent = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None);
 
7184
 
 
7185
      /* "bzrlib/_known_graph_pyx.pyx":783
 
7186
 *             if parent_node.parents is None: # left-hand ghost
 
7187
 *                 ms_node.left_pending_parent = None
 
7188
 *                 ms_node.left_parent = None             # <<<<<<<<<<<<<<
 
7189
 *             else:
 
7190
 *                 ms_node.left_pending_parent = parent_node
 
7191
 */
 
7192
      __Pyx_INCREF(Py_None);
 
7193
      __Pyx_GIVEREF(Py_None);
 
7194
      __Pyx_GOTREF(__pyx_v_ms_node->left_parent);
 
7195
      __Pyx_DECREF(((PyObject *)__pyx_v_ms_node->left_parent));
 
7196
      __pyx_v_ms_node->left_parent = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None);
 
7197
      goto __pyx_L5;
 
7198
    }
 
7199
    /*else*/ {
 
7200
 
 
7201
      /* "bzrlib/_known_graph_pyx.pyx":785
 
7202
 *                 ms_node.left_parent = None
 
7203
 *             else:
 
7204
 *                 ms_node.left_pending_parent = parent_node             # <<<<<<<<<<<<<<
 
7205
 *         if PyTuple_GET_SIZE(node.parents) > 1:
 
7206
 *             ms_node.pending_parents = []
 
7207
 */
 
7208
      __Pyx_INCREF(((PyObject *)__pyx_v_parent_node));
 
7209
      __Pyx_GIVEREF(((PyObject *)__pyx_v_parent_node));
 
7210
      __Pyx_GOTREF(__pyx_v_ms_node->left_pending_parent);
 
7211
      __Pyx_DECREF(((PyObject *)__pyx_v_ms_node->left_pending_parent));
 
7212
      __pyx_v_ms_node->left_pending_parent = __pyx_v_parent_node;
 
7213
    }
 
7214
    __pyx_L5:;
 
7215
    goto __pyx_L4;
 
7216
  }
 
7217
  __pyx_L4:;
 
7218
 
 
7219
  /* "bzrlib/_known_graph_pyx.pyx":786
 
7220
 *             else:
 
7221
 *                 ms_node.left_pending_parent = parent_node
 
7222
 *         if PyTuple_GET_SIZE(node.parents) > 1:             # <<<<<<<<<<<<<<
 
7223
 *             ms_node.pending_parents = []
 
7224
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):
 
7225
 */
 
7226
  __pyx_t_1 = __pyx_v_node->parents;
 
7227
  __Pyx_INCREF(__pyx_t_1);
 
7228
  __pyx_t_2 = (PyTuple_GET_SIZE(__pyx_t_1) > 1);
 
7229
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
7230
  if (__pyx_t_2) {
 
7231
 
 
7232
    /* "bzrlib/_known_graph_pyx.pyx":787
 
7233
 *                 ms_node.left_pending_parent = parent_node
 
7234
 *         if PyTuple_GET_SIZE(node.parents) > 1:
 
7235
 *             ms_node.pending_parents = []             # <<<<<<<<<<<<<<
 
7236
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):
 
7237
 *                 parent_node = _get_tuple_node(node.parents, pos)
 
7238
 */
 
7239
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7240
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
7241
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
 
7242
    __Pyx_GOTREF(__pyx_v_ms_node->pending_parents);
 
7243
    __Pyx_DECREF(__pyx_v_ms_node->pending_parents);
 
7244
    __pyx_v_ms_node->pending_parents = ((PyObject *)__pyx_t_1);
 
7245
    __pyx_t_1 = 0;
 
7246
 
 
7247
    /* "bzrlib/_known_graph_pyx.pyx":788
 
7248
 *         if PyTuple_GET_SIZE(node.parents) > 1:
 
7249
 *             ms_node.pending_parents = []
 
7250
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):             # <<<<<<<<<<<<<<
 
7251
 *                 parent_node = _get_tuple_node(node.parents, pos)
 
7252
 *                 if parent_node.parents is None: # ghost
 
7253
 */
 
7254
    __pyx_t_1 = __pyx_v_node->parents;
 
7255
    __Pyx_INCREF(__pyx_t_1);
 
7256
    __pyx_t_4 = PyTuple_GET_SIZE(__pyx_t_1);
 
7257
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
7258
    for (__pyx_v_pos = 1; __pyx_v_pos < __pyx_t_4; __pyx_v_pos++) {
 
7259
 
 
7260
      /* "bzrlib/_known_graph_pyx.pyx":789
 
7261
 *             ms_node.pending_parents = []
 
7262
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):
 
7263
 *                 parent_node = _get_tuple_node(node.parents, pos)             # <<<<<<<<<<<<<<
 
7264
 *                 if parent_node.parents is None: # ghost
 
7265
 *                     continue
 
7266
 */
 
7267
      __pyx_t_1 = __pyx_v_node->parents;
 
7268
      __Pyx_INCREF(__pyx_t_1);
 
7269
      __pyx_t_3 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_tuple_node(__pyx_t_1, __pyx_v_pos)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7270
      __Pyx_GOTREF(__pyx_t_3);
 
7271
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
7272
      __Pyx_DECREF(((PyObject *)__pyx_v_parent_node));
 
7273
      __pyx_v_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
 
7274
      __pyx_t_3 = 0;
 
7275
 
 
7276
      /* "bzrlib/_known_graph_pyx.pyx":790
 
7277
 *             for pos from 1 <= pos < PyTuple_GET_SIZE(node.parents):
 
7278
 *                 parent_node = _get_tuple_node(node.parents, pos)
 
7279
 *                 if parent_node.parents is None: # ghost             # <<<<<<<<<<<<<<
 
7280
 *                     continue
 
7281
 *                 PyList_Append(ms_node.pending_parents, parent_node)
 
7282
 */
 
7283
      __pyx_t_2 = (__pyx_v_parent_node->parents == Py_None);
 
7284
      if (__pyx_t_2) {
 
7285
 
 
7286
        /* "bzrlib/_known_graph_pyx.pyx":791
 
7287
 *                 parent_node = _get_tuple_node(node.parents, pos)
 
7288
 *                 if parent_node.parents is None: # ghost
 
7289
 *                     continue             # <<<<<<<<<<<<<<
 
7290
 *                 PyList_Append(ms_node.pending_parents, parent_node)
 
7291
 * 
 
7292
 */
 
7293
        goto __pyx_L7_continue;
 
7294
        goto __pyx_L9;
 
7295
      }
 
7296
      __pyx_L9:;
 
7297
 
 
7298
      /* "bzrlib/_known_graph_pyx.pyx":792
 
7299
 *                 if parent_node.parents is None: # ghost
 
7300
 *                     continue
 
7301
 *                 PyList_Append(ms_node.pending_parents, parent_node)             # <<<<<<<<<<<<<<
 
7302
 * 
 
7303
 *         ms_node.is_first_child = 1
 
7304
 */
 
7305
      __pyx_t_3 = __pyx_v_ms_node->pending_parents;
 
7306
      __Pyx_INCREF(__pyx_t_3);
 
7307
      __pyx_t_5 = PyList_Append(__pyx_t_3, ((PyObject *)__pyx_v_parent_node)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7308
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
7309
      __pyx_L7_continue:;
 
7310
    }
 
7311
    goto __pyx_L6;
 
7312
  }
 
7313
  __pyx_L6:;
 
7314
 
 
7315
  /* "bzrlib/_known_graph_pyx.pyx":794
 
7316
 *                 PyList_Append(ms_node.pending_parents, parent_node)
 
7317
 * 
 
7318
 *         ms_node.is_first_child = 1             # <<<<<<<<<<<<<<
 
7319
 *         if ms_node.left_parent is not None:
 
7320
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)
 
7321
 */
 
7322
  __pyx_v_ms_node->is_first_child = 1;
 
7323
 
 
7324
  /* "bzrlib/_known_graph_pyx.pyx":795
 
7325
 * 
 
7326
 *         ms_node.is_first_child = 1
 
7327
 *         if ms_node.left_parent is not None:             # <<<<<<<<<<<<<<
 
7328
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)
 
7329
 *             if ms_parent_node.seen_by_child:
 
7330
 */
 
7331
  __pyx_t_2 = (((PyObject *)__pyx_v_ms_node->left_parent) != Py_None);
 
7332
  if (__pyx_t_2) {
 
7333
 
 
7334
    /* "bzrlib/_known_graph_pyx.pyx":796
 
7335
 *         ms_node.is_first_child = 1
 
7336
 *         if ms_node.left_parent is not None:
 
7337
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)             # <<<<<<<<<<<<<<
 
7338
 *             if ms_parent_node.seen_by_child:
 
7339
 *                 ms_node.is_first_child = 0
 
7340
 */
 
7341
    __pyx_t_3 = ((PyObject *)__pyx_v_ms_node->left_parent);
 
7342
    __Pyx_INCREF(__pyx_t_3);
 
7343
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_get_ms_node(__pyx_v_self, ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7344
    __Pyx_GOTREF(__pyx_t_1);
 
7345
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
7346
    __Pyx_DECREF(((PyObject *)__pyx_v_ms_parent_node));
 
7347
    __pyx_v_ms_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_t_1);
 
7348
    __pyx_t_1 = 0;
 
7349
 
 
7350
    /* "bzrlib/_known_graph_pyx.pyx":797
 
7351
 *         if ms_node.left_parent is not None:
 
7352
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)
 
7353
 *             if ms_parent_node.seen_by_child:             # <<<<<<<<<<<<<<
 
7354
 *                 ms_node.is_first_child = 0
 
7355
 *             ms_parent_node.seen_by_child = 1
 
7356
 */
 
7357
    if (__pyx_v_ms_parent_node->seen_by_child) {
 
7358
 
 
7359
      /* "bzrlib/_known_graph_pyx.pyx":798
 
7360
 *             ms_parent_node = self._get_ms_node(ms_node.left_parent)
 
7361
 *             if ms_parent_node.seen_by_child:
 
7362
 *                 ms_node.is_first_child = 0             # <<<<<<<<<<<<<<
 
7363
 *             ms_parent_node.seen_by_child = 1
 
7364
 *         self._last_stack_item = self._last_stack_item + 1
 
7365
 */
 
7366
      __pyx_v_ms_node->is_first_child = 0;
 
7367
      goto __pyx_L11;
 
7368
    }
 
7369
    __pyx_L11:;
 
7370
 
 
7371
    /* "bzrlib/_known_graph_pyx.pyx":799
 
7372
 *             if ms_parent_node.seen_by_child:
 
7373
 *                 ms_node.is_first_child = 0
 
7374
 *             ms_parent_node.seen_by_child = 1             # <<<<<<<<<<<<<<
 
7375
 *         self._last_stack_item = self._last_stack_item + 1
 
7376
 *         if self._last_stack_item < PyList_GET_SIZE(self._depth_first_stack):
 
7377
 */
 
7378
    __pyx_v_ms_parent_node->seen_by_child = 1;
 
7379
    goto __pyx_L10;
 
7380
  }
 
7381
  __pyx_L10:;
 
7382
 
 
7383
  /* "bzrlib/_known_graph_pyx.pyx":800
 
7384
 *                 ms_node.is_first_child = 0
 
7385
 *             ms_parent_node.seen_by_child = 1
 
7386
 *         self._last_stack_item = self._last_stack_item + 1             # <<<<<<<<<<<<<<
 
7387
 *         if self._last_stack_item < PyList_GET_SIZE(self._depth_first_stack):
 
7388
 *             Py_INCREF(node) # SetItem steals a ref
 
7389
 */
 
7390
  __pyx_v_self->_last_stack_item = (__pyx_v_self->_last_stack_item + 1);
 
7391
 
 
7392
  /* "bzrlib/_known_graph_pyx.pyx":801
 
7393
 *             ms_parent_node.seen_by_child = 1
 
7394
 *         self._last_stack_item = self._last_stack_item + 1
 
7395
 *         if self._last_stack_item < PyList_GET_SIZE(self._depth_first_stack):             # <<<<<<<<<<<<<<
 
7396
 *             Py_INCREF(node) # SetItem steals a ref
 
7397
 *             PyList_SetItem(self._depth_first_stack, self._last_stack_item,
 
7398
 */
 
7399
  __pyx_t_1 = __pyx_v_self->_depth_first_stack;
 
7400
  __Pyx_INCREF(__pyx_t_1);
 
7401
  __pyx_t_2 = (__pyx_v_self->_last_stack_item < PyList_GET_SIZE(__pyx_t_1));
 
7402
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
7403
  if (__pyx_t_2) {
 
7404
 
 
7405
    /* "bzrlib/_known_graph_pyx.pyx":802
 
7406
 *         self._last_stack_item = self._last_stack_item + 1
 
7407
 *         if self._last_stack_item < PyList_GET_SIZE(self._depth_first_stack):
 
7408
 *             Py_INCREF(node) # SetItem steals a ref             # <<<<<<<<<<<<<<
 
7409
 *             PyList_SetItem(self._depth_first_stack, self._last_stack_item,
 
7410
 *                            node)
 
7411
 */
 
7412
    Py_INCREF(((PyObject *)__pyx_v_node));
 
7413
 
 
7414
    /* "bzrlib/_known_graph_pyx.pyx":803
 
7415
 *         if self._last_stack_item < PyList_GET_SIZE(self._depth_first_stack):
 
7416
 *             Py_INCREF(node) # SetItem steals a ref
 
7417
 *             PyList_SetItem(self._depth_first_stack, self._last_stack_item,             # <<<<<<<<<<<<<<
 
7418
 *                            node)
 
7419
 *         else:
 
7420
 */
 
7421
    __pyx_t_1 = __pyx_v_self->_depth_first_stack;
 
7422
    __Pyx_INCREF(__pyx_t_1);
 
7423
 
 
7424
    /* "bzrlib/_known_graph_pyx.pyx":804
 
7425
 *             Py_INCREF(node) # SetItem steals a ref
 
7426
 *             PyList_SetItem(self._depth_first_stack, self._last_stack_item,
 
7427
 *                            node)             # <<<<<<<<<<<<<<
 
7428
 *         else:
 
7429
 *             PyList_Append(self._depth_first_stack, node)
 
7430
 */
 
7431
    __pyx_t_5 = PyList_SetItem(__pyx_t_1, __pyx_v_self->_last_stack_item, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7432
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
7433
    goto __pyx_L12;
 
7434
  }
 
7435
  /*else*/ {
 
7436
 
 
7437
    /* "bzrlib/_known_graph_pyx.pyx":806
 
7438
 *                            node)
 
7439
 *         else:
 
7440
 *             PyList_Append(self._depth_first_stack, node)             # <<<<<<<<<<<<<<
 
7441
 * 
 
7442
 *     cdef _pop_node(self):
 
7443
 */
 
7444
    __pyx_t_1 = __pyx_v_self->_depth_first_stack;
 
7445
    __Pyx_INCREF(__pyx_t_1);
 
7446
    __pyx_t_5 = PyList_Append(__pyx_t_1, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7447
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
7448
  }
 
7449
  __pyx_L12:;
 
7450
 
 
7451
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
7452
  goto __pyx_L0;
 
7453
  __pyx_L1_error:;
 
7454
  __Pyx_XDECREF(__pyx_t_1);
 
7455
  __Pyx_XDECREF(__pyx_t_3);
 
7456
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSorter._push_node");
 
7457
  __pyx_r = 0;
 
7458
  __pyx_L0:;
 
7459
  __Pyx_DECREF((PyObject *)__pyx_v_parent_node);
 
7460
  __Pyx_DECREF((PyObject *)__pyx_v_ms_node);
 
7461
  __Pyx_DECREF((PyObject *)__pyx_v_ms_parent_node);
 
7462
  __Pyx_XGIVEREF(__pyx_r);
 
7463
  __Pyx_RefNannyFinishContext();
 
7464
  return __pyx_r;
 
7465
}
 
7466
 
 
7467
/* "bzrlib/_known_graph_pyx.pyx":808
 
7468
 *             PyList_Append(self._depth_first_stack, node)
 
7469
 * 
 
7470
 *     cdef _pop_node(self):             # <<<<<<<<<<<<<<
 
7471
 *         cdef PyObject *temp
 
7472
 *         cdef _MergeSortNode ms_node, ms_parent_node, ms_prev_node
 
7473
 */
 
7474
 
 
7475
static  PyObject *__pyx_f_6bzrlib_16_known_graph_pyx_12_MergeSorter__pop_node(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *__pyx_v_self) {
 
7476
  PyObject *__pyx_v_temp;
 
7477
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_node;
 
7478
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_parent_node;
 
7479
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_prev_node;
 
7480
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
7481
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_prev_node;
 
7482
  long __pyx_v_base_revno;
 
7483
  PyObject *__pyx_v_branch_count;
 
7484
  PyObject *__pyx_v_root_count;
 
7485
  PyObject *__pyx_r = NULL;
 
7486
  PyObject *__pyx_t_1 = NULL;
 
7487
  PyObject *__pyx_t_2 = NULL;
 
7488
  int __pyx_t_3;
 
7489
  int __pyx_t_4;
 
7490
  long __pyx_t_5;
 
7491
  PyObject *__pyx_t_6 = NULL;
 
7492
  int __pyx_t_7;
 
7493
  int __pyx_t_8;
 
7494
  __Pyx_RefNannySetupContext("_pop_node");
 
7495
  __pyx_v_ms_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)Py_None); __Pyx_INCREF(Py_None);
 
7496
  __pyx_v_ms_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)Py_None); __Pyx_INCREF(Py_None);
 
7497
  __pyx_v_ms_prev_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)Py_None); __Pyx_INCREF(Py_None);
 
7498
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
7499
  __pyx_v_prev_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
7500
  __pyx_v_branch_count = Py_None; __Pyx_INCREF(Py_None);
 
7501
  __pyx_v_root_count = Py_None; __Pyx_INCREF(Py_None);
 
7502
 
 
7503
  /* "bzrlib/_known_graph_pyx.pyx":813
 
7504
 *         cdef _KnownGraphNode node, parent_node, prev_node
 
7505
 * 
 
7506
 *         node = _get_list_node(self._depth_first_stack, self._last_stack_item)             # <<<<<<<<<<<<<<
 
7507
 *         ms_node = <_MergeSortNode>node.extra
 
7508
 *         self._last_stack_item = self._last_stack_item - 1
 
7509
 */
 
7510
  __pyx_t_1 = __pyx_v_self->_depth_first_stack;
 
7511
  __Pyx_INCREF(__pyx_t_1);
 
7512
  __pyx_t_2 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_t_1, __pyx_v_self->_last_stack_item)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7513
  __Pyx_GOTREF(__pyx_t_2);
 
7514
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
7515
  __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
7516
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_2);
 
7517
  __pyx_t_2 = 0;
 
7518
 
 
7519
  /* "bzrlib/_known_graph_pyx.pyx":814
 
7520
 * 
 
7521
 *         node = _get_list_node(self._depth_first_stack, self._last_stack_item)
 
7522
 *         ms_node = <_MergeSortNode>node.extra             # <<<<<<<<<<<<<<
 
7523
 *         self._last_stack_item = self._last_stack_item - 1
 
7524
 *         if ms_node.left_parent is not None:
 
7525
 */
 
7526
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_node->extra)));
 
7527
  __Pyx_DECREF(((PyObject *)__pyx_v_ms_node));
 
7528
  __pyx_v_ms_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_node->extra);
 
7529
 
 
7530
  /* "bzrlib/_known_graph_pyx.pyx":815
 
7531
 *         node = _get_list_node(self._depth_first_stack, self._last_stack_item)
 
7532
 *         ms_node = <_MergeSortNode>node.extra
 
7533
 *         self._last_stack_item = self._last_stack_item - 1             # <<<<<<<<<<<<<<
 
7534
 *         if ms_node.left_parent is not None:
 
7535
 *             # Assign the revision number from the left-hand parent
 
7536
 */
 
7537
  __pyx_v_self->_last_stack_item = (__pyx_v_self->_last_stack_item - 1);
 
7538
 
 
7539
  /* "bzrlib/_known_graph_pyx.pyx":816
 
7540
 *         ms_node = <_MergeSortNode>node.extra
 
7541
 *         self._last_stack_item = self._last_stack_item - 1
 
7542
 *         if ms_node.left_parent is not None:             # <<<<<<<<<<<<<<
 
7543
 *             # Assign the revision number from the left-hand parent
 
7544
 *             ms_parent_node = <_MergeSortNode>ms_node.left_parent.extra
 
7545
 */
 
7546
  __pyx_t_3 = (((PyObject *)__pyx_v_ms_node->left_parent) != Py_None);
 
7547
  if (__pyx_t_3) {
 
7548
 
 
7549
    /* "bzrlib/_known_graph_pyx.pyx":818
 
7550
 *         if ms_node.left_parent is not None:
 
7551
 *             # Assign the revision number from the left-hand parent
 
7552
 *             ms_parent_node = <_MergeSortNode>ms_node.left_parent.extra             # <<<<<<<<<<<<<<
 
7553
 *             if ms_node.is_first_child:
 
7554
 *                 # First child just increments the final digit
 
7555
 */
 
7556
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_ms_node->left_parent->extra)));
 
7557
    __Pyx_DECREF(((PyObject *)__pyx_v_ms_parent_node));
 
7558
    __pyx_v_ms_parent_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_ms_node->left_parent->extra);
 
7559
 
 
7560
    /* "bzrlib/_known_graph_pyx.pyx":819
 
7561
 *             # Assign the revision number from the left-hand parent
 
7562
 *             ms_parent_node = <_MergeSortNode>ms_node.left_parent.extra
 
7563
 *             if ms_node.is_first_child:             # <<<<<<<<<<<<<<
 
7564
 *                 # First child just increments the final digit
 
7565
 *                 ms_node._revno_first = ms_parent_node._revno_first
 
7566
 */
 
7567
    if (__pyx_v_ms_node->is_first_child) {
 
7568
 
 
7569
      /* "bzrlib/_known_graph_pyx.pyx":821
 
7570
 *             if ms_node.is_first_child:
 
7571
 *                 # First child just increments the final digit
 
7572
 *                 ms_node._revno_first = ms_parent_node._revno_first             # <<<<<<<<<<<<<<
 
7573
 *                 ms_node._revno_second = ms_parent_node._revno_second
 
7574
 *                 ms_node._revno_last = ms_parent_node._revno_last + 1
 
7575
 */
 
7576
      __pyx_v_ms_node->_revno_first = __pyx_v_ms_parent_node->_revno_first;
 
7577
 
 
7578
      /* "bzrlib/_known_graph_pyx.pyx":822
 
7579
 *                 # First child just increments the final digit
 
7580
 *                 ms_node._revno_first = ms_parent_node._revno_first
 
7581
 *                 ms_node._revno_second = ms_parent_node._revno_second             # <<<<<<<<<<<<<<
 
7582
 *                 ms_node._revno_last = ms_parent_node._revno_last + 1
 
7583
 *             else:
 
7584
 */
 
7585
      __pyx_v_ms_node->_revno_second = __pyx_v_ms_parent_node->_revno_second;
 
7586
 
 
7587
      /* "bzrlib/_known_graph_pyx.pyx":823
 
7588
 *                 ms_node._revno_first = ms_parent_node._revno_first
 
7589
 *                 ms_node._revno_second = ms_parent_node._revno_second
 
7590
 *                 ms_node._revno_last = ms_parent_node._revno_last + 1             # <<<<<<<<<<<<<<
 
7591
 *             else:
 
7592
 *                 # Not the first child, make a new branch
 
7593
 */
 
7594
      __pyx_v_ms_node->_revno_last = (__pyx_v_ms_parent_node->_revno_last + 1);
 
7595
      goto __pyx_L4;
 
7596
    }
 
7597
    /*else*/ {
 
7598
 
 
7599
      /* "bzrlib/_known_graph_pyx.pyx":827
 
7600
 *                 # Not the first child, make a new branch
 
7601
 *                 #  (mainline_revno, branch_count, 1)
 
7602
 *                 if ms_parent_node._revno_first == -1:             # <<<<<<<<<<<<<<
 
7603
 *                     # Mainline ancestor, the increment is on the last digit
 
7604
 *                     base_revno = ms_parent_node._revno_last
 
7605
 */
 
7606
      __pyx_t_3 = (__pyx_v_ms_parent_node->_revno_first == -1);
 
7607
      if (__pyx_t_3) {
 
7608
 
 
7609
        /* "bzrlib/_known_graph_pyx.pyx":829
 
7610
 *                 if ms_parent_node._revno_first == -1:
 
7611
 *                     # Mainline ancestor, the increment is on the last digit
 
7612
 *                     base_revno = ms_parent_node._revno_last             # <<<<<<<<<<<<<<
 
7613
 *                 else:
 
7614
 *                     base_revno = ms_parent_node._revno_first
 
7615
 */
 
7616
        __pyx_v_base_revno = __pyx_v_ms_parent_node->_revno_last;
 
7617
        goto __pyx_L5;
 
7618
      }
 
7619
      /*else*/ {
 
7620
 
 
7621
        /* "bzrlib/_known_graph_pyx.pyx":831
 
7622
 *                     base_revno = ms_parent_node._revno_last
 
7623
 *                 else:
 
7624
 *                     base_revno = ms_parent_node._revno_first             # <<<<<<<<<<<<<<
 
7625
 *                 temp = PyDict_GetItem(self._revno_to_branch_count,
 
7626
 *                                       base_revno)
 
7627
 */
 
7628
        __pyx_v_base_revno = __pyx_v_ms_parent_node->_revno_first;
 
7629
      }
 
7630
      __pyx_L5:;
 
7631
 
 
7632
      /* "bzrlib/_known_graph_pyx.pyx":832
 
7633
 *                 else:
 
7634
 *                     base_revno = ms_parent_node._revno_first
 
7635
 *                 temp = PyDict_GetItem(self._revno_to_branch_count,             # <<<<<<<<<<<<<<
 
7636
 *                                       base_revno)
 
7637
 *                 if temp == NULL:
 
7638
 */
 
7639
      __pyx_t_2 = __pyx_v_self->_revno_to_branch_count;
 
7640
      __Pyx_INCREF(__pyx_t_2);
 
7641
 
 
7642
      /* "bzrlib/_known_graph_pyx.pyx":833
 
7643
 *                     base_revno = ms_parent_node._revno_first
 
7644
 *                 temp = PyDict_GetItem(self._revno_to_branch_count,
 
7645
 *                                       base_revno)             # <<<<<<<<<<<<<<
 
7646
 *                 if temp == NULL:
 
7647
 *                     branch_count = 1
 
7648
 */
 
7649
      __pyx_t_1 = PyInt_FromLong(__pyx_v_base_revno); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7650
      __Pyx_GOTREF(__pyx_t_1);
 
7651
      __pyx_v_temp = PyDict_GetItem(__pyx_t_2, __pyx_t_1);
 
7652
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
7653
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
7654
 
 
7655
      /* "bzrlib/_known_graph_pyx.pyx":834
 
7656
 *                 temp = PyDict_GetItem(self._revno_to_branch_count,
 
7657
 *                                       base_revno)
 
7658
 *                 if temp == NULL:             # <<<<<<<<<<<<<<
 
7659
 *                     branch_count = 1
 
7660
 *                 else:
 
7661
 */
 
7662
      __pyx_t_3 = (__pyx_v_temp == NULL);
 
7663
      if (__pyx_t_3) {
 
7664
 
 
7665
        /* "bzrlib/_known_graph_pyx.pyx":835
 
7666
 *                                       base_revno)
 
7667
 *                 if temp == NULL:
 
7668
 *                     branch_count = 1             # <<<<<<<<<<<<<<
 
7669
 *                 else:
 
7670
 *                     branch_count = (<object>temp) + 1
 
7671
 */
 
7672
        __Pyx_INCREF(__pyx_int_1);
 
7673
        __Pyx_DECREF(__pyx_v_branch_count);
 
7674
        __pyx_v_branch_count = __pyx_int_1;
 
7675
        goto __pyx_L6;
 
7676
      }
 
7677
      /*else*/ {
 
7678
 
 
7679
        /* "bzrlib/_known_graph_pyx.pyx":837
 
7680
 *                     branch_count = 1
 
7681
 *                 else:
 
7682
 *                     branch_count = (<object>temp) + 1             # <<<<<<<<<<<<<<
 
7683
 *                 PyDict_SetItem(self._revno_to_branch_count, base_revno,
 
7684
 *                                branch_count)
 
7685
 */
 
7686
        __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_v_temp), __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7687
        __Pyx_GOTREF(__pyx_t_1);
 
7688
        __Pyx_DECREF(__pyx_v_branch_count);
 
7689
        __pyx_v_branch_count = __pyx_t_1;
 
7690
        __pyx_t_1 = 0;
 
7691
      }
 
7692
      __pyx_L6:;
 
7693
 
 
7694
      /* "bzrlib/_known_graph_pyx.pyx":838
 
7695
 *                 else:
 
7696
 *                     branch_count = (<object>temp) + 1
 
7697
 *                 PyDict_SetItem(self._revno_to_branch_count, base_revno,             # <<<<<<<<<<<<<<
 
7698
 *                                branch_count)
 
7699
 *                 ms_node._revno_first = base_revno
 
7700
 */
 
7701
      __pyx_t_1 = __pyx_v_self->_revno_to_branch_count;
 
7702
      __Pyx_INCREF(__pyx_t_1);
 
7703
      __pyx_t_2 = PyInt_FromLong(__pyx_v_base_revno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7704
      __Pyx_GOTREF(__pyx_t_2);
 
7705
 
 
7706
      /* "bzrlib/_known_graph_pyx.pyx":839
 
7707
 *                     branch_count = (<object>temp) + 1
 
7708
 *                 PyDict_SetItem(self._revno_to_branch_count, base_revno,
 
7709
 *                                branch_count)             # <<<<<<<<<<<<<<
 
7710
 *                 ms_node._revno_first = base_revno
 
7711
 *                 ms_node._revno_second = branch_count
 
7712
 */
 
7713
      __pyx_t_4 = PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_v_branch_count); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7714
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
7715
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
7716
 
 
7717
      /* "bzrlib/_known_graph_pyx.pyx":840
 
7718
 *                 PyDict_SetItem(self._revno_to_branch_count, base_revno,
 
7719
 *                                branch_count)
 
7720
 *                 ms_node._revno_first = base_revno             # <<<<<<<<<<<<<<
 
7721
 *                 ms_node._revno_second = branch_count
 
7722
 *                 ms_node._revno_last = 1
 
7723
 */
 
7724
      __pyx_v_ms_node->_revno_first = __pyx_v_base_revno;
 
7725
 
 
7726
      /* "bzrlib/_known_graph_pyx.pyx":841
 
7727
 *                                branch_count)
 
7728
 *                 ms_node._revno_first = base_revno
 
7729
 *                 ms_node._revno_second = branch_count             # <<<<<<<<<<<<<<
 
7730
 *                 ms_node._revno_last = 1
 
7731
 *         else:
 
7732
 */
 
7733
      __pyx_t_5 = __Pyx_PyInt_AsLong(__pyx_v_branch_count); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7734
      __pyx_v_ms_node->_revno_second = __pyx_t_5;
 
7735
 
 
7736
      /* "bzrlib/_known_graph_pyx.pyx":842
 
7737
 *                 ms_node._revno_first = base_revno
 
7738
 *                 ms_node._revno_second = branch_count
 
7739
 *                 ms_node._revno_last = 1             # <<<<<<<<<<<<<<
 
7740
 *         else:
 
7741
 *             temp = PyDict_GetItem(self._revno_to_branch_count, 0)
 
7742
 */
 
7743
      __pyx_v_ms_node->_revno_last = 1;
 
7744
    }
 
7745
    __pyx_L4:;
 
7746
    goto __pyx_L3;
 
7747
  }
 
7748
  /*else*/ {
 
7749
 
 
7750
    /* "bzrlib/_known_graph_pyx.pyx":844
 
7751
 *                 ms_node._revno_last = 1
 
7752
 *         else:
 
7753
 *             temp = PyDict_GetItem(self._revno_to_branch_count, 0)             # <<<<<<<<<<<<<<
 
7754
 *             if temp == NULL:
 
7755
 *                 # The first root node doesn't have a 3-digit revno
 
7756
 */
 
7757
    __pyx_t_2 = __pyx_v_self->_revno_to_branch_count;
 
7758
    __Pyx_INCREF(__pyx_t_2);
 
7759
    __pyx_v_temp = PyDict_GetItem(__pyx_t_2, __pyx_int_0);
 
7760
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
7761
 
 
7762
    /* "bzrlib/_known_graph_pyx.pyx":845
 
7763
 *         else:
 
7764
 *             temp = PyDict_GetItem(self._revno_to_branch_count, 0)
 
7765
 *             if temp == NULL:             # <<<<<<<<<<<<<<
 
7766
 *                 # The first root node doesn't have a 3-digit revno
 
7767
 *                 root_count = 0
 
7768
 */
 
7769
    __pyx_t_3 = (__pyx_v_temp == NULL);
 
7770
    if (__pyx_t_3) {
 
7771
 
 
7772
      /* "bzrlib/_known_graph_pyx.pyx":847
 
7773
 *             if temp == NULL:
 
7774
 *                 # The first root node doesn't have a 3-digit revno
 
7775
 *                 root_count = 0             # <<<<<<<<<<<<<<
 
7776
 *                 ms_node._revno_first = -1
 
7777
 *                 ms_node._revno_second = -1
 
7778
 */
 
7779
      __Pyx_INCREF(__pyx_int_0);
 
7780
      __Pyx_DECREF(__pyx_v_root_count);
 
7781
      __pyx_v_root_count = __pyx_int_0;
 
7782
 
 
7783
      /* "bzrlib/_known_graph_pyx.pyx":848
 
7784
 *                 # The first root node doesn't have a 3-digit revno
 
7785
 *                 root_count = 0
 
7786
 *                 ms_node._revno_first = -1             # <<<<<<<<<<<<<<
 
7787
 *                 ms_node._revno_second = -1
 
7788
 *                 ms_node._revno_last = 1
 
7789
 */
 
7790
      __pyx_v_ms_node->_revno_first = -1;
 
7791
 
 
7792
      /* "bzrlib/_known_graph_pyx.pyx":849
 
7793
 *                 root_count = 0
 
7794
 *                 ms_node._revno_first = -1
 
7795
 *                 ms_node._revno_second = -1             # <<<<<<<<<<<<<<
 
7796
 *                 ms_node._revno_last = 1
 
7797
 *             else:
 
7798
 */
 
7799
      __pyx_v_ms_node->_revno_second = -1;
 
7800
 
 
7801
      /* "bzrlib/_known_graph_pyx.pyx":850
 
7802
 *                 ms_node._revno_first = -1
 
7803
 *                 ms_node._revno_second = -1
 
7804
 *                 ms_node._revno_last = 1             # <<<<<<<<<<<<<<
 
7805
 *             else:
 
7806
 *                 root_count = (<object>temp) + 1
 
7807
 */
 
7808
      __pyx_v_ms_node->_revno_last = 1;
 
7809
      goto __pyx_L7;
 
7810
    }
 
7811
    /*else*/ {
 
7812
 
 
7813
      /* "bzrlib/_known_graph_pyx.pyx":852
 
7814
 *                 ms_node._revno_last = 1
 
7815
 *             else:
 
7816
 *                 root_count = (<object>temp) + 1             # <<<<<<<<<<<<<<
 
7817
 *                 ms_node._revno_first = 0
 
7818
 *                 ms_node._revno_second = root_count
 
7819
 */
 
7820
      __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_temp), __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7821
      __Pyx_GOTREF(__pyx_t_2);
 
7822
      __Pyx_DECREF(__pyx_v_root_count);
 
7823
      __pyx_v_root_count = __pyx_t_2;
 
7824
      __pyx_t_2 = 0;
 
7825
 
 
7826
      /* "bzrlib/_known_graph_pyx.pyx":853
 
7827
 *             else:
 
7828
 *                 root_count = (<object>temp) + 1
 
7829
 *                 ms_node._revno_first = 0             # <<<<<<<<<<<<<<
 
7830
 *                 ms_node._revno_second = root_count
 
7831
 *                 ms_node._revno_last = 1
 
7832
 */
 
7833
      __pyx_v_ms_node->_revno_first = 0;
 
7834
 
 
7835
      /* "bzrlib/_known_graph_pyx.pyx":854
 
7836
 *                 root_count = (<object>temp) + 1
 
7837
 *                 ms_node._revno_first = 0
 
7838
 *                 ms_node._revno_second = root_count             # <<<<<<<<<<<<<<
 
7839
 *                 ms_node._revno_last = 1
 
7840
 *             PyDict_SetItem(self._revno_to_branch_count, 0, root_count)
 
7841
 */
 
7842
      __pyx_t_5 = __Pyx_PyInt_AsLong(__pyx_v_root_count); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7843
      __pyx_v_ms_node->_revno_second = __pyx_t_5;
 
7844
 
 
7845
      /* "bzrlib/_known_graph_pyx.pyx":855
 
7846
 *                 ms_node._revno_first = 0
 
7847
 *                 ms_node._revno_second = root_count
 
7848
 *                 ms_node._revno_last = 1             # <<<<<<<<<<<<<<
 
7849
 *             PyDict_SetItem(self._revno_to_branch_count, 0, root_count)
 
7850
 *         ms_node.completed = 1
 
7851
 */
 
7852
      __pyx_v_ms_node->_revno_last = 1;
 
7853
    }
 
7854
    __pyx_L7:;
 
7855
 
 
7856
    /* "bzrlib/_known_graph_pyx.pyx":856
 
7857
 *                 ms_node._revno_second = root_count
 
7858
 *                 ms_node._revno_last = 1
 
7859
 *             PyDict_SetItem(self._revno_to_branch_count, 0, root_count)             # <<<<<<<<<<<<<<
 
7860
 *         ms_node.completed = 1
 
7861
 *         if PyList_GET_SIZE(self._scheduled_nodes) == 0:
 
7862
 */
 
7863
    __pyx_t_2 = __pyx_v_self->_revno_to_branch_count;
 
7864
    __Pyx_INCREF(__pyx_t_2);
 
7865
    __pyx_t_4 = PyDict_SetItem(__pyx_t_2, __pyx_int_0, __pyx_v_root_count); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7866
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
7867
  }
 
7868
  __pyx_L3:;
 
7869
 
 
7870
  /* "bzrlib/_known_graph_pyx.pyx":857
 
7871
 *                 ms_node._revno_last = 1
 
7872
 *             PyDict_SetItem(self._revno_to_branch_count, 0, root_count)
 
7873
 *         ms_node.completed = 1             # <<<<<<<<<<<<<<
 
7874
 *         if PyList_GET_SIZE(self._scheduled_nodes) == 0:
 
7875
 *             # The first scheduled node is always the end of merge
 
7876
 */
 
7877
  __pyx_v_ms_node->completed = 1;
 
7878
 
 
7879
  /* "bzrlib/_known_graph_pyx.pyx":858
 
7880
 *             PyDict_SetItem(self._revno_to_branch_count, 0, root_count)
 
7881
 *         ms_node.completed = 1
 
7882
 *         if PyList_GET_SIZE(self._scheduled_nodes) == 0:             # <<<<<<<<<<<<<<
 
7883
 *             # The first scheduled node is always the end of merge
 
7884
 *             ms_node.end_of_merge = True
 
7885
 */
 
7886
  __pyx_t_2 = __pyx_v_self->_scheduled_nodes;
 
7887
  __Pyx_INCREF(__pyx_t_2);
 
7888
  __pyx_t_3 = (PyList_GET_SIZE(__pyx_t_2) == 0);
 
7889
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
7890
  if (__pyx_t_3) {
 
7891
 
 
7892
    /* "bzrlib/_known_graph_pyx.pyx":860
 
7893
 *         if PyList_GET_SIZE(self._scheduled_nodes) == 0:
 
7894
 *             # The first scheduled node is always the end of merge
 
7895
 *             ms_node.end_of_merge = True             # <<<<<<<<<<<<<<
 
7896
 *         else:
 
7897
 *             prev_node = _get_list_node(self._scheduled_nodes,
 
7898
 */
 
7899
    __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7900
    __Pyx_GOTREF(__pyx_t_2);
 
7901
    __Pyx_GIVEREF(__pyx_t_2);
 
7902
    __Pyx_GOTREF(__pyx_v_ms_node->end_of_merge);
 
7903
    __Pyx_DECREF(__pyx_v_ms_node->end_of_merge);
 
7904
    __pyx_v_ms_node->end_of_merge = __pyx_t_2;
 
7905
    __pyx_t_2 = 0;
 
7906
    goto __pyx_L8;
 
7907
  }
 
7908
  /*else*/ {
 
7909
 
 
7910
    /* "bzrlib/_known_graph_pyx.pyx":862
 
7911
 *             ms_node.end_of_merge = True
 
7912
 *         else:
 
7913
 *             prev_node = _get_list_node(self._scheduled_nodes,             # <<<<<<<<<<<<<<
 
7914
 *                                     PyList_GET_SIZE(self._scheduled_nodes) - 1)
 
7915
 *             ms_prev_node = <_MergeSortNode>prev_node.extra
 
7916
 */
 
7917
    __pyx_t_2 = __pyx_v_self->_scheduled_nodes;
 
7918
    __Pyx_INCREF(__pyx_t_2);
 
7919
 
 
7920
    /* "bzrlib/_known_graph_pyx.pyx":863
 
7921
 *         else:
 
7922
 *             prev_node = _get_list_node(self._scheduled_nodes,
 
7923
 *                                     PyList_GET_SIZE(self._scheduled_nodes) - 1)             # <<<<<<<<<<<<<<
 
7924
 *             ms_prev_node = <_MergeSortNode>prev_node.extra
 
7925
 *             if ms_prev_node.merge_depth < ms_node.merge_depth:
 
7926
 */
 
7927
    __pyx_t_1 = __pyx_v_self->_scheduled_nodes;
 
7928
    __Pyx_INCREF(__pyx_t_1);
 
7929
    __pyx_t_6 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_t_2, (PyList_GET_SIZE(__pyx_t_1) - 1))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7930
    __Pyx_GOTREF(__pyx_t_6);
 
7931
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
7932
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
7933
    __Pyx_DECREF(((PyObject *)__pyx_v_prev_node));
 
7934
    __pyx_v_prev_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_6);
 
7935
    __pyx_t_6 = 0;
 
7936
 
 
7937
    /* "bzrlib/_known_graph_pyx.pyx":864
 
7938
 *             prev_node = _get_list_node(self._scheduled_nodes,
 
7939
 *                                     PyList_GET_SIZE(self._scheduled_nodes) - 1)
 
7940
 *             ms_prev_node = <_MergeSortNode>prev_node.extra             # <<<<<<<<<<<<<<
 
7941
 *             if ms_prev_node.merge_depth < ms_node.merge_depth:
 
7942
 *                 # The previously pushed node is to our left, so this is the end
 
7943
 */
 
7944
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_prev_node->extra)));
 
7945
    __Pyx_DECREF(((PyObject *)__pyx_v_ms_prev_node));
 
7946
    __pyx_v_ms_prev_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_prev_node->extra);
 
7947
 
 
7948
    /* "bzrlib/_known_graph_pyx.pyx":865
 
7949
 *                                     PyList_GET_SIZE(self._scheduled_nodes) - 1)
 
7950
 *             ms_prev_node = <_MergeSortNode>prev_node.extra
 
7951
 *             if ms_prev_node.merge_depth < ms_node.merge_depth:             # <<<<<<<<<<<<<<
 
7952
 *                 # The previously pushed node is to our left, so this is the end
 
7953
 *                 # of this right-hand chain
 
7954
 */
 
7955
    __pyx_t_3 = (__pyx_v_ms_prev_node->merge_depth < __pyx_v_ms_node->merge_depth);
 
7956
    if (__pyx_t_3) {
 
7957
 
 
7958
      /* "bzrlib/_known_graph_pyx.pyx":868
 
7959
 *                 # The previously pushed node is to our left, so this is the end
 
7960
 *                 # of this right-hand chain
 
7961
 *                 ms_node.end_of_merge = True             # <<<<<<<<<<<<<<
 
7962
 *             elif (ms_prev_node.merge_depth == ms_node.merge_depth
 
7963
 *                   and prev_node not in node.parents):
 
7964
 */
 
7965
      __pyx_t_6 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7966
      __Pyx_GOTREF(__pyx_t_6);
 
7967
      __Pyx_GIVEREF(__pyx_t_6);
 
7968
      __Pyx_GOTREF(__pyx_v_ms_node->end_of_merge);
 
7969
      __Pyx_DECREF(__pyx_v_ms_node->end_of_merge);
 
7970
      __pyx_v_ms_node->end_of_merge = __pyx_t_6;
 
7971
      __pyx_t_6 = 0;
 
7972
      goto __pyx_L9;
 
7973
    }
 
7974
 
 
7975
    /* "bzrlib/_known_graph_pyx.pyx":869
 
7976
 *                 # of this right-hand chain
 
7977
 *                 ms_node.end_of_merge = True
 
7978
 *             elif (ms_prev_node.merge_depth == ms_node.merge_depth             # <<<<<<<<<<<<<<
 
7979
 *                   and prev_node not in node.parents):
 
7980
 *                 # The next node is not a direct parent of this node
 
7981
 */
 
7982
    __pyx_t_3 = (__pyx_v_ms_prev_node->merge_depth == __pyx_v_ms_node->merge_depth);
 
7983
    if (__pyx_t_3) {
 
7984
 
 
7985
      /* "bzrlib/_known_graph_pyx.pyx":870
 
7986
 *                 ms_node.end_of_merge = True
 
7987
 *             elif (ms_prev_node.merge_depth == ms_node.merge_depth
 
7988
 *                   and prev_node not in node.parents):             # <<<<<<<<<<<<<<
 
7989
 *                 # The next node is not a direct parent of this node
 
7990
 *                 ms_node.end_of_merge = True
 
7991
 */
 
7992
      __pyx_t_7 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_v_node->parents, ((PyObject *)__pyx_v_prev_node)))); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
7993
      __pyx_t_8 = __pyx_t_7;
 
7994
    } else {
 
7995
      __pyx_t_8 = __pyx_t_3;
 
7996
    }
 
7997
    if (__pyx_t_8) {
 
7998
 
 
7999
      /* "bzrlib/_known_graph_pyx.pyx":872
 
8000
 *                   and prev_node not in node.parents):
 
8001
 *                 # The next node is not a direct parent of this node
 
8002
 *                 ms_node.end_of_merge = True             # <<<<<<<<<<<<<<
 
8003
 *             else:
 
8004
 *                 ms_node.end_of_merge = False
 
8005
 */
 
8006
      __pyx_t_6 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8007
      __Pyx_GOTREF(__pyx_t_6);
 
8008
      __Pyx_GIVEREF(__pyx_t_6);
 
8009
      __Pyx_GOTREF(__pyx_v_ms_node->end_of_merge);
 
8010
      __Pyx_DECREF(__pyx_v_ms_node->end_of_merge);
 
8011
      __pyx_v_ms_node->end_of_merge = __pyx_t_6;
 
8012
      __pyx_t_6 = 0;
 
8013
      goto __pyx_L9;
 
8014
    }
 
8015
    /*else*/ {
 
8016
 
 
8017
      /* "bzrlib/_known_graph_pyx.pyx":874
 
8018
 *                 ms_node.end_of_merge = True
 
8019
 *             else:
 
8020
 *                 ms_node.end_of_merge = False             # <<<<<<<<<<<<<<
 
8021
 *         PyList_Append(self._scheduled_nodes, node)
 
8022
 * 
 
8023
 */
 
8024
      __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8025
      __Pyx_GOTREF(__pyx_t_6);
 
8026
      __Pyx_GIVEREF(__pyx_t_6);
 
8027
      __Pyx_GOTREF(__pyx_v_ms_node->end_of_merge);
 
8028
      __Pyx_DECREF(__pyx_v_ms_node->end_of_merge);
 
8029
      __pyx_v_ms_node->end_of_merge = __pyx_t_6;
 
8030
      __pyx_t_6 = 0;
 
8031
    }
 
8032
    __pyx_L9:;
 
8033
  }
 
8034
  __pyx_L8:;
 
8035
 
 
8036
  /* "bzrlib/_known_graph_pyx.pyx":875
 
8037
 *             else:
 
8038
 *                 ms_node.end_of_merge = False
 
8039
 *         PyList_Append(self._scheduled_nodes, node)             # <<<<<<<<<<<<<<
 
8040
 * 
 
8041
 *     cdef _schedule_stack(self):
 
8042
 */
 
8043
  __pyx_t_6 = __pyx_v_self->_scheduled_nodes;
 
8044
  __Pyx_INCREF(__pyx_t_6);
 
8045
  __pyx_t_4 = PyList_Append(__pyx_t_6, ((PyObject *)__pyx_v_node)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8046
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
8047
 
 
8048
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
8049
  goto __pyx_L0;
 
8050
  __pyx_L1_error:;
 
8051
  __Pyx_XDECREF(__pyx_t_1);
 
8052
  __Pyx_XDECREF(__pyx_t_2);
 
8053
  __Pyx_XDECREF(__pyx_t_6);
 
8054
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSorter._pop_node");
 
8055
  __pyx_r = 0;
 
8056
  __pyx_L0:;
 
8057
  __Pyx_DECREF((PyObject *)__pyx_v_ms_node);
 
8058
  __Pyx_DECREF((PyObject *)__pyx_v_ms_parent_node);
 
8059
  __Pyx_DECREF((PyObject *)__pyx_v_ms_prev_node);
 
8060
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
8061
  __Pyx_DECREF((PyObject *)__pyx_v_prev_node);
 
8062
  __Pyx_DECREF(__pyx_v_branch_count);
 
8063
  __Pyx_DECREF(__pyx_v_root_count);
 
8064
  __Pyx_XGIVEREF(__pyx_r);
 
8065
  __Pyx_RefNannyFinishContext();
 
8066
  return __pyx_r;
 
8067
}
 
8068
 
 
8069
/* "bzrlib/_known_graph_pyx.pyx":877
 
8070
 *         PyList_Append(self._scheduled_nodes, node)
 
8071
 * 
 
8072
 *     cdef _schedule_stack(self):             # <<<<<<<<<<<<<<
 
8073
 *         cdef _KnownGraphNode last_node, next_node
 
8074
 *         cdef _MergeSortNode ms_node, ms_last_node, ms_next_node
 
8075
 */
 
8076
 
 
8077
static  PyObject *__pyx_f_6bzrlib_16_known_graph_pyx_12_MergeSorter__schedule_stack(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *__pyx_v_self) {
 
8078
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_last_node;
 
8079
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_next_node;
 
8080
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_last_node;
 
8081
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_next_node;
 
8082
  long __pyx_v_next_merge_depth;
 
8083
  PyObject *__pyx_v_ordered;
 
8084
  PyObject *__pyx_r = NULL;
 
8085
  PyObject *__pyx_t_1 = NULL;
 
8086
  int __pyx_t_2;
 
8087
  PyObject *__pyx_t_3 = NULL;
 
8088
  PyObject *__pyx_t_4 = NULL;
 
8089
  int __pyx_t_5;
 
8090
  __Pyx_RefNannySetupContext("_schedule_stack");
 
8091
  __pyx_v_last_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
8092
  __pyx_v_next_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
8093
  __pyx_v_ms_last_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)Py_None); __Pyx_INCREF(Py_None);
 
8094
  __pyx_v_ms_next_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)Py_None); __Pyx_INCREF(Py_None);
 
8095
  __pyx_v_ordered = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
8096
 
 
8097
  /* "bzrlib/_known_graph_pyx.pyx":881
 
8098
 *         cdef _MergeSortNode ms_node, ms_last_node, ms_next_node
 
8099
 *         cdef long next_merge_depth
 
8100
 *         ordered = []             # <<<<<<<<<<<<<<
 
8101
 *         while self._last_stack_item >= 0:
 
8102
 *             # Peek at the last item on the stack
 
8103
 */
 
8104
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8105
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
8106
  __Pyx_DECREF(((PyObject *)__pyx_v_ordered));
 
8107
  __pyx_v_ordered = __pyx_t_1;
 
8108
  __pyx_t_1 = 0;
 
8109
 
 
8110
  /* "bzrlib/_known_graph_pyx.pyx":882
 
8111
 *         cdef long next_merge_depth
 
8112
 *         ordered = []
 
8113
 *         while self._last_stack_item >= 0:             # <<<<<<<<<<<<<<
 
8114
 *             # Peek at the last item on the stack
 
8115
 *             last_node = _get_list_node(self._depth_first_stack,
 
8116
 */
 
8117
  while (1) {
 
8118
    __pyx_t_2 = (__pyx_v_self->_last_stack_item >= 0);
 
8119
    if (!__pyx_t_2) break;
 
8120
 
 
8121
    /* "bzrlib/_known_graph_pyx.pyx":884
 
8122
 *         while self._last_stack_item >= 0:
 
8123
 *             # Peek at the last item on the stack
 
8124
 *             last_node = _get_list_node(self._depth_first_stack,             # <<<<<<<<<<<<<<
 
8125
 *                                        self._last_stack_item)
 
8126
 *             if last_node.gdfo == -1:
 
8127
 */
 
8128
    __pyx_t_1 = __pyx_v_self->_depth_first_stack;
 
8129
    __Pyx_INCREF(__pyx_t_1);
 
8130
 
 
8131
    /* "bzrlib/_known_graph_pyx.pyx":885
 
8132
 *             # Peek at the last item on the stack
 
8133
 *             last_node = _get_list_node(self._depth_first_stack,
 
8134
 *                                        self._last_stack_item)             # <<<<<<<<<<<<<<
 
8135
 *             if last_node.gdfo == -1:
 
8136
 *                 # if _find_gdfo skipped a node, that means there is a graph
 
8137
 */
 
8138
    __pyx_t_3 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_t_1, __pyx_v_self->_last_stack_item)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8139
    __Pyx_GOTREF(__pyx_t_3);
 
8140
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
8141
    __Pyx_DECREF(((PyObject *)__pyx_v_last_node));
 
8142
    __pyx_v_last_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
 
8143
    __pyx_t_3 = 0;
 
8144
 
 
8145
    /* "bzrlib/_known_graph_pyx.pyx":886
 
8146
 *             last_node = _get_list_node(self._depth_first_stack,
 
8147
 *                                        self._last_stack_item)
 
8148
 *             if last_node.gdfo == -1:             # <<<<<<<<<<<<<<
 
8149
 *                 # if _find_gdfo skipped a node, that means there is a graph
 
8150
 *                 # cycle, error out now
 
8151
 */
 
8152
    __pyx_t_2 = (__pyx_v_last_node->gdfo == -1);
 
8153
    if (__pyx_t_2) {
 
8154
 
 
8155
      /* "bzrlib/_known_graph_pyx.pyx":889
 
8156
 *                 # if _find_gdfo skipped a node, that means there is a graph
 
8157
 *                 # cycle, error out now
 
8158
 *                 raise errors.GraphCycleError(self.graph._nodes)             # <<<<<<<<<<<<<<
 
8159
 *             ms_last_node = <_MergeSortNode>last_node.extra
 
8160
 *             if not ms_last_node.has_pending_parents():
 
8161
 */
 
8162
      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__errors); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8163
      __Pyx_GOTREF(__pyx_t_3);
 
8164
      __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__GraphCycleError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8165
      __Pyx_GOTREF(__pyx_t_1);
 
8166
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
8167
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8168
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
8169
      __Pyx_INCREF(__pyx_v_self->graph->_nodes);
 
8170
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->graph->_nodes);
 
8171
      __Pyx_GIVEREF(__pyx_v_self->graph->_nodes);
 
8172
      __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8173
      __Pyx_GOTREF(__pyx_t_4);
 
8174
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
8175
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
8176
      __Pyx_Raise(__pyx_t_4, 0, 0);
 
8177
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
8178
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8179
      goto __pyx_L5;
 
8180
    }
 
8181
    __pyx_L5:;
 
8182
 
 
8183
    /* "bzrlib/_known_graph_pyx.pyx":890
 
8184
 *                 # cycle, error out now
 
8185
 *                 raise errors.GraphCycleError(self.graph._nodes)
 
8186
 *             ms_last_node = <_MergeSortNode>last_node.extra             # <<<<<<<<<<<<<<
 
8187
 *             if not ms_last_node.has_pending_parents():
 
8188
 *                 # Processed all parents, pop this node
 
8189
 */
 
8190
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_last_node->extra)));
 
8191
    __Pyx_DECREF(((PyObject *)__pyx_v_ms_last_node));
 
8192
    __pyx_v_ms_last_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_last_node->extra);
 
8193
 
 
8194
    /* "bzrlib/_known_graph_pyx.pyx":891
 
8195
 *                 raise errors.GraphCycleError(self.graph._nodes)
 
8196
 *             ms_last_node = <_MergeSortNode>last_node.extra
 
8197
 *             if not ms_last_node.has_pending_parents():             # <<<<<<<<<<<<<<
 
8198
 *                 # Processed all parents, pop this node
 
8199
 *                 self._pop_node()
 
8200
 */
 
8201
    __pyx_t_2 = (!((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_ms_last_node->__pyx_vtab)->has_pending_parents(__pyx_v_ms_last_node));
 
8202
    if (__pyx_t_2) {
 
8203
 
 
8204
      /* "bzrlib/_known_graph_pyx.pyx":893
 
8205
 *             if not ms_last_node.has_pending_parents():
 
8206
 *                 # Processed all parents, pop this node
 
8207
 *                 self._pop_node()             # <<<<<<<<<<<<<<
 
8208
 *                 continue
 
8209
 *             while ms_last_node.has_pending_parents():
 
8210
 */
 
8211
      __pyx_t_4 = ((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_pop_node(__pyx_v_self); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8212
      __Pyx_GOTREF(__pyx_t_4);
 
8213
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
8214
 
 
8215
      /* "bzrlib/_known_graph_pyx.pyx":894
 
8216
 *                 # Processed all parents, pop this node
 
8217
 *                 self._pop_node()
 
8218
 *                 continue             # <<<<<<<<<<<<<<
 
8219
 *             while ms_last_node.has_pending_parents():
 
8220
 *                 if ms_last_node.left_pending_parent is not None:
 
8221
 */
 
8222
      goto __pyx_L3_continue;
 
8223
      goto __pyx_L6;
 
8224
    }
 
8225
    __pyx_L6:;
 
8226
 
 
8227
    /* "bzrlib/_known_graph_pyx.pyx":895
 
8228
 *                 self._pop_node()
 
8229
 *                 continue
 
8230
 *             while ms_last_node.has_pending_parents():             # <<<<<<<<<<<<<<
 
8231
 *                 if ms_last_node.left_pending_parent is not None:
 
8232
 *                     # recurse depth first into the primary parent
 
8233
 */
 
8234
    while (1) {
 
8235
      __pyx_t_5 = ((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_ms_last_node->__pyx_vtab)->has_pending_parents(__pyx_v_ms_last_node);
 
8236
      if (!__pyx_t_5) break;
 
8237
 
 
8238
      /* "bzrlib/_known_graph_pyx.pyx":896
 
8239
 *                 continue
 
8240
 *             while ms_last_node.has_pending_parents():
 
8241
 *                 if ms_last_node.left_pending_parent is not None:             # <<<<<<<<<<<<<<
 
8242
 *                     # recurse depth first into the primary parent
 
8243
 *                     next_node = ms_last_node.left_pending_parent
 
8244
 */
 
8245
      __pyx_t_2 = (((PyObject *)__pyx_v_ms_last_node->left_pending_parent) != Py_None);
 
8246
      if (__pyx_t_2) {
 
8247
 
 
8248
        /* "bzrlib/_known_graph_pyx.pyx":898
 
8249
 *                 if ms_last_node.left_pending_parent is not None:
 
8250
 *                     # recurse depth first into the primary parent
 
8251
 *                     next_node = ms_last_node.left_pending_parent             # <<<<<<<<<<<<<<
 
8252
 *                     ms_last_node.left_pending_parent = None
 
8253
 *                 else:
 
8254
 */
 
8255
        __Pyx_INCREF(((PyObject *)__pyx_v_ms_last_node->left_pending_parent));
 
8256
        __Pyx_DECREF(((PyObject *)__pyx_v_next_node));
 
8257
        __pyx_v_next_node = __pyx_v_ms_last_node->left_pending_parent;
 
8258
 
 
8259
        /* "bzrlib/_known_graph_pyx.pyx":899
 
8260
 *                     # recurse depth first into the primary parent
 
8261
 *                     next_node = ms_last_node.left_pending_parent
 
8262
 *                     ms_last_node.left_pending_parent = None             # <<<<<<<<<<<<<<
 
8263
 *                 else:
 
8264
 *                     # place any merges in right-to-left order for scheduling
 
8265
 */
 
8266
        __Pyx_INCREF(Py_None);
 
8267
        __Pyx_GIVEREF(Py_None);
 
8268
        __Pyx_GOTREF(__pyx_v_ms_last_node->left_pending_parent);
 
8269
        __Pyx_DECREF(((PyObject *)__pyx_v_ms_last_node->left_pending_parent));
 
8270
        __pyx_v_ms_last_node->left_pending_parent = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None);
 
8271
        goto __pyx_L9;
 
8272
      }
 
8273
      /*else*/ {
 
8274
 
 
8275
        /* "bzrlib/_known_graph_pyx.pyx":908
 
8276
 *                     #       left most, which will display nicely (you get
 
8277
 *                     #       smaller trees at the top of the combined merge).
 
8278
 *                     next_node = ms_last_node.pending_parents.pop()             # <<<<<<<<<<<<<<
 
8279
 *                 ms_next_node = self._get_ms_node(next_node)
 
8280
 *                 if ms_next_node.completed:
 
8281
 */
 
8282
        __pyx_t_4 = __Pyx_PyObject_Pop(__pyx_v_ms_last_node->pending_parents); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8283
        __Pyx_GOTREF(__pyx_t_4);
 
8284
        if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8285
        __Pyx_DECREF(((PyObject *)__pyx_v_next_node));
 
8286
        __pyx_v_next_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_4);
 
8287
        __pyx_t_4 = 0;
 
8288
      }
 
8289
      __pyx_L9:;
 
8290
 
 
8291
      /* "bzrlib/_known_graph_pyx.pyx":909
 
8292
 *                     #       smaller trees at the top of the combined merge).
 
8293
 *                     next_node = ms_last_node.pending_parents.pop()
 
8294
 *                 ms_next_node = self._get_ms_node(next_node)             # <<<<<<<<<<<<<<
 
8295
 *                 if ms_next_node.completed:
 
8296
 *                     # this parent was completed by a child on the
 
8297
 */
 
8298
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_get_ms_node(__pyx_v_self, __pyx_v_next_node)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8299
      __Pyx_GOTREF(__pyx_t_4);
 
8300
      __Pyx_DECREF(((PyObject *)__pyx_v_ms_next_node));
 
8301
      __pyx_v_ms_next_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_t_4);
 
8302
      __pyx_t_4 = 0;
 
8303
 
 
8304
      /* "bzrlib/_known_graph_pyx.pyx":910
 
8305
 *                     next_node = ms_last_node.pending_parents.pop()
 
8306
 *                 ms_next_node = self._get_ms_node(next_node)
 
8307
 *                 if ms_next_node.completed:             # <<<<<<<<<<<<<<
 
8308
 *                     # this parent was completed by a child on the
 
8309
 *                     # call stack. skip it.
 
8310
 */
 
8311
      if (__pyx_v_ms_next_node->completed) {
 
8312
 
 
8313
        /* "bzrlib/_known_graph_pyx.pyx":913
 
8314
 *                     # this parent was completed by a child on the
 
8315
 *                     # call stack. skip it.
 
8316
 *                     continue             # <<<<<<<<<<<<<<
 
8317
 *                 # otherwise transfer it from the source graph into the
 
8318
 *                 # top of the current depth first search stack.
 
8319
 */
 
8320
        goto __pyx_L7_continue;
 
8321
        goto __pyx_L10;
 
8322
      }
 
8323
      __pyx_L10:;
 
8324
 
 
8325
      /* "bzrlib/_known_graph_pyx.pyx":917
 
8326
 *                 # top of the current depth first search stack.
 
8327
 * 
 
8328
 *                 if next_node is ms_last_node.left_parent:             # <<<<<<<<<<<<<<
 
8329
 *                     next_merge_depth = ms_last_node.merge_depth
 
8330
 *                 else:
 
8331
 */
 
8332
      __pyx_t_2 = (__pyx_v_next_node == __pyx_v_ms_last_node->left_parent);
 
8333
      if (__pyx_t_2) {
 
8334
 
 
8335
        /* "bzrlib/_known_graph_pyx.pyx":918
 
8336
 * 
 
8337
 *                 if next_node is ms_last_node.left_parent:
 
8338
 *                     next_merge_depth = ms_last_node.merge_depth             # <<<<<<<<<<<<<<
 
8339
 *                 else:
 
8340
 *                     next_merge_depth = ms_last_node.merge_depth + 1
 
8341
 */
 
8342
        __pyx_v_next_merge_depth = __pyx_v_ms_last_node->merge_depth;
 
8343
        goto __pyx_L11;
 
8344
      }
 
8345
      /*else*/ {
 
8346
 
 
8347
        /* "bzrlib/_known_graph_pyx.pyx":920
 
8348
 *                     next_merge_depth = ms_last_node.merge_depth
 
8349
 *                 else:
 
8350
 *                     next_merge_depth = ms_last_node.merge_depth + 1             # <<<<<<<<<<<<<<
 
8351
 *                 self._push_node(next_node, next_merge_depth)
 
8352
 *                 # and do not continue processing parents until this 'call'
 
8353
 */
 
8354
        __pyx_v_next_merge_depth = (__pyx_v_ms_last_node->merge_depth + 1);
 
8355
      }
 
8356
      __pyx_L11:;
 
8357
 
 
8358
      /* "bzrlib/_known_graph_pyx.pyx":921
 
8359
 *                 else:
 
8360
 *                     next_merge_depth = ms_last_node.merge_depth + 1
 
8361
 *                 self._push_node(next_node, next_merge_depth)             # <<<<<<<<<<<<<<
 
8362
 *                 # and do not continue processing parents until this 'call'
 
8363
 *                 # has recursed.
 
8364
 */
 
8365
      __pyx_t_4 = ((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_push_node(__pyx_v_self, __pyx_v_next_node, __pyx_v_next_merge_depth); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8366
      __Pyx_GOTREF(__pyx_t_4);
 
8367
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
8368
 
 
8369
      /* "bzrlib/_known_graph_pyx.pyx":924
 
8370
 *                 # and do not continue processing parents until this 'call'
 
8371
 *                 # has recursed.
 
8372
 *                 break             # <<<<<<<<<<<<<<
 
8373
 * 
 
8374
 *     cdef topo_order(self):
 
8375
 */
 
8376
      goto __pyx_L8_break;
 
8377
      __pyx_L7_continue:;
 
8378
    }
 
8379
    __pyx_L8_break:;
 
8380
    __pyx_L3_continue:;
 
8381
  }
 
8382
 
 
8383
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
8384
  goto __pyx_L0;
 
8385
  __pyx_L1_error:;
 
8386
  __Pyx_XDECREF(__pyx_t_1);
 
8387
  __Pyx_XDECREF(__pyx_t_3);
 
8388
  __Pyx_XDECREF(__pyx_t_4);
 
8389
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSorter._schedule_stack");
 
8390
  __pyx_r = 0;
 
8391
  __pyx_L0:;
 
8392
  __Pyx_DECREF((PyObject *)__pyx_v_last_node);
 
8393
  __Pyx_DECREF((PyObject *)__pyx_v_next_node);
 
8394
  __Pyx_DECREF((PyObject *)__pyx_v_ms_last_node);
 
8395
  __Pyx_DECREF((PyObject *)__pyx_v_ms_next_node);
 
8396
  __Pyx_DECREF(__pyx_v_ordered);
 
8397
  __Pyx_XGIVEREF(__pyx_r);
 
8398
  __Pyx_RefNannyFinishContext();
 
8399
  return __pyx_r;
 
8400
}
 
8401
 
 
8402
/* "bzrlib/_known_graph_pyx.pyx":926
 
8403
 *                 break
 
8404
 * 
 
8405
 *     cdef topo_order(self):             # <<<<<<<<<<<<<<
 
8406
 *         cdef _MergeSortNode ms_node
 
8407
 *         cdef _KnownGraphNode node
 
8408
 */
 
8409
 
 
8410
static  PyObject *__pyx_f_6bzrlib_16_known_graph_pyx_12_MergeSorter_topo_order(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *__pyx_v_self) {
 
8411
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *__pyx_v_ms_node;
 
8412
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *__pyx_v_node;
 
8413
  Py_ssize_t __pyx_v_pos;
 
8414
  PyObject *__pyx_v_ordered;
 
8415
  PyObject *__pyx_r = NULL;
 
8416
  PyObject *__pyx_t_1 = NULL;
 
8417
  PyObject *__pyx_t_2 = NULL;
 
8418
  PyObject *__pyx_t_3 = NULL;
 
8419
  int __pyx_t_4;
 
8420
  __Pyx_RefNannySetupContext("topo_order");
 
8421
  __pyx_v_ms_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)Py_None); __Pyx_INCREF(Py_None);
 
8422
  __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); __Pyx_INCREF(Py_None);
 
8423
  __pyx_v_ordered = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
 
8424
 
 
8425
  /* "bzrlib/_known_graph_pyx.pyx":936
 
8426
 *         #       We might consider moving the attributes into the base
 
8427
 *         #       KnownGraph object.
 
8428
 *         self._schedule_stack()             # <<<<<<<<<<<<<<
 
8429
 * 
 
8430
 *         # We've set up the basic schedule, now we can continue processing the
 
8431
 */
 
8432
  __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter *)__pyx_v_self->__pyx_vtab)->_schedule_stack(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8433
  __Pyx_GOTREF(__pyx_t_1);
 
8434
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
8435
 
 
8436
  /* "bzrlib/_known_graph_pyx.pyx":946
 
8437
 *         #       7ms is computing the return tuple
 
8438
 *         #       4ms is PyList_Append()
 
8439
 *         ordered = []             # <<<<<<<<<<<<<<
 
8440
 *         # output the result in reverse order, and separate the generated info
 
8441
 *         for pos from PyList_GET_SIZE(self._scheduled_nodes) > pos >= 0:
 
8442
 */
 
8443
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8444
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
8445
  __Pyx_DECREF(((PyObject *)__pyx_v_ordered));
 
8446
  __pyx_v_ordered = __pyx_t_1;
 
8447
  __pyx_t_1 = 0;
 
8448
 
 
8449
  /* "bzrlib/_known_graph_pyx.pyx":948
 
8450
 *         ordered = []
 
8451
 *         # output the result in reverse order, and separate the generated info
 
8452
 *         for pos from PyList_GET_SIZE(self._scheduled_nodes) > pos >= 0:             # <<<<<<<<<<<<<<
 
8453
 *             node = _get_list_node(self._scheduled_nodes, pos)
 
8454
 *             ms_node = <_MergeSortNode>node.extra
 
8455
 */
 
8456
  __pyx_t_1 = __pyx_v_self->_scheduled_nodes;
 
8457
  __Pyx_INCREF(__pyx_t_1);
 
8458
  for (__pyx_v_pos = PyList_GET_SIZE(__pyx_t_1)-1; __pyx_v_pos >= 0; __pyx_v_pos--) {
 
8459
 
 
8460
    /* "bzrlib/_known_graph_pyx.pyx":949
 
8461
 *         # output the result in reverse order, and separate the generated info
 
8462
 *         for pos from PyList_GET_SIZE(self._scheduled_nodes) > pos >= 0:
 
8463
 *             node = _get_list_node(self._scheduled_nodes, pos)             # <<<<<<<<<<<<<<
 
8464
 *             ms_node = <_MergeSortNode>node.extra
 
8465
 *             PyList_Append(ordered, ms_node)
 
8466
 */
 
8467
    __pyx_t_2 = __pyx_v_self->_scheduled_nodes;
 
8468
    __Pyx_INCREF(__pyx_t_2);
 
8469
    __pyx_t_3 = ((PyObject *)__pyx_f_6bzrlib_16_known_graph_pyx__get_list_node(__pyx_t_2, __pyx_v_pos)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8470
    __Pyx_GOTREF(__pyx_t_3);
 
8471
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
8472
    __Pyx_DECREF(((PyObject *)__pyx_v_node));
 
8473
    __pyx_v_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)__pyx_t_3);
 
8474
    __pyx_t_3 = 0;
 
8475
 
 
8476
    /* "bzrlib/_known_graph_pyx.pyx":950
 
8477
 *         for pos from PyList_GET_SIZE(self._scheduled_nodes) > pos >= 0:
 
8478
 *             node = _get_list_node(self._scheduled_nodes, pos)
 
8479
 *             ms_node = <_MergeSortNode>node.extra             # <<<<<<<<<<<<<<
 
8480
 *             PyList_Append(ordered, ms_node)
 
8481
 *             node.extra = None
 
8482
 */
 
8483
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_node->extra)));
 
8484
    __Pyx_DECREF(((PyObject *)__pyx_v_ms_node));
 
8485
    __pyx_v_ms_node = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)__pyx_v_node->extra);
 
8486
 
 
8487
    /* "bzrlib/_known_graph_pyx.pyx":951
 
8488
 *             node = _get_list_node(self._scheduled_nodes, pos)
 
8489
 *             ms_node = <_MergeSortNode>node.extra
 
8490
 *             PyList_Append(ordered, ms_node)             # <<<<<<<<<<<<<<
 
8491
 *             node.extra = None
 
8492
 *         # Clear out the scheduled nodes now that we're done
 
8493
 */
 
8494
    __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_ordered), ((PyObject *)__pyx_v_ms_node)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8495
 
 
8496
    /* "bzrlib/_known_graph_pyx.pyx":952
 
8497
 *             ms_node = <_MergeSortNode>node.extra
 
8498
 *             PyList_Append(ordered, ms_node)
 
8499
 *             node.extra = None             # <<<<<<<<<<<<<<
 
8500
 *         # Clear out the scheduled nodes now that we're done
 
8501
 *         self._scheduled_nodes = []
 
8502
 */
 
8503
    __Pyx_INCREF(Py_None);
 
8504
    __Pyx_GIVEREF(Py_None);
 
8505
    __Pyx_GOTREF(__pyx_v_node->extra);
 
8506
    __Pyx_DECREF(__pyx_v_node->extra);
 
8507
    __pyx_v_node->extra = Py_None;
 
8508
  }
 
8509
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
8510
 
 
8511
  /* "bzrlib/_known_graph_pyx.pyx":954
 
8512
 *             node.extra = None
 
8513
 *         # Clear out the scheduled nodes now that we're done
 
8514
 *         self._scheduled_nodes = []             # <<<<<<<<<<<<<<
 
8515
 *         return ordered
 
8516
 */
 
8517
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
8518
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
8519
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
 
8520
  __Pyx_GOTREF(__pyx_v_self->_scheduled_nodes);
 
8521
  __Pyx_DECREF(__pyx_v_self->_scheduled_nodes);
 
8522
  __pyx_v_self->_scheduled_nodes = ((PyObject *)__pyx_t_1);
 
8523
  __pyx_t_1 = 0;
 
8524
 
 
8525
  /* "bzrlib/_known_graph_pyx.pyx":955
 
8526
 *         # Clear out the scheduled nodes now that we're done
 
8527
 *         self._scheduled_nodes = []
 
8528
 *         return ordered             # <<<<<<<<<<<<<<
 
8529
 */
 
8530
  __Pyx_XDECREF(__pyx_r);
 
8531
  __Pyx_INCREF(((PyObject *)__pyx_v_ordered));
 
8532
  __pyx_r = ((PyObject *)__pyx_v_ordered);
 
8533
  goto __pyx_L0;
 
8534
 
 
8535
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
8536
  goto __pyx_L0;
 
8537
  __pyx_L1_error:;
 
8538
  __Pyx_XDECREF(__pyx_t_1);
 
8539
  __Pyx_XDECREF(__pyx_t_2);
 
8540
  __Pyx_XDECREF(__pyx_t_3);
 
8541
  __Pyx_AddTraceback("bzrlib._known_graph_pyx._MergeSorter.topo_order");
 
8542
  __pyx_r = 0;
 
8543
  __pyx_L0:;
 
8544
  __Pyx_DECREF((PyObject *)__pyx_v_ms_node);
 
8545
  __Pyx_DECREF((PyObject *)__pyx_v_node);
 
8546
  __Pyx_DECREF(__pyx_v_ordered);
 
8547
  __Pyx_XGIVEREF(__pyx_r);
 
8548
  __Pyx_RefNannyFinishContext();
 
8549
  return __pyx_r;
 
8550
}
 
8551
static struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__KnownGraphNode __pyx_vtable_6bzrlib_16_known_graph_pyx__KnownGraphNode;
 
8552
 
 
8553
static PyObject *__pyx_tp_new_6bzrlib_16_known_graph_pyx__KnownGraphNode(PyTypeObject *t, PyObject *a, PyObject *k) {
 
8554
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *p;
 
8555
  PyObject *o = (*t->tp_alloc)(t, 0);
 
8556
  if (!o) return 0;
 
8557
  p = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)o);
 
8558
  p->__pyx_vtab = __pyx_vtabptr_6bzrlib_16_known_graph_pyx__KnownGraphNode;
 
8559
  p->key = Py_None; Py_INCREF(Py_None);
 
8560
  p->parents = Py_None; Py_INCREF(Py_None);
 
8561
  p->children = Py_None; Py_INCREF(Py_None);
 
8562
  p->extra = Py_None; Py_INCREF(Py_None);
 
8563
  return o;
 
8564
}
 
8565
 
 
8566
static void __pyx_tp_dealloc_6bzrlib_16_known_graph_pyx__KnownGraphNode(PyObject *o) {
 
8567
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)o;
 
8568
  Py_XDECREF(p->key);
 
8569
  Py_XDECREF(p->parents);
 
8570
  Py_XDECREF(p->children);
 
8571
  Py_XDECREF(p->extra);
 
8572
  (*Py_TYPE(o)->tp_free)(o);
 
8573
}
 
8574
 
 
8575
static int __pyx_tp_traverse_6bzrlib_16_known_graph_pyx__KnownGraphNode(PyObject *o, visitproc v, void *a) {
 
8576
  int e;
 
8577
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)o;
 
8578
  if (p->key) {
 
8579
    e = (*v)(p->key, a); if (e) return e;
 
8580
  }
 
8581
  if (p->parents) {
 
8582
    e = (*v)(p->parents, a); if (e) return e;
 
8583
  }
 
8584
  if (p->children) {
 
8585
    e = (*v)(p->children, a); if (e) return e;
 
8586
  }
 
8587
  if (p->extra) {
 
8588
    e = (*v)(p->extra, a); if (e) return e;
 
8589
  }
 
8590
  return 0;
 
8591
}
 
8592
 
 
8593
static int __pyx_tp_clear_6bzrlib_16_known_graph_pyx__KnownGraphNode(PyObject *o) {
 
8594
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)o;
 
8595
  PyObject* tmp;
 
8596
  tmp = ((PyObject*)p->key);
 
8597
  p->key = Py_None; Py_INCREF(Py_None);
 
8598
  Py_XDECREF(tmp);
 
8599
  tmp = ((PyObject*)p->parents);
 
8600
  p->parents = Py_None; Py_INCREF(Py_None);
 
8601
  Py_XDECREF(tmp);
 
8602
  tmp = ((PyObject*)p->children);
 
8603
  p->children = Py_None; Py_INCREF(Py_None);
 
8604
  Py_XDECREF(tmp);
 
8605
  tmp = ((PyObject*)p->extra);
 
8606
  p->extra = Py_None; Py_INCREF(Py_None);
 
8607
  Py_XDECREF(tmp);
 
8608
  return 0;
 
8609
}
 
8610
 
 
8611
static PyObject *__pyx_getprop_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_child_keys(PyObject *o, void *x) {
 
8612
  return __pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_10child_keys___get__(o);
 
8613
}
 
8614
 
 
8615
static PyObject *__pyx_getprop_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_parent_keys(PyObject *o, void *x) {
 
8616
  return __pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_11parent_keys___get__(o);
 
8617
}
 
8618
 
 
8619
static PyObject *__pyx_getprop_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_gdfo(PyObject *o, void *x) {
 
8620
  return __pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_4gdfo___get__(o);
 
8621
}
 
8622
 
 
8623
static int __pyx_setprop_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_gdfo(PyObject *o, PyObject *v, void *x) {
 
8624
  if (v) {
 
8625
    return __pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_4gdfo_1__set__(o, v);
 
8626
  }
 
8627
  else {
 
8628
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
 
8629
    return -1;
 
8630
  }
 
8631
}
 
8632
 
 
8633
static PyMethodDef __pyx_methods_6bzrlib_16_known_graph_pyx__KnownGraphNode[] = {
 
8634
  {0, 0, 0, 0}
 
8635
};
 
8636
 
 
8637
static struct PyGetSetDef __pyx_getsets_6bzrlib_16_known_graph_pyx__KnownGraphNode[] = {
 
8638
  {(char *)"child_keys", __pyx_getprop_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_child_keys, 0, 0, 0},
 
8639
  {(char *)"parent_keys", __pyx_getprop_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_parent_keys, 0, 0, 0},
 
8640
  {(char *)"gdfo", __pyx_getprop_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_gdfo, __pyx_setprop_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_gdfo, 0, 0},
 
8641
  {0, 0, 0, 0, 0}
 
8642
};
 
8643
 
 
8644
static PyNumberMethods __pyx_tp_as_number__KnownGraphNode = {
 
8645
  0, /*nb_add*/
 
8646
  0, /*nb_subtract*/
 
8647
  0, /*nb_multiply*/
 
8648
  #if PY_MAJOR_VERSION < 3
 
8649
  0, /*nb_divide*/
 
8650
  #endif
 
8651
  0, /*nb_remainder*/
 
8652
  0, /*nb_divmod*/
 
8653
  0, /*nb_power*/
 
8654
  0, /*nb_negative*/
 
8655
  0, /*nb_positive*/
 
8656
  0, /*nb_absolute*/
 
8657
  0, /*nb_nonzero*/
 
8658
  0, /*nb_invert*/
 
8659
  0, /*nb_lshift*/
 
8660
  0, /*nb_rshift*/
 
8661
  0, /*nb_and*/
 
8662
  0, /*nb_xor*/
 
8663
  0, /*nb_or*/
 
8664
  #if PY_MAJOR_VERSION < 3
 
8665
  0, /*nb_coerce*/
 
8666
  #endif
 
8667
  0, /*nb_int*/
 
8668
  #if PY_MAJOR_VERSION < 3
 
8669
  0, /*nb_long*/
 
8670
  #else
 
8671
  0, /*reserved*/
 
8672
  #endif
 
8673
  0, /*nb_float*/
 
8674
  #if PY_MAJOR_VERSION < 3
 
8675
  0, /*nb_oct*/
 
8676
  #endif
 
8677
  #if PY_MAJOR_VERSION < 3
 
8678
  0, /*nb_hex*/
 
8679
  #endif
 
8680
  0, /*nb_inplace_add*/
 
8681
  0, /*nb_inplace_subtract*/
 
8682
  0, /*nb_inplace_multiply*/
 
8683
  #if PY_MAJOR_VERSION < 3
 
8684
  0, /*nb_inplace_divide*/
 
8685
  #endif
 
8686
  0, /*nb_inplace_remainder*/
 
8687
  0, /*nb_inplace_power*/
 
8688
  0, /*nb_inplace_lshift*/
 
8689
  0, /*nb_inplace_rshift*/
 
8690
  0, /*nb_inplace_and*/
 
8691
  0, /*nb_inplace_xor*/
 
8692
  0, /*nb_inplace_or*/
 
8693
  0, /*nb_floor_divide*/
 
8694
  0, /*nb_true_divide*/
 
8695
  0, /*nb_inplace_floor_divide*/
 
8696
  0, /*nb_inplace_true_divide*/
 
8697
  #if PY_VERSION_HEX >= 0x02050000
 
8698
  0, /*nb_index*/
 
8699
  #endif
 
8700
};
 
8701
 
 
8702
static PySequenceMethods __pyx_tp_as_sequence__KnownGraphNode = {
 
8703
  0, /*sq_length*/
 
8704
  0, /*sq_concat*/
 
8705
  0, /*sq_repeat*/
 
8706
  0, /*sq_item*/
 
8707
  0, /*sq_slice*/
 
8708
  0, /*sq_ass_item*/
 
8709
  0, /*sq_ass_slice*/
 
8710
  0, /*sq_contains*/
 
8711
  0, /*sq_inplace_concat*/
 
8712
  0, /*sq_inplace_repeat*/
 
8713
};
 
8714
 
 
8715
static PyMappingMethods __pyx_tp_as_mapping__KnownGraphNode = {
 
8716
  0, /*mp_length*/
 
8717
  0, /*mp_subscript*/
 
8718
  0, /*mp_ass_subscript*/
 
8719
};
 
8720
 
 
8721
static PyBufferProcs __pyx_tp_as_buffer__KnownGraphNode = {
 
8722
  #if PY_MAJOR_VERSION < 3
 
8723
  0, /*bf_getreadbuffer*/
 
8724
  #endif
 
8725
  #if PY_MAJOR_VERSION < 3
 
8726
  0, /*bf_getwritebuffer*/
 
8727
  #endif
 
8728
  #if PY_MAJOR_VERSION < 3
 
8729
  0, /*bf_getsegcount*/
 
8730
  #endif
 
8731
  #if PY_MAJOR_VERSION < 3
 
8732
  0, /*bf_getcharbuffer*/
 
8733
  #endif
 
8734
  #if PY_VERSION_HEX >= 0x02060000
 
8735
  0, /*bf_getbuffer*/
 
8736
  #endif
 
8737
  #if PY_VERSION_HEX >= 0x02060000
 
8738
  0, /*bf_releasebuffer*/
 
8739
  #endif
 
8740
};
 
8741
 
 
8742
static PyTypeObject __pyx_type_6bzrlib_16_known_graph_pyx__KnownGraphNode = {
 
8743
  PyVarObject_HEAD_INIT(0, 0)
 
8744
  __Pyx_NAMESTR("bzrlib._known_graph_pyx._KnownGraphNode"), /*tp_name*/
 
8745
  sizeof(struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode), /*tp_basicsize*/
 
8746
  0, /*tp_itemsize*/
 
8747
  __pyx_tp_dealloc_6bzrlib_16_known_graph_pyx__KnownGraphNode, /*tp_dealloc*/
 
8748
  0, /*tp_print*/
 
8749
  0, /*tp_getattr*/
 
8750
  0, /*tp_setattr*/
 
8751
  #if PY_MAJOR_VERSION < 3
 
8752
  0, /*tp_compare*/
 
8753
  #else
 
8754
  0, /*reserved*/
 
8755
  #endif
 
8756
  __pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_1__repr__, /*tp_repr*/
 
8757
  &__pyx_tp_as_number__KnownGraphNode, /*tp_as_number*/
 
8758
  &__pyx_tp_as_sequence__KnownGraphNode, /*tp_as_sequence*/
 
8759
  &__pyx_tp_as_mapping__KnownGraphNode, /*tp_as_mapping*/
 
8760
  0, /*tp_hash*/
 
8761
  0, /*tp_call*/
 
8762
  0, /*tp_str*/
 
8763
  0, /*tp_getattro*/
 
8764
  0, /*tp_setattro*/
 
8765
  &__pyx_tp_as_buffer__KnownGraphNode, /*tp_as_buffer*/
 
8766
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
 
8767
  __Pyx_DOCSTR("Represents a single object in the known graph."), /*tp_doc*/
 
8768
  __pyx_tp_traverse_6bzrlib_16_known_graph_pyx__KnownGraphNode, /*tp_traverse*/
 
8769
  __pyx_tp_clear_6bzrlib_16_known_graph_pyx__KnownGraphNode, /*tp_clear*/
 
8770
  0, /*tp_richcompare*/
 
8771
  0, /*tp_weaklistoffset*/
 
8772
  0, /*tp_iter*/
 
8773
  0, /*tp_iternext*/
 
8774
  __pyx_methods_6bzrlib_16_known_graph_pyx__KnownGraphNode, /*tp_methods*/
 
8775
  0, /*tp_members*/
 
8776
  __pyx_getsets_6bzrlib_16_known_graph_pyx__KnownGraphNode, /*tp_getset*/
 
8777
  0, /*tp_base*/
 
8778
  0, /*tp_dict*/
 
8779
  0, /*tp_descr_get*/
 
8780
  0, /*tp_descr_set*/
 
8781
  0, /*tp_dictoffset*/
 
8782
  __pyx_pf_6bzrlib_16_known_graph_pyx_15_KnownGraphNode___init__, /*tp_init*/
 
8783
  0, /*tp_alloc*/
 
8784
  __pyx_tp_new_6bzrlib_16_known_graph_pyx__KnownGraphNode, /*tp_new*/
 
8785
  0, /*tp_free*/
 
8786
  0, /*tp_is_gc*/
 
8787
  0, /*tp_bases*/
 
8788
  0, /*tp_mro*/
 
8789
  0, /*tp_cache*/
 
8790
  0, /*tp_subclasses*/
 
8791
  0, /*tp_weaklist*/
 
8792
  0, /*tp_del*/
 
8793
  #if PY_VERSION_HEX >= 0x02060000
 
8794
  0, /*tp_version_tag*/
 
8795
  #endif
 
8796
};
 
8797
static struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSorter __pyx_vtable_6bzrlib_16_known_graph_pyx__MergeSorter;
 
8798
 
 
8799
static PyObject *__pyx_tp_new_6bzrlib_16_known_graph_pyx__MergeSorter(PyTypeObject *t, PyObject *a, PyObject *k) {
 
8800
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *p;
 
8801
  PyObject *o = (*t->tp_alloc)(t, 0);
 
8802
  if (!o) return 0;
 
8803
  p = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)o);
 
8804
  p->__pyx_vtab = __pyx_vtabptr_6bzrlib_16_known_graph_pyx__MergeSorter;
 
8805
  p->graph = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)Py_None); Py_INCREF(Py_None);
 
8806
  p->_depth_first_stack = Py_None; Py_INCREF(Py_None);
 
8807
  p->_revno_to_branch_count = Py_None; Py_INCREF(Py_None);
 
8808
  p->_scheduled_nodes = Py_None; Py_INCREF(Py_None);
 
8809
  return o;
 
8810
}
 
8811
 
 
8812
static void __pyx_tp_dealloc_6bzrlib_16_known_graph_pyx__MergeSorter(PyObject *o) {
 
8813
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)o;
 
8814
  Py_XDECREF(((PyObject *)p->graph));
 
8815
  Py_XDECREF(p->_depth_first_stack);
 
8816
  Py_XDECREF(p->_revno_to_branch_count);
 
8817
  Py_XDECREF(p->_scheduled_nodes);
 
8818
  (*Py_TYPE(o)->tp_free)(o);
 
8819
}
 
8820
 
 
8821
static int __pyx_tp_traverse_6bzrlib_16_known_graph_pyx__MergeSorter(PyObject *o, visitproc v, void *a) {
 
8822
  int e;
 
8823
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)o;
 
8824
  if (p->graph) {
 
8825
    e = (*v)(((PyObject*)p->graph), a); if (e) return e;
 
8826
  }
 
8827
  if (p->_depth_first_stack) {
 
8828
    e = (*v)(p->_depth_first_stack, a); if (e) return e;
 
8829
  }
 
8830
  if (p->_revno_to_branch_count) {
 
8831
    e = (*v)(p->_revno_to_branch_count, a); if (e) return e;
 
8832
  }
 
8833
  if (p->_scheduled_nodes) {
 
8834
    e = (*v)(p->_scheduled_nodes, a); if (e) return e;
 
8835
  }
 
8836
  return 0;
 
8837
}
 
8838
 
 
8839
static int __pyx_tp_clear_6bzrlib_16_known_graph_pyx__MergeSorter(PyObject *o) {
 
8840
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *)o;
 
8841
  PyObject* tmp;
 
8842
  tmp = ((PyObject*)p->graph);
 
8843
  p->graph = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)Py_None); Py_INCREF(Py_None);
 
8844
  Py_XDECREF(tmp);
 
8845
  tmp = ((PyObject*)p->_depth_first_stack);
 
8846
  p->_depth_first_stack = Py_None; Py_INCREF(Py_None);
 
8847
  Py_XDECREF(tmp);
 
8848
  tmp = ((PyObject*)p->_revno_to_branch_count);
 
8849
  p->_revno_to_branch_count = Py_None; Py_INCREF(Py_None);
 
8850
  Py_XDECREF(tmp);
 
8851
  tmp = ((PyObject*)p->_scheduled_nodes);
 
8852
  p->_scheduled_nodes = Py_None; Py_INCREF(Py_None);
 
8853
  Py_XDECREF(tmp);
 
8854
  return 0;
 
8855
}
 
8856
 
 
8857
static PyMethodDef __pyx_methods_6bzrlib_16_known_graph_pyx__MergeSorter[] = {
 
8858
  {0, 0, 0, 0}
 
8859
};
 
8860
 
 
8861
static PyNumberMethods __pyx_tp_as_number__MergeSorter = {
 
8862
  0, /*nb_add*/
 
8863
  0, /*nb_subtract*/
 
8864
  0, /*nb_multiply*/
 
8865
  #if PY_MAJOR_VERSION < 3
 
8866
  0, /*nb_divide*/
 
8867
  #endif
 
8868
  0, /*nb_remainder*/
 
8869
  0, /*nb_divmod*/
 
8870
  0, /*nb_power*/
 
8871
  0, /*nb_negative*/
 
8872
  0, /*nb_positive*/
 
8873
  0, /*nb_absolute*/
 
8874
  0, /*nb_nonzero*/
 
8875
  0, /*nb_invert*/
 
8876
  0, /*nb_lshift*/
 
8877
  0, /*nb_rshift*/
 
8878
  0, /*nb_and*/
 
8879
  0, /*nb_xor*/
 
8880
  0, /*nb_or*/
 
8881
  #if PY_MAJOR_VERSION < 3
 
8882
  0, /*nb_coerce*/
 
8883
  #endif
 
8884
  0, /*nb_int*/
 
8885
  #if PY_MAJOR_VERSION < 3
 
8886
  0, /*nb_long*/
 
8887
  #else
 
8888
  0, /*reserved*/
 
8889
  #endif
 
8890
  0, /*nb_float*/
 
8891
  #if PY_MAJOR_VERSION < 3
 
8892
  0, /*nb_oct*/
 
8893
  #endif
 
8894
  #if PY_MAJOR_VERSION < 3
 
8895
  0, /*nb_hex*/
 
8896
  #endif
 
8897
  0, /*nb_inplace_add*/
 
8898
  0, /*nb_inplace_subtract*/
 
8899
  0, /*nb_inplace_multiply*/
 
8900
  #if PY_MAJOR_VERSION < 3
 
8901
  0, /*nb_inplace_divide*/
 
8902
  #endif
 
8903
  0, /*nb_inplace_remainder*/
 
8904
  0, /*nb_inplace_power*/
 
8905
  0, /*nb_inplace_lshift*/
 
8906
  0, /*nb_inplace_rshift*/
 
8907
  0, /*nb_inplace_and*/
 
8908
  0, /*nb_inplace_xor*/
 
8909
  0, /*nb_inplace_or*/
 
8910
  0, /*nb_floor_divide*/
 
8911
  0, /*nb_true_divide*/
 
8912
  0, /*nb_inplace_floor_divide*/
 
8913
  0, /*nb_inplace_true_divide*/
 
8914
  #if PY_VERSION_HEX >= 0x02050000
 
8915
  0, /*nb_index*/
 
8916
  #endif
 
8917
};
 
8918
 
 
8919
static PySequenceMethods __pyx_tp_as_sequence__MergeSorter = {
 
8920
  0, /*sq_length*/
 
8921
  0, /*sq_concat*/
 
8922
  0, /*sq_repeat*/
 
8923
  0, /*sq_item*/
 
8924
  0, /*sq_slice*/
 
8925
  0, /*sq_ass_item*/
 
8926
  0, /*sq_ass_slice*/
 
8927
  0, /*sq_contains*/
 
8928
  0, /*sq_inplace_concat*/
 
8929
  0, /*sq_inplace_repeat*/
 
8930
};
 
8931
 
 
8932
static PyMappingMethods __pyx_tp_as_mapping__MergeSorter = {
 
8933
  0, /*mp_length*/
 
8934
  0, /*mp_subscript*/
 
8935
  0, /*mp_ass_subscript*/
 
8936
};
 
8937
 
 
8938
static PyBufferProcs __pyx_tp_as_buffer__MergeSorter = {
 
8939
  #if PY_MAJOR_VERSION < 3
 
8940
  0, /*bf_getreadbuffer*/
 
8941
  #endif
 
8942
  #if PY_MAJOR_VERSION < 3
 
8943
  0, /*bf_getwritebuffer*/
 
8944
  #endif
 
8945
  #if PY_MAJOR_VERSION < 3
 
8946
  0, /*bf_getsegcount*/
 
8947
  #endif
 
8948
  #if PY_MAJOR_VERSION < 3
 
8949
  0, /*bf_getcharbuffer*/
 
8950
  #endif
 
8951
  #if PY_VERSION_HEX >= 0x02060000
 
8952
  0, /*bf_getbuffer*/
 
8953
  #endif
 
8954
  #if PY_VERSION_HEX >= 0x02060000
 
8955
  0, /*bf_releasebuffer*/
 
8956
  #endif
 
8957
};
 
8958
 
 
8959
static PyTypeObject __pyx_type_6bzrlib_16_known_graph_pyx__MergeSorter = {
 
8960
  PyVarObject_HEAD_INIT(0, 0)
 
8961
  __Pyx_NAMESTR("bzrlib._known_graph_pyx._MergeSorter"), /*tp_name*/
 
8962
  sizeof(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter), /*tp_basicsize*/
 
8963
  0, /*tp_itemsize*/
 
8964
  __pyx_tp_dealloc_6bzrlib_16_known_graph_pyx__MergeSorter, /*tp_dealloc*/
 
8965
  0, /*tp_print*/
 
8966
  0, /*tp_getattr*/
 
8967
  0, /*tp_setattr*/
 
8968
  #if PY_MAJOR_VERSION < 3
 
8969
  0, /*tp_compare*/
 
8970
  #else
 
8971
  0, /*reserved*/
 
8972
  #endif
 
8973
  0, /*tp_repr*/
 
8974
  &__pyx_tp_as_number__MergeSorter, /*tp_as_number*/
 
8975
  &__pyx_tp_as_sequence__MergeSorter, /*tp_as_sequence*/
 
8976
  &__pyx_tp_as_mapping__MergeSorter, /*tp_as_mapping*/
 
8977
  0, /*tp_hash*/
 
8978
  0, /*tp_call*/
 
8979
  0, /*tp_str*/
 
8980
  0, /*tp_getattro*/
 
8981
  0, /*tp_setattro*/
 
8982
  &__pyx_tp_as_buffer__MergeSorter, /*tp_as_buffer*/
 
8983
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
 
8984
  __Pyx_DOCSTR("This class does the work of computing the merge_sort ordering.\n\n    We have some small advantages, in that we get all the extra information\n    that KnownGraph knows, like knowing the child lists, etc.\n    "), /*tp_doc*/
 
8985
  __pyx_tp_traverse_6bzrlib_16_known_graph_pyx__MergeSorter, /*tp_traverse*/
 
8986
  __pyx_tp_clear_6bzrlib_16_known_graph_pyx__MergeSorter, /*tp_clear*/
 
8987
  0, /*tp_richcompare*/
 
8988
  0, /*tp_weaklistoffset*/
 
8989
  0, /*tp_iter*/
 
8990
  0, /*tp_iternext*/
 
8991
  __pyx_methods_6bzrlib_16_known_graph_pyx__MergeSorter, /*tp_methods*/
 
8992
  0, /*tp_members*/
 
8993
  0, /*tp_getset*/
 
8994
  0, /*tp_base*/
 
8995
  0, /*tp_dict*/
 
8996
  0, /*tp_descr_get*/
 
8997
  0, /*tp_descr_set*/
 
8998
  0, /*tp_dictoffset*/
 
8999
  __pyx_pf_6bzrlib_16_known_graph_pyx_12_MergeSorter___init__, /*tp_init*/
 
9000
  0, /*tp_alloc*/
 
9001
  __pyx_tp_new_6bzrlib_16_known_graph_pyx__MergeSorter, /*tp_new*/
 
9002
  0, /*tp_free*/
 
9003
  0, /*tp_is_gc*/
 
9004
  0, /*tp_bases*/
 
9005
  0, /*tp_mro*/
 
9006
  0, /*tp_cache*/
 
9007
  0, /*tp_subclasses*/
 
9008
  0, /*tp_weaklist*/
 
9009
  0, /*tp_del*/
 
9010
  #if PY_VERSION_HEX >= 0x02060000
 
9011
  0, /*tp_version_tag*/
 
9012
  #endif
 
9013
};
 
9014
static struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx_KnownGraph __pyx_vtable_6bzrlib_16_known_graph_pyx_KnownGraph;
 
9015
 
 
9016
static PyObject *__pyx_tp_new_6bzrlib_16_known_graph_pyx_KnownGraph(PyTypeObject *t, PyObject *a, PyObject *k) {
 
9017
  struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *p;
 
9018
  PyObject *o = (*t->tp_alloc)(t, 0);
 
9019
  if (!o) return 0;
 
9020
  p = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)o);
 
9021
  p->__pyx_vtab = __pyx_vtabptr_6bzrlib_16_known_graph_pyx_KnownGraph;
 
9022
  p->_nodes = Py_None; Py_INCREF(Py_None);
 
9023
  p->_known_heads = Py_None; Py_INCREF(Py_None);
 
9024
  return o;
 
9025
}
 
9026
 
 
9027
static void __pyx_tp_dealloc_6bzrlib_16_known_graph_pyx_KnownGraph(PyObject *o) {
 
9028
  struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)o;
 
9029
  {
 
9030
    PyObject *etype, *eval, *etb;
 
9031
    PyErr_Fetch(&etype, &eval, &etb);
 
9032
    ++Py_REFCNT(o);
 
9033
    __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_1__dealloc__(o);
 
9034
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
 
9035
    --Py_REFCNT(o);
 
9036
    PyErr_Restore(etype, eval, etb);
 
9037
  }
 
9038
  Py_XDECREF(p->_nodes);
 
9039
  Py_XDECREF(p->_known_heads);
 
9040
  (*Py_TYPE(o)->tp_free)(o);
 
9041
}
 
9042
 
 
9043
static int __pyx_tp_traverse_6bzrlib_16_known_graph_pyx_KnownGraph(PyObject *o, visitproc v, void *a) {
 
9044
  int e;
 
9045
  struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)o;
 
9046
  if (p->_nodes) {
 
9047
    e = (*v)(p->_nodes, a); if (e) return e;
 
9048
  }
 
9049
  if (p->_known_heads) {
 
9050
    e = (*v)(p->_known_heads, a); if (e) return e;
 
9051
  }
 
9052
  return 0;
 
9053
}
 
9054
 
 
9055
static int __pyx_tp_clear_6bzrlib_16_known_graph_pyx_KnownGraph(PyObject *o) {
 
9056
  struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *)o;
 
9057
  PyObject* tmp;
 
9058
  tmp = ((PyObject*)p->_nodes);
 
9059
  p->_nodes = Py_None; Py_INCREF(Py_None);
 
9060
  Py_XDECREF(tmp);
 
9061
  tmp = ((PyObject*)p->_known_heads);
 
9062
  p->_known_heads = Py_None; Py_INCREF(Py_None);
 
9063
  Py_XDECREF(tmp);
 
9064
  return 0;
 
9065
}
 
9066
 
 
9067
static PyObject *__pyx_getprop_6bzrlib_16_known_graph_pyx_10KnownGraph__nodes(PyObject *o, void *x) {
 
9068
  return __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6_nodes___get__(o);
 
9069
}
 
9070
 
 
9071
static int __pyx_setprop_6bzrlib_16_known_graph_pyx_10KnownGraph__nodes(PyObject *o, PyObject *v, void *x) {
 
9072
  if (v) {
 
9073
    return __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6_nodes_1__set__(o, v);
 
9074
  }
 
9075
  else {
 
9076
    return __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6_nodes_2__del__(o);
 
9077
  }
 
9078
}
 
9079
 
 
9080
static PyObject *__pyx_getprop_6bzrlib_16_known_graph_pyx_10KnownGraph__known_heads(PyObject *o, void *x) {
 
9081
  return __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12_known_heads___get__(o);
 
9082
}
 
9083
 
 
9084
static int __pyx_setprop_6bzrlib_16_known_graph_pyx_10KnownGraph__known_heads(PyObject *o, PyObject *v, void *x) {
 
9085
  if (v) {
 
9086
    return __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12_known_heads_1__set__(o, v);
 
9087
  }
 
9088
  else {
 
9089
    return __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12_known_heads_2__del__(o);
 
9090
  }
 
9091
}
 
9092
 
 
9093
static PyObject *__pyx_getprop_6bzrlib_16_known_graph_pyx_10KnownGraph_do_cache(PyObject *o, void *x) {
 
9094
  return __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_8do_cache___get__(o);
 
9095
}
 
9096
 
 
9097
static int __pyx_setprop_6bzrlib_16_known_graph_pyx_10KnownGraph_do_cache(PyObject *o, PyObject *v, void *x) {
 
9098
  if (v) {
 
9099
    return __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_8do_cache_1__set__(o, v);
 
9100
  }
 
9101
  else {
 
9102
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
 
9103
    return -1;
 
9104
  }
 
9105
}
 
9106
 
 
9107
static PyMethodDef __pyx_methods_6bzrlib_16_known_graph_pyx_KnownGraph[] = {
 
9108
  {__Pyx_NAMESTR("_initialize_nodes"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_2_initialize_nodes, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_2_initialize_nodes)},
 
9109
  {__Pyx_NAMESTR("_find_tails"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_3_find_tails, METH_NOARGS, __Pyx_DOCSTR(0)},
 
9110
  {__Pyx_NAMESTR("_find_tips"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_4_find_tips, METH_NOARGS, __Pyx_DOCSTR(0)},
 
9111
  {__Pyx_NAMESTR("_find_gdfo"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_5_find_gdfo, METH_NOARGS, __Pyx_DOCSTR(0)},
 
9112
  {__Pyx_NAMESTR("add_node"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_6add_node, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_6add_node)},
 
9113
  {__Pyx_NAMESTR("heads"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_7heads, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_7heads)},
 
9114
  {__Pyx_NAMESTR("topo_sort"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_8topo_sort, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_8topo_sort)},
 
9115
  {__Pyx_NAMESTR("gc_sort"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_9gc_sort, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_9gc_sort)},
 
9116
  {__Pyx_NAMESTR("merge_sort"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_10merge_sort, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_10merge_sort)},
 
9117
  {__Pyx_NAMESTR("get_parent_keys"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_11get_parent_keys, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_11get_parent_keys)},
 
9118
  {__Pyx_NAMESTR("get_child_keys"), (PyCFunction)__pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph_12get_child_keys, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph_12get_child_keys)},
 
9119
  {0, 0, 0, 0}
 
9120
};
 
9121
 
 
9122
static struct PyGetSetDef __pyx_getsets_6bzrlib_16_known_graph_pyx_KnownGraph[] = {
 
9123
  {(char *)"_nodes", __pyx_getprop_6bzrlib_16_known_graph_pyx_10KnownGraph__nodes, __pyx_setprop_6bzrlib_16_known_graph_pyx_10KnownGraph__nodes, 0, 0},
 
9124
  {(char *)"_known_heads", __pyx_getprop_6bzrlib_16_known_graph_pyx_10KnownGraph__known_heads, __pyx_setprop_6bzrlib_16_known_graph_pyx_10KnownGraph__known_heads, 0, 0},
 
9125
  {(char *)"do_cache", __pyx_getprop_6bzrlib_16_known_graph_pyx_10KnownGraph_do_cache, __pyx_setprop_6bzrlib_16_known_graph_pyx_10KnownGraph_do_cache, 0, 0},
 
9126
  {0, 0, 0, 0, 0}
 
9127
};
 
9128
 
 
9129
static PyNumberMethods __pyx_tp_as_number_KnownGraph = {
 
9130
  0, /*nb_add*/
 
9131
  0, /*nb_subtract*/
 
9132
  0, /*nb_multiply*/
 
9133
  #if PY_MAJOR_VERSION < 3
 
9134
  0, /*nb_divide*/
 
9135
  #endif
 
9136
  0, /*nb_remainder*/
 
9137
  0, /*nb_divmod*/
 
9138
  0, /*nb_power*/
 
9139
  0, /*nb_negative*/
 
9140
  0, /*nb_positive*/
 
9141
  0, /*nb_absolute*/
 
9142
  0, /*nb_nonzero*/
 
9143
  0, /*nb_invert*/
 
9144
  0, /*nb_lshift*/
 
9145
  0, /*nb_rshift*/
 
9146
  0, /*nb_and*/
 
9147
  0, /*nb_xor*/
 
9148
  0, /*nb_or*/
 
9149
  #if PY_MAJOR_VERSION < 3
 
9150
  0, /*nb_coerce*/
 
9151
  #endif
 
9152
  0, /*nb_int*/
 
9153
  #if PY_MAJOR_VERSION < 3
 
9154
  0, /*nb_long*/
 
9155
  #else
 
9156
  0, /*reserved*/
 
9157
  #endif
 
9158
  0, /*nb_float*/
 
9159
  #if PY_MAJOR_VERSION < 3
 
9160
  0, /*nb_oct*/
 
9161
  #endif
 
9162
  #if PY_MAJOR_VERSION < 3
 
9163
  0, /*nb_hex*/
 
9164
  #endif
 
9165
  0, /*nb_inplace_add*/
 
9166
  0, /*nb_inplace_subtract*/
 
9167
  0, /*nb_inplace_multiply*/
 
9168
  #if PY_MAJOR_VERSION < 3
 
9169
  0, /*nb_inplace_divide*/
 
9170
  #endif
 
9171
  0, /*nb_inplace_remainder*/
 
9172
  0, /*nb_inplace_power*/
 
9173
  0, /*nb_inplace_lshift*/
 
9174
  0, /*nb_inplace_rshift*/
 
9175
  0, /*nb_inplace_and*/
 
9176
  0, /*nb_inplace_xor*/
 
9177
  0, /*nb_inplace_or*/
 
9178
  0, /*nb_floor_divide*/
 
9179
  0, /*nb_true_divide*/
 
9180
  0, /*nb_inplace_floor_divide*/
 
9181
  0, /*nb_inplace_true_divide*/
 
9182
  #if PY_VERSION_HEX >= 0x02050000
 
9183
  0, /*nb_index*/
 
9184
  #endif
 
9185
};
 
9186
 
 
9187
static PySequenceMethods __pyx_tp_as_sequence_KnownGraph = {
 
9188
  0, /*sq_length*/
 
9189
  0, /*sq_concat*/
 
9190
  0, /*sq_repeat*/
 
9191
  0, /*sq_item*/
 
9192
  0, /*sq_slice*/
 
9193
  0, /*sq_ass_item*/
 
9194
  0, /*sq_ass_slice*/
 
9195
  0, /*sq_contains*/
 
9196
  0, /*sq_inplace_concat*/
 
9197
  0, /*sq_inplace_repeat*/
 
9198
};
 
9199
 
 
9200
static PyMappingMethods __pyx_tp_as_mapping_KnownGraph = {
 
9201
  0, /*mp_length*/
 
9202
  0, /*mp_subscript*/
 
9203
  0, /*mp_ass_subscript*/
 
9204
};
 
9205
 
 
9206
static PyBufferProcs __pyx_tp_as_buffer_KnownGraph = {
 
9207
  #if PY_MAJOR_VERSION < 3
 
9208
  0, /*bf_getreadbuffer*/
 
9209
  #endif
 
9210
  #if PY_MAJOR_VERSION < 3
 
9211
  0, /*bf_getwritebuffer*/
 
9212
  #endif
 
9213
  #if PY_MAJOR_VERSION < 3
 
9214
  0, /*bf_getsegcount*/
 
9215
  #endif
 
9216
  #if PY_MAJOR_VERSION < 3
 
9217
  0, /*bf_getcharbuffer*/
 
9218
  #endif
 
9219
  #if PY_VERSION_HEX >= 0x02060000
 
9220
  0, /*bf_getbuffer*/
 
9221
  #endif
 
9222
  #if PY_VERSION_HEX >= 0x02060000
 
9223
  0, /*bf_releasebuffer*/
 
9224
  #endif
 
9225
};
 
9226
 
 
9227
static PyTypeObject __pyx_type_6bzrlib_16_known_graph_pyx_KnownGraph = {
 
9228
  PyVarObject_HEAD_INIT(0, 0)
 
9229
  __Pyx_NAMESTR("bzrlib._known_graph_pyx.KnownGraph"), /*tp_name*/
 
9230
  sizeof(struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph), /*tp_basicsize*/
 
9231
  0, /*tp_itemsize*/
 
9232
  __pyx_tp_dealloc_6bzrlib_16_known_graph_pyx_KnownGraph, /*tp_dealloc*/
 
9233
  0, /*tp_print*/
 
9234
  0, /*tp_getattr*/
 
9235
  0, /*tp_setattr*/
 
9236
  #if PY_MAJOR_VERSION < 3
 
9237
  0, /*tp_compare*/
 
9238
  #else
 
9239
  0, /*reserved*/
 
9240
  #endif
 
9241
  0, /*tp_repr*/
 
9242
  &__pyx_tp_as_number_KnownGraph, /*tp_as_number*/
 
9243
  &__pyx_tp_as_sequence_KnownGraph, /*tp_as_sequence*/
 
9244
  &__pyx_tp_as_mapping_KnownGraph, /*tp_as_mapping*/
 
9245
  0, /*tp_hash*/
 
9246
  0, /*tp_call*/
 
9247
  0, /*tp_str*/
 
9248
  0, /*tp_getattro*/
 
9249
  0, /*tp_setattro*/
 
9250
  &__pyx_tp_as_buffer_KnownGraph, /*tp_as_buffer*/
 
9251
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
 
9252
  __Pyx_DOCSTR("This is a class which assumes we already know the full graph."), /*tp_doc*/
 
9253
  __pyx_tp_traverse_6bzrlib_16_known_graph_pyx_KnownGraph, /*tp_traverse*/
 
9254
  __pyx_tp_clear_6bzrlib_16_known_graph_pyx_KnownGraph, /*tp_clear*/
 
9255
  0, /*tp_richcompare*/
 
9256
  0, /*tp_weaklistoffset*/
 
9257
  0, /*tp_iter*/
 
9258
  0, /*tp_iternext*/
 
9259
  __pyx_methods_6bzrlib_16_known_graph_pyx_KnownGraph, /*tp_methods*/
 
9260
  0, /*tp_members*/
 
9261
  __pyx_getsets_6bzrlib_16_known_graph_pyx_KnownGraph, /*tp_getset*/
 
9262
  0, /*tp_base*/
 
9263
  0, /*tp_dict*/
 
9264
  0, /*tp_descr_get*/
 
9265
  0, /*tp_descr_set*/
 
9266
  0, /*tp_dictoffset*/
 
9267
  __pyx_pf_6bzrlib_16_known_graph_pyx_10KnownGraph___init__, /*tp_init*/
 
9268
  0, /*tp_alloc*/
 
9269
  __pyx_tp_new_6bzrlib_16_known_graph_pyx_KnownGraph, /*tp_new*/
 
9270
  0, /*tp_free*/
 
9271
  0, /*tp_is_gc*/
 
9272
  0, /*tp_bases*/
 
9273
  0, /*tp_mro*/
 
9274
  0, /*tp_cache*/
 
9275
  0, /*tp_subclasses*/
 
9276
  0, /*tp_weaklist*/
 
9277
  0, /*tp_del*/
 
9278
  #if PY_VERSION_HEX >= 0x02060000
 
9279
  0, /*tp_version_tag*/
 
9280
  #endif
 
9281
};
 
9282
static struct __pyx_vtabstruct_6bzrlib_16_known_graph_pyx__MergeSortNode __pyx_vtable_6bzrlib_16_known_graph_pyx__MergeSortNode;
 
9283
 
 
9284
static PyObject *__pyx_tp_new_6bzrlib_16_known_graph_pyx__MergeSortNode(PyTypeObject *t, PyObject *a, PyObject *k) {
 
9285
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *p;
 
9286
  PyObject *o = (*t->tp_alloc)(t, 0);
 
9287
  if (!o) return 0;
 
9288
  p = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)o);
 
9289
  p->__pyx_vtab = __pyx_vtabptr_6bzrlib_16_known_graph_pyx__MergeSortNode;
 
9290
  p->key = Py_None; Py_INCREF(Py_None);
 
9291
  p->end_of_merge = Py_None; Py_INCREF(Py_None);
 
9292
  p->left_parent = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); Py_INCREF(Py_None);
 
9293
  p->left_pending_parent = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); Py_INCREF(Py_None);
 
9294
  p->pending_parents = Py_None; Py_INCREF(Py_None);
 
9295
  return o;
 
9296
}
 
9297
 
 
9298
static void __pyx_tp_dealloc_6bzrlib_16_known_graph_pyx__MergeSortNode(PyObject *o) {
 
9299
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)o;
 
9300
  Py_XDECREF(p->key);
 
9301
  Py_XDECREF(p->end_of_merge);
 
9302
  Py_XDECREF(((PyObject *)p->left_parent));
 
9303
  Py_XDECREF(((PyObject *)p->left_pending_parent));
 
9304
  Py_XDECREF(p->pending_parents);
 
9305
  (*Py_TYPE(o)->tp_free)(o);
 
9306
}
 
9307
 
 
9308
static int __pyx_tp_traverse_6bzrlib_16_known_graph_pyx__MergeSortNode(PyObject *o, visitproc v, void *a) {
 
9309
  int e;
 
9310
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)o;
 
9311
  if (p->key) {
 
9312
    e = (*v)(p->key, a); if (e) return e;
 
9313
  }
 
9314
  if (p->end_of_merge) {
 
9315
    e = (*v)(p->end_of_merge, a); if (e) return e;
 
9316
  }
 
9317
  if (p->left_parent) {
 
9318
    e = (*v)(((PyObject*)p->left_parent), a); if (e) return e;
 
9319
  }
 
9320
  if (p->left_pending_parent) {
 
9321
    e = (*v)(((PyObject*)p->left_pending_parent), a); if (e) return e;
 
9322
  }
 
9323
  if (p->pending_parents) {
 
9324
    e = (*v)(p->pending_parents, a); if (e) return e;
 
9325
  }
 
9326
  return 0;
 
9327
}
 
9328
 
 
9329
static int __pyx_tp_clear_6bzrlib_16_known_graph_pyx__MergeSortNode(PyObject *o) {
 
9330
  struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *p = (struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *)o;
 
9331
  PyObject* tmp;
 
9332
  tmp = ((PyObject*)p->key);
 
9333
  p->key = Py_None; Py_INCREF(Py_None);
 
9334
  Py_XDECREF(tmp);
 
9335
  tmp = ((PyObject*)p->end_of_merge);
 
9336
  p->end_of_merge = Py_None; Py_INCREF(Py_None);
 
9337
  Py_XDECREF(tmp);
 
9338
  tmp = ((PyObject*)p->left_parent);
 
9339
  p->left_parent = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); Py_INCREF(Py_None);
 
9340
  Py_XDECREF(tmp);
 
9341
  tmp = ((PyObject*)p->left_pending_parent);
 
9342
  p->left_pending_parent = ((struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *)Py_None); Py_INCREF(Py_None);
 
9343
  Py_XDECREF(tmp);
 
9344
  tmp = ((PyObject*)p->pending_parents);
 
9345
  p->pending_parents = Py_None; Py_INCREF(Py_None);
 
9346
  Py_XDECREF(tmp);
 
9347
  return 0;
 
9348
}
 
9349
 
 
9350
static PyObject *__pyx_getprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_revno(PyObject *o, void *x) {
 
9351
  return __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_5revno___get__(o);
 
9352
}
 
9353
 
 
9354
static PyObject *__pyx_getprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_key(PyObject *o, void *x) {
 
9355
  return __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_3key___get__(o);
 
9356
}
 
9357
 
 
9358
static int __pyx_setprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_key(PyObject *o, PyObject *v, void *x) {
 
9359
  if (v) {
 
9360
    return __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_3key_1__set__(o, v);
 
9361
  }
 
9362
  else {
 
9363
    return __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_3key_2__del__(o);
 
9364
  }
 
9365
}
 
9366
 
 
9367
static PyObject *__pyx_getprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_merge_depth(PyObject *o, void *x) {
 
9368
  return __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_11merge_depth___get__(o);
 
9369
}
 
9370
 
 
9371
static int __pyx_setprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_merge_depth(PyObject *o, PyObject *v, void *x) {
 
9372
  if (v) {
 
9373
    return __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_11merge_depth_1__set__(o, v);
 
9374
  }
 
9375
  else {
 
9376
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
 
9377
    return -1;
 
9378
  }
 
9379
}
 
9380
 
 
9381
static PyObject *__pyx_getprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_end_of_merge(PyObject *o, void *x) {
 
9382
  return __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_12end_of_merge___get__(o);
 
9383
}
 
9384
 
 
9385
static int __pyx_setprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_end_of_merge(PyObject *o, PyObject *v, void *x) {
 
9386
  if (v) {
 
9387
    return __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_1__set__(o, v);
 
9388
  }
 
9389
  else {
 
9390
    return __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_12end_of_merge_2__del__(o);
 
9391
  }
 
9392
}
 
9393
 
 
9394
static PyMethodDef __pyx_methods_6bzrlib_16_known_graph_pyx__MergeSortNode[] = {
 
9395
  {0, 0, 0, 0}
 
9396
};
 
9397
 
 
9398
static struct PyGetSetDef __pyx_getsets_6bzrlib_16_known_graph_pyx__MergeSortNode[] = {
 
9399
  {(char *)"revno", __pyx_getprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_revno, 0, 0, 0},
 
9400
  {(char *)"key", __pyx_getprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_key, __pyx_setprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_key, 0, 0},
 
9401
  {(char *)"merge_depth", __pyx_getprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_merge_depth, __pyx_setprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_merge_depth, 0, 0},
 
9402
  {(char *)"end_of_merge", __pyx_getprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_end_of_merge, __pyx_setprop_6bzrlib_16_known_graph_pyx_14_MergeSortNode_end_of_merge, 0, 0},
 
9403
  {0, 0, 0, 0, 0}
 
9404
};
 
9405
 
 
9406
static PyNumberMethods __pyx_tp_as_number__MergeSortNode = {
 
9407
  0, /*nb_add*/
 
9408
  0, /*nb_subtract*/
 
9409
  0, /*nb_multiply*/
 
9410
  #if PY_MAJOR_VERSION < 3
 
9411
  0, /*nb_divide*/
 
9412
  #endif
 
9413
  0, /*nb_remainder*/
 
9414
  0, /*nb_divmod*/
 
9415
  0, /*nb_power*/
 
9416
  0, /*nb_negative*/
 
9417
  0, /*nb_positive*/
 
9418
  0, /*nb_absolute*/
 
9419
  0, /*nb_nonzero*/
 
9420
  0, /*nb_invert*/
 
9421
  0, /*nb_lshift*/
 
9422
  0, /*nb_rshift*/
 
9423
  0, /*nb_and*/
 
9424
  0, /*nb_xor*/
 
9425
  0, /*nb_or*/
 
9426
  #if PY_MAJOR_VERSION < 3
 
9427
  0, /*nb_coerce*/
 
9428
  #endif
 
9429
  0, /*nb_int*/
 
9430
  #if PY_MAJOR_VERSION < 3
 
9431
  0, /*nb_long*/
 
9432
  #else
 
9433
  0, /*reserved*/
 
9434
  #endif
 
9435
  0, /*nb_float*/
 
9436
  #if PY_MAJOR_VERSION < 3
 
9437
  0, /*nb_oct*/
 
9438
  #endif
 
9439
  #if PY_MAJOR_VERSION < 3
 
9440
  0, /*nb_hex*/
 
9441
  #endif
 
9442
  0, /*nb_inplace_add*/
 
9443
  0, /*nb_inplace_subtract*/
 
9444
  0, /*nb_inplace_multiply*/
 
9445
  #if PY_MAJOR_VERSION < 3
 
9446
  0, /*nb_inplace_divide*/
 
9447
  #endif
 
9448
  0, /*nb_inplace_remainder*/
 
9449
  0, /*nb_inplace_power*/
 
9450
  0, /*nb_inplace_lshift*/
 
9451
  0, /*nb_inplace_rshift*/
 
9452
  0, /*nb_inplace_and*/
 
9453
  0, /*nb_inplace_xor*/
 
9454
  0, /*nb_inplace_or*/
 
9455
  0, /*nb_floor_divide*/
 
9456
  0, /*nb_true_divide*/
 
9457
  0, /*nb_inplace_floor_divide*/
 
9458
  0, /*nb_inplace_true_divide*/
 
9459
  #if PY_VERSION_HEX >= 0x02050000
 
9460
  0, /*nb_index*/
 
9461
  #endif
 
9462
};
 
9463
 
 
9464
static PySequenceMethods __pyx_tp_as_sequence__MergeSortNode = {
 
9465
  0, /*sq_length*/
 
9466
  0, /*sq_concat*/
 
9467
  0, /*sq_repeat*/
 
9468
  0, /*sq_item*/
 
9469
  0, /*sq_slice*/
 
9470
  0, /*sq_ass_item*/
 
9471
  0, /*sq_ass_slice*/
 
9472
  0, /*sq_contains*/
 
9473
  0, /*sq_inplace_concat*/
 
9474
  0, /*sq_inplace_repeat*/
 
9475
};
 
9476
 
 
9477
static PyMappingMethods __pyx_tp_as_mapping__MergeSortNode = {
 
9478
  0, /*mp_length*/
 
9479
  0, /*mp_subscript*/
 
9480
  0, /*mp_ass_subscript*/
 
9481
};
 
9482
 
 
9483
static PyBufferProcs __pyx_tp_as_buffer__MergeSortNode = {
 
9484
  #if PY_MAJOR_VERSION < 3
 
9485
  0, /*bf_getreadbuffer*/
 
9486
  #endif
 
9487
  #if PY_MAJOR_VERSION < 3
 
9488
  0, /*bf_getwritebuffer*/
 
9489
  #endif
 
9490
  #if PY_MAJOR_VERSION < 3
 
9491
  0, /*bf_getsegcount*/
 
9492
  #endif
 
9493
  #if PY_MAJOR_VERSION < 3
 
9494
  0, /*bf_getcharbuffer*/
 
9495
  #endif
 
9496
  #if PY_VERSION_HEX >= 0x02060000
 
9497
  0, /*bf_getbuffer*/
 
9498
  #endif
 
9499
  #if PY_VERSION_HEX >= 0x02060000
 
9500
  0, /*bf_releasebuffer*/
 
9501
  #endif
 
9502
};
 
9503
 
 
9504
static PyTypeObject __pyx_type_6bzrlib_16_known_graph_pyx__MergeSortNode = {
 
9505
  PyVarObject_HEAD_INIT(0, 0)
 
9506
  __Pyx_NAMESTR("bzrlib._known_graph_pyx._MergeSortNode"), /*tp_name*/
 
9507
  sizeof(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode), /*tp_basicsize*/
 
9508
  0, /*tp_itemsize*/
 
9509
  __pyx_tp_dealloc_6bzrlib_16_known_graph_pyx__MergeSortNode, /*tp_dealloc*/
 
9510
  0, /*tp_print*/
 
9511
  0, /*tp_getattr*/
 
9512
  0, /*tp_setattr*/
 
9513
  #if PY_MAJOR_VERSION < 3
 
9514
  0, /*tp_compare*/
 
9515
  #else
 
9516
  0, /*reserved*/
 
9517
  #endif
 
9518
  __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode_1__repr__, /*tp_repr*/
 
9519
  &__pyx_tp_as_number__MergeSortNode, /*tp_as_number*/
 
9520
  &__pyx_tp_as_sequence__MergeSortNode, /*tp_as_sequence*/
 
9521
  &__pyx_tp_as_mapping__MergeSortNode, /*tp_as_mapping*/
 
9522
  0, /*tp_hash*/
 
9523
  0, /*tp_call*/
 
9524
  0, /*tp_str*/
 
9525
  0, /*tp_getattro*/
 
9526
  0, /*tp_setattro*/
 
9527
  &__pyx_tp_as_buffer__MergeSortNode, /*tp_as_buffer*/
 
9528
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
 
9529
  __Pyx_DOCSTR("Tracks information about a node during the merge_sort operation."), /*tp_doc*/
 
9530
  __pyx_tp_traverse_6bzrlib_16_known_graph_pyx__MergeSortNode, /*tp_traverse*/
 
9531
  __pyx_tp_clear_6bzrlib_16_known_graph_pyx__MergeSortNode, /*tp_clear*/
 
9532
  0, /*tp_richcompare*/
 
9533
  0, /*tp_weaklistoffset*/
 
9534
  0, /*tp_iter*/
 
9535
  0, /*tp_iternext*/
 
9536
  __pyx_methods_6bzrlib_16_known_graph_pyx__MergeSortNode, /*tp_methods*/
 
9537
  0, /*tp_members*/
 
9538
  __pyx_getsets_6bzrlib_16_known_graph_pyx__MergeSortNode, /*tp_getset*/
 
9539
  0, /*tp_base*/
 
9540
  0, /*tp_dict*/
 
9541
  0, /*tp_descr_get*/
 
9542
  0, /*tp_descr_set*/
 
9543
  0, /*tp_dictoffset*/
 
9544
  __pyx_pf_6bzrlib_16_known_graph_pyx_14_MergeSortNode___init__, /*tp_init*/
 
9545
  0, /*tp_alloc*/
 
9546
  __pyx_tp_new_6bzrlib_16_known_graph_pyx__MergeSortNode, /*tp_new*/
 
9547
  0, /*tp_free*/
 
9548
  0, /*tp_is_gc*/
 
9549
  0, /*tp_bases*/
 
9550
  0, /*tp_mro*/
 
9551
  0, /*tp_cache*/
 
9552
  0, /*tp_subclasses*/
 
9553
  0, /*tp_weaklist*/
 
9554
  0, /*tp_del*/
 
9555
  #if PY_VERSION_HEX >= 0x02060000
 
9556
  0, /*tp_version_tag*/
 
9557
  #endif
 
9558
};
 
9559
 
 
9560
static PyMethodDef __pyx_methods[] = {
 
9561
  {0, 0, 0, 0}
 
9562
};
 
9563
 
 
9564
#if PY_MAJOR_VERSION >= 3
 
9565
static struct PyModuleDef __pyx_moduledef = {
 
9566
    PyModuleDef_HEAD_INIT,
 
9567
    __Pyx_NAMESTR("_known_graph_pyx"),
 
9568
    __Pyx_DOCSTR(__pyx_k_14), /* m_doc */
 
9569
    -1, /* m_size */
 
9570
    __pyx_methods /* m_methods */,
 
9571
    NULL, /* m_reload */
 
9572
    NULL, /* m_traverse */
 
9573
    NULL, /* m_clear */
 
9574
    NULL /* m_free */
 
9575
};
 
9576
#endif
 
9577
 
 
9578
static __Pyx_StringTabEntry __pyx_string_tab[] = {
 
9579
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
 
9580
  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
 
9581
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
 
9582
  {&__pyx_n_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 1},
 
9583
  {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
 
9584
  {&__pyx_n_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 1},
 
9585
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
 
9586
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
 
9587
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
 
9588
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
 
9589
  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
 
9590
  {&__pyx_n_s__GraphCycleError, __pyx_k__GraphCycleError, sizeof(__pyx_k__GraphCycleError), 0, 0, 1, 1},
 
9591
  {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
 
9592
  {&__pyx_n_s__NULL_REVISION, __pyx_k__NULL_REVISION, sizeof(__pyx_k__NULL_REVISION), 0, 0, 1, 1},
 
9593
  {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
 
9594
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
 
9595
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
 
9596
  {&__pyx_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1},
 
9597
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
 
9598
  {&__pyx_n_s____name__, __pyx_k____name__, sizeof(__pyx_k____name__), 0, 0, 1, 1},
 
9599
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
 
9600
  {&__pyx_n_s___depth_first_stack, __pyx_k___depth_first_stack, sizeof(__pyx_k___depth_first_stack), 0, 0, 1, 1},
 
9601
  {&__pyx_n_s___find_gdfo, __pyx_k___find_gdfo, sizeof(__pyx_k___find_gdfo), 0, 0, 1, 1},
 
9602
  {&__pyx_n_s___find_tails, __pyx_k___find_tails, sizeof(__pyx_k___find_tails), 0, 0, 1, 1},
 
9603
  {&__pyx_n_s___find_tips, __pyx_k___find_tips, sizeof(__pyx_k___find_tips), 0, 0, 1, 1},
 
9604
  {&__pyx_n_s___get_ms_node, __pyx_k___get_ms_node, sizeof(__pyx_k___get_ms_node), 0, 0, 1, 1},
 
9605
  {&__pyx_n_s___get_or_create_node, __pyx_k___get_or_create_node, sizeof(__pyx_k___get_or_create_node), 0, 0, 1, 1},
 
9606
  {&__pyx_n_s___initialize_nodes, __pyx_k___initialize_nodes, sizeof(__pyx_k___initialize_nodes), 0, 0, 1, 1},
 
9607
  {&__pyx_n_s___known_heads, __pyx_k___known_heads, sizeof(__pyx_k___known_heads), 0, 0, 1, 1},
 
9608
  {&__pyx_n_s___last_stack_item, __pyx_k___last_stack_item, sizeof(__pyx_k___last_stack_item), 0, 0, 1, 1},
 
9609
  {&__pyx_n_s___nodes, __pyx_k___nodes, sizeof(__pyx_k___nodes), 0, 0, 1, 1},
 
9610
  {&__pyx_n_s___pop_node, __pyx_k___pop_node, sizeof(__pyx_k___pop_node), 0, 0, 1, 1},
 
9611
  {&__pyx_n_s___populate_parents, __pyx_k___populate_parents, sizeof(__pyx_k___populate_parents), 0, 0, 1, 1},
 
9612
  {&__pyx_n_s___push_node, __pyx_k___push_node, sizeof(__pyx_k___push_node), 0, 0, 1, 1},
 
9613
  {&__pyx_n_s___revno, __pyx_k___revno, sizeof(__pyx_k___revno), 0, 0, 1, 1},
 
9614
  {&__pyx_n_s___revno_first, __pyx_k___revno_first, sizeof(__pyx_k___revno_first), 0, 0, 1, 1},
 
9615
  {&__pyx_n_s___revno_last, __pyx_k___revno_last, sizeof(__pyx_k___revno_last), 0, 0, 1, 1},
 
9616
  {&__pyx_n_s___revno_second, __pyx_k___revno_second, sizeof(__pyx_k___revno_second), 0, 0, 1, 1},
 
9617
  {&__pyx_n_s___schedule_stack, __pyx_k___schedule_stack, sizeof(__pyx_k___schedule_stack), 0, 0, 1, 1},
 
9618
  {&__pyx_n_s___scheduled_nodes, __pyx_k___scheduled_nodes, sizeof(__pyx_k___scheduled_nodes), 0, 0, 1, 1},
 
9619
  {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1},
 
9620
  {&__pyx_n_s__bzrlib, __pyx_k__bzrlib, sizeof(__pyx_k__bzrlib), 0, 0, 1, 1},
 
9621
  {&__pyx_n_s__child_keys, __pyx_k__child_keys, sizeof(__pyx_k__child_keys), 0, 0, 1, 1},
 
9622
  {&__pyx_n_s__children, __pyx_k__children, sizeof(__pyx_k__children), 0, 0, 1, 1},
 
9623
  {&__pyx_n_s__clear, __pyx_k__clear, sizeof(__pyx_k__clear), 0, 0, 1, 1},
 
9624
  {&__pyx_n_s__clear_references, __pyx_k__clear_references, sizeof(__pyx_k__clear_references), 0, 0, 1, 1},
 
9625
  {&__pyx_n_s__collections, __pyx_k__collections, sizeof(__pyx_k__collections), 0, 0, 1, 1},
 
9626
  {&__pyx_n_s__completed, __pyx_k__completed, sizeof(__pyx_k__completed), 0, 0, 1, 1},
 
9627
  {&__pyx_n_s__deque, __pyx_k__deque, sizeof(__pyx_k__deque), 0, 0, 1, 1},
 
9628
  {&__pyx_n_s__do_cache, __pyx_k__do_cache, sizeof(__pyx_k__do_cache), 0, 0, 1, 1},
 
9629
  {&__pyx_n_s__end_of_merge, __pyx_k__end_of_merge, sizeof(__pyx_k__end_of_merge), 0, 0, 1, 1},
 
9630
  {&__pyx_n_s__errors, __pyx_k__errors, sizeof(__pyx_k__errors), 0, 0, 1, 1},
 
9631
  {&__pyx_n_s__extend, __pyx_k__extend, sizeof(__pyx_k__extend), 0, 0, 1, 1},
 
9632
  {&__pyx_n_s__extra, __pyx_k__extra, sizeof(__pyx_k__extra), 0, 0, 1, 1},
 
9633
  {&__pyx_n_s__gc, __pyx_k__gc, sizeof(__pyx_k__gc), 0, 0, 1, 1},
 
9634
  {&__pyx_n_s__gdfo, __pyx_k__gdfo, sizeof(__pyx_k__gdfo), 0, 0, 1, 1},
 
9635
  {&__pyx_n_s__get_key, __pyx_k__get_key, sizeof(__pyx_k__get_key), 0, 0, 1, 1},
 
9636
  {&__pyx_n_s__graph, __pyx_k__graph, sizeof(__pyx_k__graph), 0, 0, 1, 1},
 
9637
  {&__pyx_n_s__has_pending_parents, __pyx_k__has_pending_parents, sizeof(__pyx_k__has_pending_parents), 0, 0, 1, 1},
 
9638
  {&__pyx_n_s__is_first_child, __pyx_k__is_first_child, sizeof(__pyx_k__is_first_child), 0, 0, 1, 1},
 
9639
  {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1},
 
9640
  {&__pyx_n_s__known_graph, __pyx_k__known_graph, sizeof(__pyx_k__known_graph), 0, 0, 1, 1},
 
9641
  {&__pyx_n_s__left_parent, __pyx_k__left_parent, sizeof(__pyx_k__left_parent), 0, 0, 1, 1},
 
9642
  {&__pyx_n_s__left_pending_parent, __pyx_k__left_pending_parent, sizeof(__pyx_k__left_pending_parent), 0, 0, 1, 1},
 
9643
  {&__pyx_n_s__merge_depth, __pyx_k__merge_depth, sizeof(__pyx_k__merge_depth), 0, 0, 1, 1},
 
9644
  {&__pyx_n_s__parent_keys, __pyx_k__parent_keys, sizeof(__pyx_k__parent_keys), 0, 0, 1, 1},
 
9645
  {&__pyx_n_s__parent_map, __pyx_k__parent_map, sizeof(__pyx_k__parent_map), 0, 0, 1, 1},
 
9646
  {&__pyx_n_s__parents, __pyx_k__parents, sizeof(__pyx_k__parents), 0, 0, 1, 1},
 
9647
  {&__pyx_n_s__pending_parents, __pyx_k__pending_parents, sizeof(__pyx_k__pending_parents), 0, 0, 1, 1},
 
9648
  {&__pyx_n_s__pop, __pyx_k__pop, sizeof(__pyx_k__pop), 0, 0, 1, 1},
 
9649
  {&__pyx_n_s__popleft, __pyx_k__popleft, sizeof(__pyx_k__popleft), 0, 0, 1, 1},
 
9650
  {&__pyx_n_s__reverse, __pyx_k__reverse, sizeof(__pyx_k__reverse), 0, 0, 1, 1},
 
9651
  {&__pyx_n_s__revision, __pyx_k__revision, sizeof(__pyx_k__revision), 0, 0, 1, 1},
 
9652
  {&__pyx_n_s__seen, __pyx_k__seen, sizeof(__pyx_k__seen), 0, 0, 1, 1},
 
9653
  {&__pyx_n_s__seen_by_child, __pyx_k__seen_by_child, sizeof(__pyx_k__seen_by_child), 0, 0, 1, 1},
 
9654
  {&__pyx_n_s__sort, __pyx_k__sort, sizeof(__pyx_k__sort), 0, 0, 1, 1},
 
9655
  {&__pyx_n_s__sorted, __pyx_k__sorted, sizeof(__pyx_k__sorted), 0, 0, 1, 1},
 
9656
  {&__pyx_n_s__tip_key, __pyx_k__tip_key, sizeof(__pyx_k__tip_key), 0, 0, 1, 1},
 
9657
  {&__pyx_n_s__topo_order, __pyx_k__topo_order, sizeof(__pyx_k__topo_order), 0, 0, 1, 1},
 
9658
  {0, 0, 0, 0, 0, 0, 0}
 
9659
};
 
9660
static int __Pyx_InitCachedBuiltins(void) {
 
9661
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9662
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9663
  __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9664
  __pyx_builtin_sorted = __Pyx_GetName(__pyx_b, __pyx_n_s__sorted); if (!__pyx_builtin_sorted) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9665
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9666
  return 0;
 
9667
  __pyx_L1_error:;
 
9668
  return -1;
 
9669
}
 
9670
 
 
9671
static int __Pyx_InitCachedConstants(void) {
 
9672
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");
 
9673
 
 
9674
  /* "bzrlib/_known_graph_pyx.pyx":156
 
9675
 *     is_tuple = PyTuple_CheckExact(lst_or_tpl)
 
9676
 *     if not (is_tuple or PyList_CheckExact(lst_or_tpl)):
 
9677
 *         raise TypeError('lst_or_tpl must be a list or tuple.')             # <<<<<<<<<<<<<<
 
9678
 *     length = len(lst_or_tpl)
 
9679
 *     if length == 0 or length == 1:
 
9680
 */
 
9681
  __pyx_k_tuple_3 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9682
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_3));
 
9683
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
 
9684
  PyTuple_SET_ITEM(__pyx_k_tuple_3, 0, ((PyObject *)__pyx_kp_s_2));
 
9685
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
 
9686
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_3));
 
9687
 
 
9688
  /* "bzrlib/_known_graph_pyx.pyx":273
 
9689
 * 
 
9690
 *         if not PyDict_CheckExact(parent_map):
 
9691
 *             raise TypeError('parent_map should be a dict of {key:parent_keys}')             # <<<<<<<<<<<<<<
 
9692
 *         # for key, parent_keys in parent_map.iteritems():
 
9693
 *         pos = 0
 
9694
 */
 
9695
  __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9696
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_6));
 
9697
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
 
9698
  PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_kp_s_5));
 
9699
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
 
9700
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6));
 
9701
  __Pyx_RefNannyFinishContext();
 
9702
  return 0;
 
9703
  __pyx_L1_error:;
 
9704
  __Pyx_RefNannyFinishContext();
 
9705
  return -1;
 
9706
}
 
9707
 
 
9708
static int __Pyx_InitGlobals(void) {
 
9709
  #if PY_VERSION_HEX < 0x02040000
 
9710
  if (unlikely(__Pyx_Py23SetsImport() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9711
  #endif
 
9712
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
9713
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
9714
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
9715
  return 0;
 
9716
  __pyx_L1_error:;
 
9717
  return -1;
 
9718
}
 
9719
 
 
9720
#if PY_MAJOR_VERSION < 3
 
9721
PyMODINIT_FUNC init_known_graph_pyx(void); /*proto*/
 
9722
PyMODINIT_FUNC init_known_graph_pyx(void)
 
9723
#else
 
9724
PyMODINIT_FUNC PyInit__known_graph_pyx(void); /*proto*/
 
9725
PyMODINIT_FUNC PyInit__known_graph_pyx(void)
 
9726
#endif
 
9727
{
 
9728
  PyObject *__pyx_t_1 = NULL;
 
9729
  PyObject *__pyx_t_2 = NULL;
 
9730
  #if CYTHON_REFNANNY
 
9731
  void* __pyx_refnanny = NULL;
 
9732
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
 
9733
  if (!__Pyx_RefNanny) {
 
9734
      PyErr_Clear();
 
9735
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
 
9736
      if (!__Pyx_RefNanny)
 
9737
          Py_FatalError("failed to import 'refnanny' module");
 
9738
  }
 
9739
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit__known_graph_pyx(void)", __LINE__, __FILE__);
 
9740
  #endif
 
9741
  __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;}
 
9742
  __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;}
 
9743
  #ifdef __pyx_binding_PyCFunctionType_USED
 
9744
  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9745
  #endif
 
9746
  /*--- Library function declarations ---*/
 
9747
  /*--- Threads initialization code ---*/
 
9748
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
 
9749
  #ifdef WITH_THREAD /* Python build with threading support? */
 
9750
  PyEval_InitThreads();
 
9751
  #endif
 
9752
  #endif
 
9753
  /*--- Module creation code ---*/
 
9754
  #if PY_MAJOR_VERSION < 3
 
9755
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_known_graph_pyx"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_14), 0, PYTHON_API_VERSION);
 
9756
  #else
 
9757
  __pyx_m = PyModule_Create(&__pyx_moduledef);
 
9758
  #endif
 
9759
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
9760
  #if PY_MAJOR_VERSION < 3
 
9761
  Py_INCREF(__pyx_m);
 
9762
  #endif
 
9763
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
 
9764
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
9765
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
9766
  /*--- Initialize various global constants etc. ---*/
 
9767
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9768
  if (__pyx_module_is_main_bzrlib___known_graph_pyx) {
 
9769
    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;};
 
9770
  }
 
9771
  /*--- Builtin init code ---*/
 
9772
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9773
  /*--- Constants init code ---*/
 
9774
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9775
  /*--- Global init code ---*/
 
9776
  __pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION = Py_None; Py_INCREF(Py_None);
 
9777
  /*--- Function export code ---*/
 
9778
  /*--- Type init code ---*/
 
9779
  __pyx_vtabptr_6bzrlib_16_known_graph_pyx__KnownGraphNode = &__pyx_vtable_6bzrlib_16_known_graph_pyx__KnownGraphNode;
 
9780
  __pyx_vtable_6bzrlib_16_known_graph_pyx__KnownGraphNode.clear_references = (PyObject *(*)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *))__pyx_f_6bzrlib_16_known_graph_pyx_15_KnownGraphNode_clear_references;
 
9781
  if (PyType_Ready(&__pyx_type_6bzrlib_16_known_graph_pyx__KnownGraphNode) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9782
  if (__Pyx_SetVtable(__pyx_type_6bzrlib_16_known_graph_pyx__KnownGraphNode.tp_dict, __pyx_vtabptr_6bzrlib_16_known_graph_pyx__KnownGraphNode) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9783
  if (__Pyx_SetAttrString(__pyx_m, "_KnownGraphNode", (PyObject *)&__pyx_type_6bzrlib_16_known_graph_pyx__KnownGraphNode) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9784
  __pyx_ptype_6bzrlib_16_known_graph_pyx__KnownGraphNode = &__pyx_type_6bzrlib_16_known_graph_pyx__KnownGraphNode;
 
9785
  __pyx_vtabptr_6bzrlib_16_known_graph_pyx__MergeSorter = &__pyx_vtable_6bzrlib_16_known_graph_pyx__MergeSorter;
 
9786
  __pyx_vtable_6bzrlib_16_known_graph_pyx__MergeSorter._get_ms_node = (struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *(*)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *, struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *))__pyx_f_6bzrlib_16_known_graph_pyx_12_MergeSorter__get_ms_node;
 
9787
  __pyx_vtable_6bzrlib_16_known_graph_pyx__MergeSorter._push_node = (PyObject *(*)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *, struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *, long))__pyx_f_6bzrlib_16_known_graph_pyx_12_MergeSorter__push_node;
 
9788
  __pyx_vtable_6bzrlib_16_known_graph_pyx__MergeSorter._pop_node = (PyObject *(*)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *))__pyx_f_6bzrlib_16_known_graph_pyx_12_MergeSorter__pop_node;
 
9789
  __pyx_vtable_6bzrlib_16_known_graph_pyx__MergeSorter._schedule_stack = (PyObject *(*)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *))__pyx_f_6bzrlib_16_known_graph_pyx_12_MergeSorter__schedule_stack;
 
9790
  __pyx_vtable_6bzrlib_16_known_graph_pyx__MergeSorter.topo_order = (PyObject *(*)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSorter *))__pyx_f_6bzrlib_16_known_graph_pyx_12_MergeSorter_topo_order;
 
9791
  if (PyType_Ready(&__pyx_type_6bzrlib_16_known_graph_pyx__MergeSorter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9792
  if (__Pyx_SetVtable(__pyx_type_6bzrlib_16_known_graph_pyx__MergeSorter.tp_dict, __pyx_vtabptr_6bzrlib_16_known_graph_pyx__MergeSorter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9793
  if (__Pyx_SetAttrString(__pyx_m, "_MergeSorter", (PyObject *)&__pyx_type_6bzrlib_16_known_graph_pyx__MergeSorter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9794
  __pyx_ptype_6bzrlib_16_known_graph_pyx__MergeSorter = &__pyx_type_6bzrlib_16_known_graph_pyx__MergeSorter;
 
9795
  __pyx_vtabptr_6bzrlib_16_known_graph_pyx_KnownGraph = &__pyx_vtable_6bzrlib_16_known_graph_pyx_KnownGraph;
 
9796
  __pyx_vtable_6bzrlib_16_known_graph_pyx_KnownGraph._get_or_create_node = (struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *(*)(struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *, PyObject *))__pyx_f_6bzrlib_16_known_graph_pyx_10KnownGraph__get_or_create_node;
 
9797
  __pyx_vtable_6bzrlib_16_known_graph_pyx_KnownGraph._populate_parents = (PyObject *(*)(struct __pyx_obj_6bzrlib_16_known_graph_pyx_KnownGraph *, struct __pyx_obj_6bzrlib_16_known_graph_pyx__KnownGraphNode *, PyObject *))__pyx_f_6bzrlib_16_known_graph_pyx_10KnownGraph__populate_parents;
 
9798
  if (PyType_Ready(&__pyx_type_6bzrlib_16_known_graph_pyx_KnownGraph) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9799
  {
 
9800
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6bzrlib_16_known_graph_pyx_KnownGraph, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9801
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
 
9802
      __pyx_wrapperbase_6bzrlib_16_known_graph_pyx_10KnownGraph___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
 
9803
      __pyx_wrapperbase_6bzrlib_16_known_graph_pyx_10KnownGraph___init__.doc = __pyx_doc_6bzrlib_16_known_graph_pyx_10KnownGraph___init__;
 
9804
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6bzrlib_16_known_graph_pyx_10KnownGraph___init__;
 
9805
    }
 
9806
  }
 
9807
  if (__Pyx_SetVtable(__pyx_type_6bzrlib_16_known_graph_pyx_KnownGraph.tp_dict, __pyx_vtabptr_6bzrlib_16_known_graph_pyx_KnownGraph) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9808
  if (__Pyx_SetAttrString(__pyx_m, "KnownGraph", (PyObject *)&__pyx_type_6bzrlib_16_known_graph_pyx_KnownGraph) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9809
  __pyx_ptype_6bzrlib_16_known_graph_pyx_KnownGraph = &__pyx_type_6bzrlib_16_known_graph_pyx_KnownGraph;
 
9810
  __pyx_vtabptr_6bzrlib_16_known_graph_pyx__MergeSortNode = &__pyx_vtable_6bzrlib_16_known_graph_pyx__MergeSortNode;
 
9811
  __pyx_vtable_6bzrlib_16_known_graph_pyx__MergeSortNode.has_pending_parents = (int (*)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *))__pyx_f_6bzrlib_16_known_graph_pyx_14_MergeSortNode_has_pending_parents;
 
9812
  __pyx_vtable_6bzrlib_16_known_graph_pyx__MergeSortNode._revno = (PyObject *(*)(struct __pyx_obj_6bzrlib_16_known_graph_pyx__MergeSortNode *))__pyx_f_6bzrlib_16_known_graph_pyx_14_MergeSortNode__revno;
 
9813
  if (PyType_Ready(&__pyx_type_6bzrlib_16_known_graph_pyx__MergeSortNode) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9814
  if (__Pyx_SetVtable(__pyx_type_6bzrlib_16_known_graph_pyx__MergeSortNode.tp_dict, __pyx_vtabptr_6bzrlib_16_known_graph_pyx__MergeSortNode) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9815
  if (__Pyx_SetAttrString(__pyx_m, "_MergeSortNode", (PyObject *)&__pyx_type_6bzrlib_16_known_graph_pyx__MergeSortNode) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9816
  __pyx_ptype_6bzrlib_16_known_graph_pyx__MergeSortNode = &__pyx_type_6bzrlib_16_known_graph_pyx__MergeSortNode;
 
9817
  /*--- Type import code ---*/
 
9818
  /*--- Function import code ---*/
 
9819
  /*--- Execution code ---*/
 
9820
 
 
9821
  /* "bzrlib/_known_graph_pyx.pyx":54
 
9822
 *     void Py_INCREF(object)
 
9823
 * 
 
9824
 * from collections import deque             # <<<<<<<<<<<<<<
 
9825
 * import gc
 
9826
 * 
 
9827
 */
 
9828
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9829
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
9830
  __Pyx_INCREF(((PyObject *)__pyx_n_s__deque));
 
9831
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__deque));
 
9832
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__deque));
 
9833
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__collections), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9834
  __Pyx_GOTREF(__pyx_t_2);
 
9835
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
9836
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__deque); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9837
  __Pyx_GOTREF(__pyx_t_1);
 
9838
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__deque, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9839
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
9840
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
9841
 
 
9842
  /* "bzrlib/_known_graph_pyx.pyx":55
 
9843
 * 
 
9844
 * from collections import deque
 
9845
 * import gc             # <<<<<<<<<<<<<<
 
9846
 * 
 
9847
 * from bzrlib import errors, revision
 
9848
 */
 
9849
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__gc), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9850
  __Pyx_GOTREF(__pyx_t_2);
 
9851
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__gc, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9852
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
9853
 
 
9854
  /* "bzrlib/_known_graph_pyx.pyx":57
 
9855
 * import gc
 
9856
 * 
 
9857
 * from bzrlib import errors, revision             # <<<<<<<<<<<<<<
 
9858
 * 
 
9859
 * cdef object NULL_REVISION
 
9860
 */
 
9861
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9862
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
9863
  __Pyx_INCREF(((PyObject *)__pyx_n_s__errors));
 
9864
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__errors));
 
9865
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__errors));
 
9866
  __Pyx_INCREF(((PyObject *)__pyx_n_s__revision));
 
9867
  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__revision));
 
9868
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__revision));
 
9869
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__bzrlib), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9870
  __Pyx_GOTREF(__pyx_t_1);
 
9871
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
9872
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__errors); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9873
  __Pyx_GOTREF(__pyx_t_2);
 
9874
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__errors, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9875
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
9876
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__revision); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9877
  __Pyx_GOTREF(__pyx_t_2);
 
9878
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__revision, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9879
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
9880
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
9881
 
 
9882
  /* "bzrlib/_known_graph_pyx.pyx":60
 
9883
 * 
 
9884
 * cdef object NULL_REVISION
 
9885
 * NULL_REVISION = revision.NULL_REVISION             # <<<<<<<<<<<<<<
 
9886
 * 
 
9887
 * 
 
9888
 */
 
9889
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__revision); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9890
  __Pyx_GOTREF(__pyx_t_1);
 
9891
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__NULL_REVISION); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9892
  __Pyx_GOTREF(__pyx_t_2);
 
9893
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
9894
  __Pyx_GOTREF(__pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
9895
  __Pyx_DECREF(__pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION);
 
9896
  __Pyx_GIVEREF(__pyx_t_2);
 
9897
  __pyx_v_6bzrlib_16_known_graph_pyx_NULL_REVISION = __pyx_t_2;
 
9898
  __pyx_t_2 = 0;
 
9899
 
 
9900
  /* "bzrlib/_known_graph_pyx.pyx":138
 
9901
 * 
 
9902
 * 
 
9903
 * def get_key(node):             # <<<<<<<<<<<<<<
 
9904
 *     cdef _KnownGraphNode real_node
 
9905
 *     real_node = node
 
9906
 */
 
9907
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_16_known_graph_pyx_get_key, NULL, __pyx_n_s_15); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9908
  __Pyx_GOTREF(__pyx_t_2);
 
9909
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__get_key, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9910
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
9911
 
 
9912
  /* "bzrlib/_known_graph_pyx.pyx":199
 
9913
 *     cdef public int do_cache
 
9914
 * 
 
9915
 *     def __init__(self, parent_map, do_cache=True):             # <<<<<<<<<<<<<<
 
9916
 *         """Create a new KnownGraph instance.
 
9917
 * 
 
9918
 */
 
9919
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
9920
  __Pyx_GOTREF(__pyx_t_2);
 
9921
  __pyx_k_4 = __pyx_t_2;
 
9922
  __Pyx_GIVEREF(__pyx_t_2);
 
9923
  __pyx_t_2 = 0;
 
9924
 
 
9925
  /* "bzrlib/_known_graph_pyx.pyx":1
 
9926
 * # Copyright (C) 2009, 2010 Canonical Ltd             # <<<<<<<<<<<<<<
 
9927
 * #
 
9928
 * # This program is free software; you can redistribute it and/or modify
 
9929
 */
 
9930
  __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;}
 
9931
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
9932
  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;}
 
9933
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
9934
  goto __pyx_L0;
 
9935
  __pyx_L1_error:;
 
9936
  __Pyx_XDECREF(__pyx_t_1);
 
9937
  __Pyx_XDECREF(__pyx_t_2);
 
9938
  if (__pyx_m) {
 
9939
    __Pyx_AddTraceback("init bzrlib._known_graph_pyx");
 
9940
    Py_DECREF(__pyx_m); __pyx_m = 0;
 
9941
  } else if (!PyErr_Occurred()) {
 
9942
    PyErr_SetString(PyExc_ImportError, "init bzrlib._known_graph_pyx");
 
9943
  }
 
9944
  __pyx_L0:;
 
9945
  __Pyx_RefNannyFinishContext();
 
9946
  #if PY_MAJOR_VERSION < 3
 
9947
  return;
 
9948
  #else
 
9949
  return __pyx_m;
 
9950
  #endif
 
9951
}
 
9952
 
 
9953
/* Runtime support code */
 
9954
 
 
9955
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
 
9956
    PyObject *result;
 
9957
    result = PyObject_GetAttr(dict, name);
 
9958
    if (!result)
 
9959
        PyErr_SetObject(PyExc_NameError, name);
 
9960
    return result;
 
9961
}
 
9962
 
 
9963
static void __Pyx_RaiseDoubleKeywordsError(
 
9964
    const char* func_name,
 
9965
    PyObject* kw_name)
 
9966
{
 
9967
    PyErr_Format(PyExc_TypeError,
 
9968
        #if PY_MAJOR_VERSION >= 3
 
9969
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
 
9970
        #else
 
9971
        "%s() got multiple values for keyword argument '%s'", func_name,
 
9972
        PyString_AS_STRING(kw_name));
 
9973
        #endif
 
9974
}
 
9975
 
 
9976
static int __Pyx_ParseOptionalKeywords(
 
9977
    PyObject *kwds,
 
9978
    PyObject **argnames[],
 
9979
    PyObject *kwds2,
 
9980
    PyObject *values[],
 
9981
    Py_ssize_t num_pos_args,
 
9982
    const char* function_name)
 
9983
{
 
9984
    PyObject *key = 0, *value = 0;
 
9985
    Py_ssize_t pos = 0;
 
9986
    PyObject*** name;
 
9987
    PyObject*** first_kw_arg = argnames + num_pos_args;
 
9988
 
 
9989
    while (PyDict_Next(kwds, &pos, &key, &value)) {
 
9990
        name = first_kw_arg;
 
9991
        while (*name && (**name != key)) name++;
 
9992
        if (*name) {
 
9993
            values[name-argnames] = value;
 
9994
        } else {
 
9995
            #if PY_MAJOR_VERSION < 3
 
9996
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
 
9997
            #else
 
9998
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
 
9999
            #endif
 
10000
                goto invalid_keyword_type;
 
10001
            } else {
 
10002
                for (name = first_kw_arg; *name; name++) {
 
10003
                    #if PY_MAJOR_VERSION >= 3
 
10004
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
 
10005
                        PyUnicode_Compare(**name, key) == 0) break;
 
10006
                    #else
 
10007
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
 
10008
                        _PyString_Eq(**name, key)) break;
 
10009
                    #endif
 
10010
                }
 
10011
                if (*name) {
 
10012
                    values[name-argnames] = value;
 
10013
                } else {
 
10014
                    /* unexpected keyword found */
 
10015
                    for (name=argnames; name != first_kw_arg; name++) {
 
10016
                        if (**name == key) goto arg_passed_twice;
 
10017
                        #if PY_MAJOR_VERSION >= 3
 
10018
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
 
10019
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
 
10020
                        #else
 
10021
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
 
10022
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
 
10023
                        #endif
 
10024
                    }
 
10025
                    if (kwds2) {
 
10026
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
 
10027
                    } else {
 
10028
                        goto invalid_keyword;
 
10029
                    }
 
10030
                }
 
10031
            }
 
10032
        }
 
10033
    }
 
10034
    return 0;
 
10035
arg_passed_twice:
 
10036
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
 
10037
    goto bad;
 
10038
invalid_keyword_type:
 
10039
    PyErr_Format(PyExc_TypeError,
 
10040
        "%s() keywords must be strings", function_name);
 
10041
    goto bad;
 
10042
invalid_keyword:
 
10043
    PyErr_Format(PyExc_TypeError,
 
10044
    #if PY_MAJOR_VERSION < 3
 
10045
        "%s() got an unexpected keyword argument '%s'",
 
10046
        function_name, PyString_AsString(key));
 
10047
    #else
 
10048
        "%s() got an unexpected keyword argument '%U'",
 
10049
        function_name, key);
 
10050
    #endif
 
10051
bad:
 
10052
    return -1;
 
10053
}
 
10054
 
 
10055
static void __Pyx_RaiseArgtupleInvalid(
 
10056
    const char* func_name,
 
10057
    int exact,
 
10058
    Py_ssize_t num_min,
 
10059
    Py_ssize_t num_max,
 
10060
    Py_ssize_t num_found)
 
10061
{
 
10062
    Py_ssize_t num_expected;
 
10063
    const char *number, *more_or_less;
 
10064
 
 
10065
    if (num_found < num_min) {
 
10066
        num_expected = num_min;
 
10067
        more_or_less = "at least";
 
10068
    } else {
 
10069
        num_expected = num_max;
 
10070
        more_or_less = "at most";
 
10071
    }
 
10072
    if (exact) {
 
10073
        more_or_less = "exactly";
 
10074
    }
 
10075
    number = (num_expected == 1) ? "" : "s";
 
10076
    PyErr_Format(PyExc_TypeError,
 
10077
        #if PY_VERSION_HEX < 0x02050000
 
10078
            "%s() takes %s %d positional argument%s (%d given)",
 
10079
        #else
 
10080
            "%s() takes %s %zd positional argument%s (%zd given)",
 
10081
        #endif
 
10082
        func_name, more_or_less, num_expected, number, num_found);
 
10083
}
 
10084
 
 
10085
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
 
10086
    if (unlikely(!type)) {
 
10087
        PyErr_Format(PyExc_SystemError, "Missing type object");
 
10088
        return 0;
 
10089
    }
 
10090
    if (likely(PyObject_TypeCheck(obj, type)))
 
10091
        return 1;
 
10092
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
 
10093
                 Py_TYPE(obj)->tp_name, type->tp_name);
 
10094
    return 0;
 
10095
}
 
10096
 
 
10097
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
 
10098
    PyObject *tmp_type, *tmp_value, *tmp_tb;
 
10099
    PyThreadState *tstate = PyThreadState_GET();
 
10100
 
 
10101
    tmp_type = tstate->curexc_type;
 
10102
    tmp_value = tstate->curexc_value;
 
10103
    tmp_tb = tstate->curexc_traceback;
 
10104
    tstate->curexc_type = type;
 
10105
    tstate->curexc_value = value;
 
10106
    tstate->curexc_traceback = tb;
 
10107
    Py_XDECREF(tmp_type);
 
10108
    Py_XDECREF(tmp_value);
 
10109
    Py_XDECREF(tmp_tb);
 
10110
}
 
10111
 
 
10112
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
 
10113
    PyThreadState *tstate = PyThreadState_GET();
 
10114
    *type = tstate->curexc_type;
 
10115
    *value = tstate->curexc_value;
 
10116
    *tb = tstate->curexc_traceback;
 
10117
 
 
10118
    tstate->curexc_type = 0;
 
10119
    tstate->curexc_value = 0;
 
10120
    tstate->curexc_traceback = 0;
 
10121
}
 
10122
 
 
10123
 
 
10124
#if PY_MAJOR_VERSION < 3
 
10125
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
 
10126
    Py_XINCREF(type);
 
10127
    Py_XINCREF(value);
 
10128
    Py_XINCREF(tb);
 
10129
    /* First, check the traceback argument, replacing None with NULL. */
 
10130
    if (tb == Py_None) {
 
10131
        Py_DECREF(tb);
 
10132
        tb = 0;
 
10133
    }
 
10134
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
 
10135
        PyErr_SetString(PyExc_TypeError,
 
10136
            "raise: arg 3 must be a traceback or None");
 
10137
        goto raise_error;
 
10138
    }
 
10139
    /* Next, replace a missing value with None */
 
10140
    if (value == NULL) {
 
10141
        value = Py_None;
 
10142
        Py_INCREF(value);
 
10143
    }
 
10144
    #if PY_VERSION_HEX < 0x02050000
 
10145
    if (!PyClass_Check(type))
 
10146
    #else
 
10147
    if (!PyType_Check(type))
 
10148
    #endif
 
10149
    {
 
10150
        /* Raising an instance.  The value should be a dummy. */
 
10151
        if (value != Py_None) {
 
10152
            PyErr_SetString(PyExc_TypeError,
 
10153
                "instance exception may not have a separate value");
 
10154
            goto raise_error;
 
10155
        }
 
10156
        /* Normalize to raise <class>, <instance> */
 
10157
        Py_DECREF(value);
 
10158
        value = type;
 
10159
        #if PY_VERSION_HEX < 0x02050000
 
10160
            if (PyInstance_Check(type)) {
 
10161
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
 
10162
                Py_INCREF(type);
 
10163
            }
 
10164
            else {
 
10165
                type = 0;
 
10166
                PyErr_SetString(PyExc_TypeError,
 
10167
                    "raise: exception must be an old-style class or instance");
 
10168
                goto raise_error;
 
10169
            }
 
10170
        #else
 
10171
            type = (PyObject*) Py_TYPE(type);
 
10172
            Py_INCREF(type);
 
10173
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
 
10174
                PyErr_SetString(PyExc_TypeError,
 
10175
                    "raise: exception class must be a subclass of BaseException");
 
10176
                goto raise_error;
 
10177
            }
 
10178
        #endif
 
10179
    }
 
10180
 
 
10181
    __Pyx_ErrRestore(type, value, tb);
 
10182
    return;
 
10183
raise_error:
 
10184
    Py_XDECREF(value);
 
10185
    Py_XDECREF(type);
 
10186
    Py_XDECREF(tb);
 
10187
    return;
 
10188
}
 
10189
 
 
10190
#else /* Python 3+ */
 
10191
 
 
10192
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
 
10193
    if (tb == Py_None) {
 
10194
        tb = 0;
 
10195
    } else if (tb && !PyTraceBack_Check(tb)) {
 
10196
        PyErr_SetString(PyExc_TypeError,
 
10197
            "raise: arg 3 must be a traceback or None");
 
10198
        goto bad;
 
10199
    }
 
10200
    if (value == Py_None)
 
10201
        value = 0;
 
10202
 
 
10203
    if (PyExceptionInstance_Check(type)) {
 
10204
        if (value) {
 
10205
            PyErr_SetString(PyExc_TypeError,
 
10206
                "instance exception may not have a separate value");
 
10207
            goto bad;
 
10208
        }
 
10209
        value = type;
 
10210
        type = (PyObject*) Py_TYPE(value);
 
10211
    } else if (!PyExceptionClass_Check(type)) {
 
10212
        PyErr_SetString(PyExc_TypeError,
 
10213
            "raise: exception class must be a subclass of BaseException");
 
10214
        goto bad;
 
10215
    }
 
10216
 
 
10217
    PyErr_SetObject(type, value);
 
10218
 
 
10219
    if (tb) {
 
10220
        PyThreadState *tstate = PyThreadState_GET();
 
10221
        PyObject* tmp_tb = tstate->curexc_traceback;
 
10222
        if (tb != tmp_tb) {
 
10223
            Py_INCREF(tb);
 
10224
            tstate->curexc_traceback = tb;
 
10225
            Py_XDECREF(tmp_tb);
 
10226
        }
 
10227
    }
 
10228
 
 
10229
bad:
 
10230
    return;
 
10231
}
 
10232
#endif
 
10233
 
 
10234
 
 
10235
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
 
10236
    PyObject *py_import = 0;
 
10237
    PyObject *empty_list = 0;
 
10238
    PyObject *module = 0;
 
10239
    PyObject *global_dict = 0;
 
10240
    PyObject *empty_dict = 0;
 
10241
    PyObject *list;
 
10242
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
 
10243
    if (!py_import)
 
10244
        goto bad;
 
10245
    if (from_list)
 
10246
        list = from_list;
 
10247
    else {
 
10248
        empty_list = PyList_New(0);
 
10249
        if (!empty_list)
 
10250
            goto bad;
 
10251
        list = empty_list;
 
10252
    }
 
10253
    global_dict = PyModule_GetDict(__pyx_m);
 
10254
    if (!global_dict)
 
10255
        goto bad;
 
10256
    empty_dict = PyDict_New();
 
10257
    if (!empty_dict)
 
10258
        goto bad;
 
10259
    module = PyObject_CallFunctionObjArgs(py_import,
 
10260
        name, global_dict, empty_dict, list, NULL);
 
10261
bad:
 
10262
    Py_XDECREF(empty_list);
 
10263
    Py_XDECREF(py_import);
 
10264
    Py_XDECREF(empty_dict);
 
10265
    return module;
 
10266
}
 
10267
 
 
10268
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
 
10269
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
 
10270
    const int is_unsigned = neg_one > const_zero;
 
10271
    if (sizeof(unsigned char) < sizeof(long)) {
 
10272
        long val = __Pyx_PyInt_AsLong(x);
 
10273
        if (unlikely(val != (long)(unsigned char)val)) {
 
10274
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
10275
                PyErr_SetString(PyExc_OverflowError,
 
10276
                    (is_unsigned && unlikely(val < 0)) ?
 
10277
                    "can't convert negative value to unsigned char" :
 
10278
                    "value too large to convert to unsigned char");
 
10279
            }
 
10280
            return (unsigned char)-1;
 
10281
        }
 
10282
        return (unsigned char)val;
 
10283
    }
 
10284
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
 
10285
}
 
10286
 
 
10287
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
 
10288
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
 
10289
    const int is_unsigned = neg_one > const_zero;
 
10290
    if (sizeof(unsigned short) < sizeof(long)) {
 
10291
        long val = __Pyx_PyInt_AsLong(x);
 
10292
        if (unlikely(val != (long)(unsigned short)val)) {
 
10293
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
10294
                PyErr_SetString(PyExc_OverflowError,
 
10295
                    (is_unsigned && unlikely(val < 0)) ?
 
10296
                    "can't convert negative value to unsigned short" :
 
10297
                    "value too large to convert to unsigned short");
 
10298
            }
 
10299
            return (unsigned short)-1;
 
10300
        }
 
10301
        return (unsigned short)val;
 
10302
    }
 
10303
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
 
10304
}
 
10305
 
 
10306
static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
 
10307
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
 
10308
    const int is_unsigned = neg_one > const_zero;
 
10309
    if (sizeof(unsigned int) < sizeof(long)) {
 
10310
        long val = __Pyx_PyInt_AsLong(x);
 
10311
        if (unlikely(val != (long)(unsigned int)val)) {
 
10312
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
10313
                PyErr_SetString(PyExc_OverflowError,
 
10314
                    (is_unsigned && unlikely(val < 0)) ?
 
10315
                    "can't convert negative value to unsigned int" :
 
10316
                    "value too large to convert to unsigned int");
 
10317
            }
 
10318
            return (unsigned int)-1;
 
10319
        }
 
10320
        return (unsigned int)val;
 
10321
    }
 
10322
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
 
10323
}
 
10324
 
 
10325
static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
 
10326
    const char neg_one = (char)-1, const_zero = 0;
 
10327
    const int is_unsigned = neg_one > const_zero;
 
10328
    if (sizeof(char) < sizeof(long)) {
 
10329
        long val = __Pyx_PyInt_AsLong(x);
 
10330
        if (unlikely(val != (long)(char)val)) {
 
10331
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
10332
                PyErr_SetString(PyExc_OverflowError,
 
10333
                    (is_unsigned && unlikely(val < 0)) ?
 
10334
                    "can't convert negative value to char" :
 
10335
                    "value too large to convert to char");
 
10336
            }
 
10337
            return (char)-1;
 
10338
        }
 
10339
        return (char)val;
 
10340
    }
 
10341
    return (char)__Pyx_PyInt_AsLong(x);
 
10342
}
 
10343
 
 
10344
static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
 
10345
    const short neg_one = (short)-1, const_zero = 0;
 
10346
    const int is_unsigned = neg_one > const_zero;
 
10347
    if (sizeof(short) < sizeof(long)) {
 
10348
        long val = __Pyx_PyInt_AsLong(x);
 
10349
        if (unlikely(val != (long)(short)val)) {
 
10350
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
10351
                PyErr_SetString(PyExc_OverflowError,
 
10352
                    (is_unsigned && unlikely(val < 0)) ?
 
10353
                    "can't convert negative value to short" :
 
10354
                    "value too large to convert to short");
 
10355
            }
 
10356
            return (short)-1;
 
10357
        }
 
10358
        return (short)val;
 
10359
    }
 
10360
    return (short)__Pyx_PyInt_AsLong(x);
 
10361
}
 
10362
 
 
10363
static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
 
10364
    const int neg_one = (int)-1, const_zero = 0;
 
10365
    const int is_unsigned = neg_one > const_zero;
 
10366
    if (sizeof(int) < sizeof(long)) {
 
10367
        long val = __Pyx_PyInt_AsLong(x);
 
10368
        if (unlikely(val != (long)(int)val)) {
 
10369
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
10370
                PyErr_SetString(PyExc_OverflowError,
 
10371
                    (is_unsigned && unlikely(val < 0)) ?
 
10372
                    "can't convert negative value to int" :
 
10373
                    "value too large to convert to int");
 
10374
            }
 
10375
            return (int)-1;
 
10376
        }
 
10377
        return (int)val;
 
10378
    }
 
10379
    return (int)__Pyx_PyInt_AsLong(x);
 
10380
}
 
10381
 
 
10382
static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
 
10383
    const signed char neg_one = (signed char)-1, const_zero = 0;
 
10384
    const int is_unsigned = neg_one > const_zero;
 
10385
    if (sizeof(signed char) < sizeof(long)) {
 
10386
        long val = __Pyx_PyInt_AsLong(x);
 
10387
        if (unlikely(val != (long)(signed char)val)) {
 
10388
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
10389
                PyErr_SetString(PyExc_OverflowError,
 
10390
                    (is_unsigned && unlikely(val < 0)) ?
 
10391
                    "can't convert negative value to signed char" :
 
10392
                    "value too large to convert to signed char");
 
10393
            }
 
10394
            return (signed char)-1;
 
10395
        }
 
10396
        return (signed char)val;
 
10397
    }
 
10398
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
 
10399
}
 
10400
 
 
10401
static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
 
10402
    const signed short neg_one = (signed short)-1, const_zero = 0;
 
10403
    const int is_unsigned = neg_one > const_zero;
 
10404
    if (sizeof(signed short) < sizeof(long)) {
 
10405
        long val = __Pyx_PyInt_AsLong(x);
 
10406
        if (unlikely(val != (long)(signed short)val)) {
 
10407
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
10408
                PyErr_SetString(PyExc_OverflowError,
 
10409
                    (is_unsigned && unlikely(val < 0)) ?
 
10410
                    "can't convert negative value to signed short" :
 
10411
                    "value too large to convert to signed short");
 
10412
            }
 
10413
            return (signed short)-1;
 
10414
        }
 
10415
        return (signed short)val;
 
10416
    }
 
10417
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
 
10418
}
 
10419
 
 
10420
static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
 
10421
    const signed int neg_one = (signed int)-1, const_zero = 0;
 
10422
    const int is_unsigned = neg_one > const_zero;
 
10423
    if (sizeof(signed int) < sizeof(long)) {
 
10424
        long val = __Pyx_PyInt_AsLong(x);
 
10425
        if (unlikely(val != (long)(signed int)val)) {
 
10426
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
10427
                PyErr_SetString(PyExc_OverflowError,
 
10428
                    (is_unsigned && unlikely(val < 0)) ?
 
10429
                    "can't convert negative value to signed int" :
 
10430
                    "value too large to convert to signed int");
 
10431
            }
 
10432
            return (signed int)-1;
 
10433
        }
 
10434
        return (signed int)val;
 
10435
    }
 
10436
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
 
10437
}
 
10438
 
 
10439
static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
 
10440
    const int neg_one = (int)-1, const_zero = 0;
 
10441
    const int is_unsigned = neg_one > const_zero;
 
10442
    if (sizeof(int) < sizeof(long)) {
 
10443
        long val = __Pyx_PyInt_AsLong(x);
 
10444
        if (unlikely(val != (long)(int)val)) {
 
10445
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
10446
                PyErr_SetString(PyExc_OverflowError,
 
10447
                    (is_unsigned && unlikely(val < 0)) ?
 
10448
                    "can't convert negative value to int" :
 
10449
                    "value too large to convert to int");
 
10450
            }
 
10451
            return (int)-1;
 
10452
        }
 
10453
        return (int)val;
 
10454
    }
 
10455
    return (int)__Pyx_PyInt_AsLong(x);
 
10456
}
 
10457
 
 
10458
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
 
10459
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
 
10460
    const int is_unsigned = neg_one > const_zero;
 
10461
#if PY_VERSION_HEX < 0x03000000
 
10462
    if (likely(PyInt_Check(x))) {
 
10463
        long val = PyInt_AS_LONG(x);
 
10464
        if (is_unsigned && unlikely(val < 0)) {
 
10465
            PyErr_SetString(PyExc_OverflowError,
 
10466
                            "can't convert negative value to unsigned long");
 
10467
            return (unsigned long)-1;
 
10468
        }
 
10469
        return (unsigned long)val;
 
10470
    } else
 
10471
#endif
 
10472
    if (likely(PyLong_Check(x))) {
 
10473
        if (is_unsigned) {
 
10474
            if (unlikely(Py_SIZE(x) < 0)) {
 
10475
                PyErr_SetString(PyExc_OverflowError,
 
10476
                                "can't convert negative value to unsigned long");
 
10477
                return (unsigned long)-1;
 
10478
            }
 
10479
            return PyLong_AsUnsignedLong(x);
 
10480
        } else {
 
10481
            return PyLong_AsLong(x);
 
10482
        }
 
10483
    } else {
 
10484
        unsigned long val;
 
10485
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
10486
        if (!tmp) return (unsigned long)-1;
 
10487
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
 
10488
        Py_DECREF(tmp);
 
10489
        return val;
 
10490
    }
 
10491
}
 
10492
 
 
10493
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
 
10494
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
 
10495
    const int is_unsigned = neg_one > const_zero;
 
10496
#if PY_VERSION_HEX < 0x03000000
 
10497
    if (likely(PyInt_Check(x))) {
 
10498
        long val = PyInt_AS_LONG(x);
 
10499
        if (is_unsigned && unlikely(val < 0)) {
 
10500
            PyErr_SetString(PyExc_OverflowError,
 
10501
                            "can't convert negative value to unsigned PY_LONG_LONG");
 
10502
            return (unsigned PY_LONG_LONG)-1;
 
10503
        }
 
10504
        return (unsigned PY_LONG_LONG)val;
 
10505
    } else
 
10506
#endif
 
10507
    if (likely(PyLong_Check(x))) {
 
10508
        if (is_unsigned) {
 
10509
            if (unlikely(Py_SIZE(x) < 0)) {
 
10510
                PyErr_SetString(PyExc_OverflowError,
 
10511
                                "can't convert negative value to unsigned PY_LONG_LONG");
 
10512
                return (unsigned PY_LONG_LONG)-1;
 
10513
            }
 
10514
            return PyLong_AsUnsignedLongLong(x);
 
10515
        } else {
 
10516
            return PyLong_AsLongLong(x);
 
10517
        }
 
10518
    } else {
 
10519
        unsigned PY_LONG_LONG val;
 
10520
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
10521
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
 
10522
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
 
10523
        Py_DECREF(tmp);
 
10524
        return val;
 
10525
    }
 
10526
}
 
10527
 
 
10528
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
 
10529
    const long neg_one = (long)-1, const_zero = 0;
 
10530
    const int is_unsigned = neg_one > const_zero;
 
10531
#if PY_VERSION_HEX < 0x03000000
 
10532
    if (likely(PyInt_Check(x))) {
 
10533
        long val = PyInt_AS_LONG(x);
 
10534
        if (is_unsigned && unlikely(val < 0)) {
 
10535
            PyErr_SetString(PyExc_OverflowError,
 
10536
                            "can't convert negative value to long");
 
10537
            return (long)-1;
 
10538
        }
 
10539
        return (long)val;
 
10540
    } else
 
10541
#endif
 
10542
    if (likely(PyLong_Check(x))) {
 
10543
        if (is_unsigned) {
 
10544
            if (unlikely(Py_SIZE(x) < 0)) {
 
10545
                PyErr_SetString(PyExc_OverflowError,
 
10546
                                "can't convert negative value to long");
 
10547
                return (long)-1;
 
10548
            }
 
10549
            return PyLong_AsUnsignedLong(x);
 
10550
        } else {
 
10551
            return PyLong_AsLong(x);
 
10552
        }
 
10553
    } else {
 
10554
        long val;
 
10555
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
10556
        if (!tmp) return (long)-1;
 
10557
        val = __Pyx_PyInt_AsLong(tmp);
 
10558
        Py_DECREF(tmp);
 
10559
        return val;
 
10560
    }
 
10561
}
 
10562
 
 
10563
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
 
10564
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
 
10565
    const int is_unsigned = neg_one > const_zero;
 
10566
#if PY_VERSION_HEX < 0x03000000
 
10567
    if (likely(PyInt_Check(x))) {
 
10568
        long val = PyInt_AS_LONG(x);
 
10569
        if (is_unsigned && unlikely(val < 0)) {
 
10570
            PyErr_SetString(PyExc_OverflowError,
 
10571
                            "can't convert negative value to PY_LONG_LONG");
 
10572
            return (PY_LONG_LONG)-1;
 
10573
        }
 
10574
        return (PY_LONG_LONG)val;
 
10575
    } else
 
10576
#endif
 
10577
    if (likely(PyLong_Check(x))) {
 
10578
        if (is_unsigned) {
 
10579
            if (unlikely(Py_SIZE(x) < 0)) {
 
10580
                PyErr_SetString(PyExc_OverflowError,
 
10581
                                "can't convert negative value to PY_LONG_LONG");
 
10582
                return (PY_LONG_LONG)-1;
 
10583
            }
 
10584
            return PyLong_AsUnsignedLongLong(x);
 
10585
        } else {
 
10586
            return PyLong_AsLongLong(x);
 
10587
        }
 
10588
    } else {
 
10589
        PY_LONG_LONG val;
 
10590
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
10591
        if (!tmp) return (PY_LONG_LONG)-1;
 
10592
        val = __Pyx_PyInt_AsLongLong(tmp);
 
10593
        Py_DECREF(tmp);
 
10594
        return val;
 
10595
    }
 
10596
}
 
10597
 
 
10598
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
 
10599
    const signed long neg_one = (signed long)-1, const_zero = 0;
 
10600
    const int is_unsigned = neg_one > const_zero;
 
10601
#if PY_VERSION_HEX < 0x03000000
 
10602
    if (likely(PyInt_Check(x))) {
 
10603
        long val = PyInt_AS_LONG(x);
 
10604
        if (is_unsigned && unlikely(val < 0)) {
 
10605
            PyErr_SetString(PyExc_OverflowError,
 
10606
                            "can't convert negative value to signed long");
 
10607
            return (signed long)-1;
 
10608
        }
 
10609
        return (signed long)val;
 
10610
    } else
 
10611
#endif
 
10612
    if (likely(PyLong_Check(x))) {
 
10613
        if (is_unsigned) {
 
10614
            if (unlikely(Py_SIZE(x) < 0)) {
 
10615
                PyErr_SetString(PyExc_OverflowError,
 
10616
                                "can't convert negative value to signed long");
 
10617
                return (signed long)-1;
 
10618
            }
 
10619
            return PyLong_AsUnsignedLong(x);
 
10620
        } else {
 
10621
            return PyLong_AsLong(x);
 
10622
        }
 
10623
    } else {
 
10624
        signed long val;
 
10625
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
10626
        if (!tmp) return (signed long)-1;
 
10627
        val = __Pyx_PyInt_AsSignedLong(tmp);
 
10628
        Py_DECREF(tmp);
 
10629
        return val;
 
10630
    }
 
10631
}
 
10632
 
 
10633
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
 
10634
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
 
10635
    const int is_unsigned = neg_one > const_zero;
 
10636
#if PY_VERSION_HEX < 0x03000000
 
10637
    if (likely(PyInt_Check(x))) {
 
10638
        long val = PyInt_AS_LONG(x);
 
10639
        if (is_unsigned && unlikely(val < 0)) {
 
10640
            PyErr_SetString(PyExc_OverflowError,
 
10641
                            "can't convert negative value to signed PY_LONG_LONG");
 
10642
            return (signed PY_LONG_LONG)-1;
 
10643
        }
 
10644
        return (signed PY_LONG_LONG)val;
 
10645
    } else
 
10646
#endif
 
10647
    if (likely(PyLong_Check(x))) {
 
10648
        if (is_unsigned) {
 
10649
            if (unlikely(Py_SIZE(x) < 0)) {
 
10650
                PyErr_SetString(PyExc_OverflowError,
 
10651
                                "can't convert negative value to signed PY_LONG_LONG");
 
10652
                return (signed PY_LONG_LONG)-1;
 
10653
            }
 
10654
            return PyLong_AsUnsignedLongLong(x);
 
10655
        } else {
 
10656
            return PyLong_AsLongLong(x);
 
10657
        }
 
10658
    } else {
 
10659
        signed PY_LONG_LONG val;
 
10660
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
10661
        if (!tmp) return (signed PY_LONG_LONG)-1;
 
10662
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
 
10663
        Py_DECREF(tmp);
 
10664
        return val;
 
10665
    }
 
10666
}
 
10667
 
 
10668
static void __Pyx_WriteUnraisable(const char *name) {
 
10669
    PyObject *old_exc, *old_val, *old_tb;
 
10670
    PyObject *ctx;
 
10671
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
 
10672
    #if PY_MAJOR_VERSION < 3
 
10673
    ctx = PyString_FromString(name);
 
10674
    #else
 
10675
    ctx = PyUnicode_FromString(name);
 
10676
    #endif
 
10677
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
 
10678
    if (!ctx) {
 
10679
        PyErr_WriteUnraisable(Py_None);
 
10680
    } else {
 
10681
        PyErr_WriteUnraisable(ctx);
 
10682
        Py_DECREF(ctx);
 
10683
    }
 
10684
}
 
10685
 
 
10686
static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
 
10687
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
 
10688
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
 
10689
#else
 
10690
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
 
10691
#endif
 
10692
    if (!ob)
 
10693
        goto bad;
 
10694
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
 
10695
        goto bad;
 
10696
    Py_DECREF(ob);
 
10697
    return 0;
 
10698
bad:
 
10699
    Py_XDECREF(ob);
 
10700
    return -1;
 
10701
}
 
10702
 
 
10703
#include "compile.h"
 
10704
#include "frameobject.h"
 
10705
#include "traceback.h"
 
10706
 
 
10707
static void __Pyx_AddTraceback(const char *funcname) {
 
10708
    PyObject *py_srcfile = 0;
 
10709
    PyObject *py_funcname = 0;
 
10710
    PyObject *py_globals = 0;
 
10711
    PyCodeObject *py_code = 0;
 
10712
    PyFrameObject *py_frame = 0;
 
10713
 
 
10714
    #if PY_MAJOR_VERSION < 3
 
10715
    py_srcfile = PyString_FromString(__pyx_filename);
 
10716
    #else
 
10717
    py_srcfile = PyUnicode_FromString(__pyx_filename);
 
10718
    #endif
 
10719
    if (!py_srcfile) goto bad;
 
10720
    if (__pyx_clineno) {
 
10721
        #if PY_MAJOR_VERSION < 3
 
10722
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
 
10723
        #else
 
10724
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
 
10725
        #endif
 
10726
    }
 
10727
    else {
 
10728
        #if PY_MAJOR_VERSION < 3
 
10729
        py_funcname = PyString_FromString(funcname);
 
10730
        #else
 
10731
        py_funcname = PyUnicode_FromString(funcname);
 
10732
        #endif
 
10733
    }
 
10734
    if (!py_funcname) goto bad;
 
10735
    py_globals = PyModule_GetDict(__pyx_m);
 
10736
    if (!py_globals) goto bad;
 
10737
    py_code = PyCode_New(
 
10738
        0,            /*int argcount,*/
 
10739
        #if PY_MAJOR_VERSION >= 3
 
10740
        0,            /*int kwonlyargcount,*/
 
10741
        #endif
 
10742
        0,            /*int nlocals,*/
 
10743
        0,            /*int stacksize,*/
 
10744
        0,            /*int flags,*/
 
10745
        __pyx_empty_bytes, /*PyObject *code,*/
 
10746
        __pyx_empty_tuple,  /*PyObject *consts,*/
 
10747
        __pyx_empty_tuple,  /*PyObject *names,*/
 
10748
        __pyx_empty_tuple,  /*PyObject *varnames,*/
 
10749
        __pyx_empty_tuple,  /*PyObject *freevars,*/
 
10750
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
 
10751
        py_srcfile,   /*PyObject *filename,*/
 
10752
        py_funcname,  /*PyObject *name,*/
 
10753
        __pyx_lineno,   /*int firstlineno,*/
 
10754
        __pyx_empty_bytes  /*PyObject *lnotab*/
 
10755
    );
 
10756
    if (!py_code) goto bad;
 
10757
    py_frame = PyFrame_New(
 
10758
        PyThreadState_GET(), /*PyThreadState *tstate,*/
 
10759
        py_code,             /*PyCodeObject *code,*/
 
10760
        py_globals,          /*PyObject *globals,*/
 
10761
        0                    /*PyObject *locals*/
 
10762
    );
 
10763
    if (!py_frame) goto bad;
 
10764
    py_frame->f_lineno = __pyx_lineno;
 
10765
    PyTraceBack_Here(py_frame);
 
10766
bad:
 
10767
    Py_XDECREF(py_srcfile);
 
10768
    Py_XDECREF(py_funcname);
 
10769
    Py_XDECREF(py_code);
 
10770
    Py_XDECREF(py_frame);
 
10771
}
 
10772
 
 
10773
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
 
10774
    while (t->p) {
 
10775
        #if PY_MAJOR_VERSION < 3
 
10776
        if (t->is_unicode) {
 
10777
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
 
10778
        } else if (t->intern) {
 
10779
            *t->p = PyString_InternFromString(t->s);
 
10780
        } else {
 
10781
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
 
10782
        }
 
10783
        #else  /* Python 3+ has unicode identifiers */
 
10784
        if (t->is_unicode | t->is_str) {
 
10785
            if (t->intern) {
 
10786
                *t->p = PyUnicode_InternFromString(t->s);
 
10787
            } else if (t->encoding) {
 
10788
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
 
10789
            } else {
 
10790
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
 
10791
            }
 
10792
        } else {
 
10793
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
 
10794
        }
 
10795
        #endif
 
10796
        if (!*t->p)
 
10797
            return -1;
 
10798
        ++t;
 
10799
    }
 
10800
    return 0;
 
10801
}
 
10802
 
 
10803
/* Type Conversion Functions */
 
10804
 
 
10805
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
 
10806
   int is_true = x == Py_True;
 
10807
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
 
10808
   else return PyObject_IsTrue(x);
 
10809
}
 
10810
 
 
10811
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
 
10812
  PyNumberMethods *m;
 
10813
  const char *name = NULL;
 
10814
  PyObject *res = NULL;
 
10815
#if PY_VERSION_HEX < 0x03000000
 
10816
  if (PyInt_Check(x) || PyLong_Check(x))
 
10817
#else
 
10818
  if (PyLong_Check(x))
 
10819
#endif
 
10820
    return Py_INCREF(x), x;
 
10821
  m = Py_TYPE(x)->tp_as_number;
 
10822
#if PY_VERSION_HEX < 0x03000000
 
10823
  if (m && m->nb_int) {
 
10824
    name = "int";
 
10825
    res = PyNumber_Int(x);
 
10826
  }
 
10827
  else if (m && m->nb_long) {
 
10828
    name = "long";
 
10829
    res = PyNumber_Long(x);
 
10830
  }
 
10831
#else
 
10832
  if (m && m->nb_int) {
 
10833
    name = "int";
 
10834
    res = PyNumber_Long(x);
 
10835
  }
 
10836
#endif
 
10837
  if (res) {
 
10838
#if PY_VERSION_HEX < 0x03000000
 
10839
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
 
10840
#else
 
10841
    if (!PyLong_Check(res)) {
 
10842
#endif
 
10843
      PyErr_Format(PyExc_TypeError,
 
10844
                   "__%s__ returned non-%s (type %.200s)",
 
10845
                   name, name, Py_TYPE(res)->tp_name);
 
10846
      Py_DECREF(res);
 
10847
      return NULL;
 
10848
    }
 
10849
  }
 
10850
  else if (!PyErr_Occurred()) {
 
10851
    PyErr_SetString(PyExc_TypeError,
 
10852
                    "an integer is required");
 
10853
  }
 
10854
  return res;
 
10855
}
 
10856
 
 
10857
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
 
10858
  Py_ssize_t ival;
 
10859
  PyObject* x = PyNumber_Index(b);
 
10860
  if (!x) return -1;
 
10861
  ival = PyInt_AsSsize_t(x);
 
10862
  Py_DECREF(x);
 
10863
  return ival;
 
10864
}
 
10865
 
 
10866
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
 
10867
#if PY_VERSION_HEX < 0x02050000
 
10868
   if (ival <= LONG_MAX)
 
10869
       return PyInt_FromLong((long)ival);
 
10870
   else {
 
10871
       unsigned char *bytes = (unsigned char *) &ival;
 
10872
       int one = 1; int little = (int)*(unsigned char*)&one;
 
10873
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
 
10874
   }
 
10875
#else
 
10876
   return PyInt_FromSize_t(ival);
 
10877
#endif
 
10878
}
 
10879
 
 
10880
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
 
10881
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
 
10882
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
 
10883
       return (size_t)-1;
 
10884
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
 
10885
       PyErr_SetString(PyExc_OverflowError,
 
10886
                       "value too large to convert to size_t");
 
10887
       return (size_t)-1;
 
10888
   }
 
10889
   return (size_t)val;
 
10890
}
 
10891
 
 
10892
 
 
10893
#endif /* Py_PYTHON_H */