~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Andrew Bennetts
  • Date: 2009-06-10 07:52:48 UTC
  • mto: This revision was merged to the branch mainline in revision 4446.
  • Revision ID: andrew.bennetts@canonical.com-20090610075248-1sniwsietj9f1f83
Refactor _extend_partial_history into a standalone function that can be used without a branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4412
4412
            yield versionedfile.FulltextContentFactory(
4413
4413
                key, parent_keys, None, as_bytes)
4414
4414
 
 
4415
 
 
4416
def _iter_for_revno(repo, partial_history_cache, stop_index=None,
 
4417
                    stop_revision=None):
 
4418
    """Extend the partial history to include a given index
 
4419
 
 
4420
    If a stop_index is supplied, stop when that index has been reached.
 
4421
    If a stop_revision is supplied, stop when that revision is
 
4422
    encountered.  Otherwise, stop when the beginning of history is
 
4423
    reached.
 
4424
 
 
4425
    :param stop_index: The index which should be present.  When it is
 
4426
        present, history extension will stop.
 
4427
    :param stop_revision: The revision id which should be present.  When
 
4428
        it is encountered, history extension will stop.
 
4429
    """
 
4430
    mutter('partial_history_cache: %r', partial_history_cache)
 
4431
    mutter('stop_index: %d', stop_index)
 
4432
    start_revision = partial_history_cache[-1]
 
4433
    iterator = repo.iter_reverse_revision_history(start_revision)
 
4434
    try:
 
4435
        #skip the last revision in the list
 
4436
        next_revision = iterator.next()
 
4437
        while True:
 
4438
            if (stop_index is not None and
 
4439
                len(partial_history_cache) > stop_index):
 
4440
                break
 
4441
            revision_id = iterator.next()
 
4442
            partial_history_cache.append(revision_id)
 
4443
            if revision_id == stop_revision:
 
4444
                break
 
4445
    except StopIteration:
 
4446
        # No more history
 
4447
        return
 
4448