~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/graph.py

  • Committer: Aaron Bentley
  • Date: 2008-03-03 16:52:41 UTC
  • mfrom: (3144.3.11 fix-conflict-handling)
  • mto: This revision was merged to the branch mainline in revision 3250.
  • Revision ID: aaron@aaronbentley.com-20080303165241-0k2c7ggs6kr9q6hf
Merge with fix-conflict-handling

Show diffs side-by-side

added added

removed removed

Lines of Context:
473
473
            return set(heads)
474
474
 
475
475
 
476
 
class HeadsCache(object):
477
 
    """A cache of results for graph heads calls."""
478
 
 
479
 
    def __init__(self, graph):
480
 
        self.graph = graph
481
 
        self._heads = {}
482
 
 
483
 
    def heads(self, keys):
484
 
        """Return the heads of keys.
485
 
 
486
 
        :see also: Graph.heads.
487
 
        :param keys: The keys to calculate heads for.
488
 
        :return: A set containing the heads, which may be mutated without
489
 
            affecting future lookups.
490
 
        """
491
 
        keys = frozenset(keys)
492
 
        try:
493
 
            return set(self._heads[keys])
494
 
        except KeyError:
495
 
            heads = self.graph.heads(keys)
496
 
            self._heads[keys] = heads
497
 
            return set(heads)
498
 
 
499
 
 
500
476
class _BreadthFirstSearcher(object):
501
477
    """Parallel search breadth-first the ancestry of revisions.
502
478
 
538
514
            # exclude keys for them. However, while we could have a second
539
515
            # look-ahead result buffer and shuffle things around, this method
540
516
            # is typically only called once per search - when memoising the
541
 
            # results of the search.
 
517
            # results of the search. 
542
518
            found, ghosts, next, parents = self._do_query(self._next_query)
543
519
            # pretend we didn't query: perhaps we should tweak _do_query to be
544
520
            # entirely stateless?