/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/_annotator_pyx.pyx

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
#
 
17
# cython: language_level=3
16
18
 
17
19
"""Functionality for doing annotations in the 'optimal' way"""
18
20
 
 
21
 
19
22
cdef extern from "python-compat.h":
20
23
    pass
21
24
 
 
25
from cpython.dict cimport (
 
26
    PyDict_GetItem,
 
27
    PyDict_SetItem,
 
28
    )
 
29
from cpython.list cimport (
 
30
    PyList_Append,
 
31
    PyList_CheckExact,
 
32
    PyList_GET_ITEM,
 
33
    PyList_GET_SIZE,
 
34
    PyList_SetItem,
 
35
    PyList_Sort,
 
36
    )
 
37
from cpython.object cimport (
 
38
    Py_EQ,
 
39
    Py_LT,
 
40
    PyObject,
 
41
    PyObject_RichCompareBool,
 
42
    )
 
43
from cpython.ref cimport (
 
44
    Py_INCREF,
 
45
    )
 
46
from cpython.tuple cimport (
 
47
    PyTuple_CheckExact,
 
48
    PyTuple_GET_ITEM,
 
49
    PyTuple_GET_SIZE,
 
50
    PyTuple_New,
 
51
    PyTuple_SET_ITEM,
 
52
    )
 
53
 
22
54
cdef extern from "Python.h":
23
 
    ctypedef int Py_ssize_t
24
 
    ctypedef struct PyObject:
25
 
        pass
26
55
    ctypedef struct PyListObject:
27
56
        PyObject **ob_item
28
 
    int PyList_CheckExact(object)
29
 
    PyObject *PyList_GET_ITEM(object, Py_ssize_t o)
30
 
    Py_ssize_t PyList_GET_SIZE(object)
31
 
    int PyList_Append(object, object) except -1
32
 
    int PyList_SetItem(object, Py_ssize_t o, object) except -1
33
 
    int PyList_Sort(object) except -1
34
57
 
35
 
    int PyTuple_CheckExact(object)
36
 
    object PyTuple_New(Py_ssize_t len)
37
 
    void PyTuple_SET_ITEM(object, Py_ssize_t pos, object)
38
58
    void PyTuple_SET_ITEM_ptr "PyTuple_SET_ITEM" (object, Py_ssize_t,
39
59
                                                  PyObject *)
40
 
    int PyTuple_Resize(PyObject **, Py_ssize_t newlen)
41
 
    PyObject *PyTuple_GET_ITEM(object, Py_ssize_t o)
42
 
    Py_ssize_t PyTuple_GET_SIZE(object)
43
 
 
44
 
    PyObject *PyDict_GetItem(object d, object k)
45
 
    int PyDict_SetItem(object d, object k, object v) except -1
46
 
 
47
 
    void Py_INCREF(object)
 
60
 
48
61
    void Py_INCREF_ptr "Py_INCREF" (PyObject *)
49
62
    void Py_DECREF_ptr "Py_DECREF" (PyObject *)
50
63
 
51
 
    int Py_EQ
52
 
    int Py_LT
53
 
    int PyObject_RichCompareBool(object, object, int opid) except -1
54
64
    int PyObject_RichCompareBool_ptr "PyObject_RichCompareBool" (
55
65
        PyObject *, PyObject *, int opid)
56
66
 
57
67
 
58
 
from bzrlib import _annotator_py
 
68
from . import _annotator_py
59
69
 
60
70
 
61
71
cdef int _check_annotations_are_lists(annotations,
88
98
 
89
99
    :param tpl: The tuple we are investigating, *must* be a PyTuple
90
100
    :param pos: The last item we found. Will be updated to the new position.
91
 
    
 
101
 
92
102
    This cannot raise an exception, as it does no error checking.
93
103
    """
94
104
    pos[0] = pos[0] + 1
101
111
    """Combine the annotations from both sides."""
102
112
    cdef Py_ssize_t pos_one, pos_two, len_one, len_two
103
113
    cdef Py_ssize_t out_pos
104
 
    cdef PyObject *temp, *left, *right
 
114
    cdef PyObject *temp
 
115
    cdef PyObject *left
 
116
    cdef PyObject *right
105
117
 
106
118
    if (PyObject_RichCompareBool(ann_one, ann_two, Py_LT)):
107
119
        cache_key = (ann_one, ann_two)
168
180
    matching_blocks defines the ranges that match.
169
181
    """
170
182
    cdef Py_ssize_t parent_idx, lines_idx, match_len, idx
171
 
    cdef PyListObject *par_list, *ann_list
172
 
    cdef PyObject **par_temp, **ann_temp
 
183
    cdef PyListObject *par_list
 
184
    cdef PyListObject *ann_list
 
185
    cdef PyObject **par_temp
 
186
    cdef PyObject **ann_temp
173
187
 
174
188
    _check_annotations_are_lists(annotations, parent_annotations)
175
189
    par_list = <PyListObject *>parent_annotations
176
190
    ann_list = <PyListObject *>annotations
177
 
    # For NEWS and bzrlib/builtins.py, over 99% of the lines are simply copied
 
191
    # For NEWS and breezy/builtins.py, over 99% of the lines are simply copied
178
192
    # across from the parent entry. So this routine is heavily optimized for
179
193
    # that. Would be interesting if we could use memcpy() but we have to incref
180
194
    # and decref
194
208
                            matching_blocks, ann_cache) except -1:
195
209
    cdef Py_ssize_t parent_idx, ann_idx, lines_idx, match_len, idx
196
210
    cdef Py_ssize_t pos
197
 
    cdef PyObject *ann_temp, *par_temp
 
211
    cdef PyObject *ann_temp
 
212
    cdef PyObject *par_temp
198
213
 
199
214
    _check_annotations_are_lists(annotations, parent_annotations)
200
215
    last_ann = None
269
284
        """
270
285
        cdef Py_ssize_t pos, num_lines
271
286
 
272
 
        from bzrlib import annotate
 
287
        from . import annotate
273
288
 
274
289
        custom_tiebreaker = annotate._break_annotation_tie
275
290
        annotations, lines = self.annotate(key)