54
54
int PyObject_RichCompareBool_ptr "PyObject_RichCompareBool" (
55
55
PyObject *, PyObject *, int opid)
57
58
from bzrlib import errors, graph as _mod_graph, osutils, patiencediff, ui
211
212
_check_annotations_are_lists(annotations, parent_annotations)
212
213
par_list = <PyListObject *>parent_annotations
213
214
ann_list = <PyListObject *>annotations
215
# For NEWS and bzrlib/builtins.py, over 99% of the lines are simply copied
216
# across from the parent entry. So this routine is heavily optimized for
217
# that. Would be interesting if we could use memcpy() but we have to incref
214
219
for parent_idx, lines_idx, match_len in matching_blocks:
215
220
_check_match_ranges(parent_annotations, annotations,
216
221
parent_idx, lines_idx, match_len)
289
294
parent_lines = self._text_cache[parent_key]
290
295
parent_annotations = self._annotations_cache[parent_key]
291
296
# PatienceSequenceMatcher should probably be part of Policy
293
298
matcher = patiencediff.PatienceSequenceMatcher(None,
294
299
parent_lines, text)
295
300
matching_blocks = matcher.get_matching_blocks()
296
# _update_counter('get_matching_blocks()', c() - t)
301
_update_counter('get_matching_blocks()', c() - t)
297
302
return parent_annotations, matching_blocks
299
304
def _update_from_one_parent(self, key, annotations, lines, parent_key):
387
392
self._update_from_one_parent(key, annotations, text, parent_keys[0])
388
_update_counter('left parents', 1)
390
394
for parent in parent_keys[1:]:
391
395
self._update_from_other_parents(key, annotations, text,
392
396
this_annotation, parent)
393
_update_counter('right parents', 1)
395
398
_update_counter('update left', t2 - t1)
396
399
_update_counter('update rest', t3 - t2)
424
427
This is meant as a compatibility thunk to how annotate() used to work.
429
cdef Py_ssize_t pos, num_lines
427
431
annotations, lines = self.annotate(key)
428
432
_update_counter('annotate time', c() - t_first)
429
433
assert len(annotations) == len(lines)
434
num_lines = len(lines)
431
436
heads = self._get_heads_provider().heads
434
for annotation, line in zip(annotations, lines):
438
for pos from 0 <= pos < num_lines:
439
annotation = annotations[pos]
435
441
if len(annotation) == 1:
436
_update_counter('one source', 1)
437
append((annotation[0], line))
439
_update_counter('multi source', 1)
441
444
the_heads = heads(annotation)
442
_update_counter('heads time', c() - t)
443
445
if len(the_heads) == 1:
444
_update_counter('one head', 1)
445
446
for head in the_heads:
448
_update_counter('multi heads', 1)
449
449
# We need to resolve the ambiguity, for now just pick the
450
450
# sorted smallest
451
451
head = sorted(the_heads)[0]
452
if head == annotation[0]:
453
_update_counter('first ann', 1)
452
PyList_Append(out, (head, line))
455
453
_update_counter('resolve annotations', c() - t_second)
456
454
_update_counter('overall', c() - t_first)