/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 bzrlib/knit.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-06 19:37:07 UTC
  • mto: This revision was merged to the branch mainline in revision 4522.
  • Revision ID: john@arbash-meinel.com-20090706193707-ipgtqgtlkua2pxno
Ensure that _KnitAnnotator also supports add_special_text.

It already had some support for handling texts that were already present.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3376
3376
        """
3377
3377
        pending = set([key])
3378
3378
        records = []
3379
 
        generation = 0
3380
 
        kept_generation = 0
 
3379
        ann_keys = set()
3381
3380
        self._num_needed_children[key] = 1
3382
3381
        while pending:
3383
3382
            # get all pending nodes
3384
 
            generation += 1
3385
3383
            this_iteration = pending
3386
3384
            build_details = self._vf._index.get_build_details(this_iteration)
3387
3385
            self._all_build_details.update(build_details)
3394
3392
                self._heads_provider = None
3395
3393
                records.append((key, index_memo))
3396
3394
                # Do we actually need to check _annotated_lines?
3397
 
                pending.update(p for p in parent_keys
3398
 
                                 if p not in self._all_build_details)
 
3395
                pending.update([p for p in parent_keys
 
3396
                                   if p not in self._all_build_details])
3399
3397
                if parent_keys:
3400
3398
                    for parent_key in parent_keys:
3401
3399
                        if parent_key in self._num_needed_children:
3410
3408
 
3411
3409
            missing_versions = this_iteration.difference(build_details.keys())
3412
3410
            if missing_versions:
3413
 
                raise ValueError('i dont handle ghosts')
 
3411
                for key in missing_versions:
 
3412
                    if key in self._parent_map and key in self._text_cache:
 
3413
                        # We already have this text ready, we just need to
 
3414
                        # yield it later so we get it annotated
 
3415
                        ann_keys.add(key)
 
3416
                        parent_keys = self._parent_map[key]
 
3417
                        for parent_key in parent_keys:
 
3418
                            if parent_key in self._num_needed_children:
 
3419
                                self._num_needed_children[parent_key] += 1
 
3420
                            else:
 
3421
                                self._num_needed_children[parent_key] = 1
 
3422
                        pending.update([p for p in parent_keys
 
3423
                                           if p not in self._all_build_details])
 
3424
                    else:
 
3425
                        raise ValueError('i dont handle ghosts')
3414
3426
        # Generally we will want to read the records in reverse order, because
3415
3427
        # we find the parent nodes after the children
3416
3428
        records.reverse()
3417
 
        return records
 
3429
        return records, ann_keys
3418
3430
 
3419
3431
    def _get_needed_texts(self, key, pb=None):
3420
3432
        # if True or len(self._vf._fallback_vfs) > 0:
3425
3437
            return
3426
3438
        while True:
3427
3439
            try:
3428
 
                records = self._get_build_graph(key)
 
3440
                records, ann_keys = self._get_build_graph(key)
3429
3441
                for idx, (sub_key, text, num_lines) in enumerate(
3430
3442
                                                self._extract_texts(records)):
3431
3443
                    if pb is not None:
3432
3444
                        pb.update('annotating', idx, len(records))
3433
3445
                    yield sub_key, text, num_lines
 
3446
                for sub_key in ann_keys:
 
3447
                    text = self._text_cache[sub_key]
 
3448
                    num_lines = len(text) # bad assumption
 
3449
                    yield sub_key, text, num_lines
3434
3450
                return
3435
3451
            except errors.RetryWithNewPacks, e:
3436
3452
                self._vf._access.reload_or_raise(e)