~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import bzrlib.bzrdir as bzrdir
23
23
from bzrlib.decorators import needs_read_lock, needs_write_lock
24
24
from bzrlib.errors import InvalidRevisionId
 
25
from bzrlib.graph import Graph
25
26
from bzrlib.lockable_files import LockableFiles, TransportLock
26
27
from bzrlib.lockdir import LockDir
27
28
from bzrlib.osutils import safe_unicode
455
456
            return result
456
457
 
457
458
    @needs_read_lock
 
459
    def get_revision_graph_with_ghosts(self, revision_ids=None):
 
460
        """Return a graph of the revisions with ghosts marked as applicable.
 
461
 
 
462
        :param revision_ids: an iterable of revisions to graph or None for all.
 
463
        :return: a Graph object with the graph reachable from revision_ids.
 
464
        """
 
465
        result = Graph()
 
466
        if not revision_ids:
 
467
            pending = set(self.all_revision_ids())
 
468
            required = set([])
 
469
        else:
 
470
            pending = set(revision_ids)
 
471
            required = set(revision_ids)
 
472
        done = set([])
 
473
        while len(pending):
 
474
            revision_id = pending.pop()
 
475
            try:
 
476
                rev = self.get_revision(revision_id)
 
477
            except errors.NoSuchRevision:
 
478
                if revision_id in required:
 
479
                    raise
 
480
                # a ghost
 
481
                result.add_ghost(revision_id)
 
482
                continue
 
483
            for parent_id in rev.parent_ids:
 
484
                # is this queued or done ?
 
485
                if (parent_id not in pending and
 
486
                    parent_id not in done):
 
487
                    # no, queue it.
 
488
                    pending.add(parent_id)
 
489
            result.add_node(revision_id, rev.parent_ids)
 
490
            done.add(result)
 
491
        return result
 
492
 
 
493
    @needs_read_lock
458
494
    def get_revision_inventory(self, revision_id):
459
495
        """Return inventory of a past revision."""
460
496
        # TODO: Unify this with get_inventory()