3406
3406
# We have the basis parent, so expand the delta
3407
3407
base_content = self._content_objects[compression_parent]
3408
# TODO: track _num_compression_children, and when it goes to 1, we
3409
# can set 'copy_base_content = False' and remove base_content
3410
# from the cache (to be inserted as the new content)
3408
3411
content, _ = self._vf._factory.parse_record(
3409
3412
key, record, record_details, None, copy_base_content=True)
3438
3441
# However, process what we can, and put off to the side things that
3439
3442
# still need parents, cleaning them up when those parents are
3445
# 1) As 'records' are read, see if we can expand these records into
3446
# Content objects (and thus lines)
3447
# 2) If a given line-delta is waiting on its compression parent, it
3448
# gets queued up into self._pending_deltas, otherwise we expand
3449
# it, and put it into self._text_cache and self._content_objects
3450
# 3) If we expanded the text, we will then check to see if all
3451
# parents have also been processed. If so, this text gets yielded,
3452
# else this record gets set aside into pending_annotation
3453
# 4) Further, if we expanded the text in (2), we will then check to
3454
# see if there are any children in self._pending_deltas waiting to
3455
# also be processed. If so, we go back to (2) for those
3456
# 5) Further again, if we yielded the text, we can then check if that
3457
# 'unlocks' any of the texts in pending_annotations, which should
3458
# then get yielded as well
3459
# Note that both steps 4 and 5 are 'recursive' in that unlocking one
3460
# compression child could unlock yet another, and yielding a fulltext
3461
# will also 'unlock' the children that are waiting on that annotation.
3462
# (Though also, unlocking 1 parent's fulltext, does not unlock a child
3463
# if other parents are also waiting.)
3464
# We want to yield content before expanding child content objects, so
3465
# that we know when we can re-use the content lines, and the annotation
3466
# code can know when it can stop caching fulltexts, as well.
3441
3468
# Children that we want to annotate as soon as we get the parent text
3442
3469
# Map from parent_key => [child_key]
3443
3470
pending_annotation = {}
3456
3483
# At this point, we may be able to yield this content, if all
3457
3484
# parents are also finished
3485
yield_this_text = True
3458
3486
for parent_key in parent_keys:
3459
3487
if parent_key not in self._annotations_cache:
3460
# still waiting on a parent text
3488
# still waiting on at least one parent text, so queue it up
3489
# Note that if there are multiple parents, we need to wait
3461
3491
pending_annotation.setdefault(parent_key,
3462
3492
[]).append((key, parent_keys, content))
3493
yield_this_text = False
3465
3496
# All parents present
3466
3497
yield key, lines, len(lines)
3498
# Whether or not all parents were present, we want to check
3499
# if there are any pending compression children that we can now
3500
# expand, and have *them* queued up as potential nodes to yield for
3503
# if key in self._pending_deltas
3505
# Now that we have expanded deltas, if we *did* yield this text,
3506
# check to see if there are any child texts that are ready to be
3509
# if yield_this_text and key in pending_annotation:
3469
3512
from bzrlib._knit_load_data_c import _load_data_c as _load_data