/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/graph.py

  • Committer: Martin Pool
  • Date: 2009-09-11 06:36:50 UTC
  • mto: This revision was merged to the branch mainline in revision 4688.
  • Revision ID: mbp@sourcefrog.net-20090911063650-yvb522sbe6k0i62r
Only mutter extension load errors when they occur, and record for later

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
22
22
    osutils,
23
23
    revision,
24
24
    trace,
 
25
    tsort,
25
26
    )
26
27
from bzrlib.symbol_versioning import deprecated_function, deprecated_in
27
28
 
311
312
        # get there.
312
313
        return known_revnos[cur_tip] + num_steps
313
314
 
314
 
    def find_lefthand_distances(self, keys):
315
 
        """Find the distance to null for all the keys in keys.
316
 
 
317
 
        :param keys: keys to lookup.
318
 
        :return: A dict key->distance for all of keys.
319
 
        """
320
 
        # Optimisable by concurrent searching, but a random spread should get
321
 
        # some sort of hit rate.
322
 
        result = {}
323
 
        known_revnos = []
324
 
        ghosts = []
325
 
        for key in keys:
326
 
            try:
327
 
                known_revnos.append(
328
 
                    (key, self.find_distance_to_null(key, known_revnos)))
329
 
            except errors.GhostRevisionsHaveNoRevno:
330
 
                ghosts.append(key)
331
 
        for key in ghosts:
332
 
            known_revnos.append((key, -1))
333
 
        return dict(known_revnos)
334
 
 
335
315
    def find_unique_ancestors(self, unique_revision, common_revisions):
336
316
        """Find the unique ancestors for a revision versus others.
337
317
 
926
906
        An ancestor may sort after a descendant if the relationship is not
927
907
        visible in the supplied list of revisions.
928
908
        """
929
 
        from bzrlib import tsort
930
909
        sorter = tsort.TopoSorter(self.get_parent_map(revisions))
931
910
        return sorter.iter_topo_order()
932
911
 
1679
1658
    return result
1680
1659
 
1681
1660
 
1682
 
class GraphThunkIdsToKeys(object):
1683
 
    """Forwards calls about 'ids' to be about keys internally."""
1684
 
 
1685
 
    def __init__(self, graph):
1686
 
        self._graph = graph
1687
 
 
1688
 
    def topo_sort(self):
1689
 
        return [r for (r,) in self._graph.topo_sort()]
1690
 
 
1691
 
    def heads(self, ids):
1692
 
        """See Graph.heads()"""
1693
 
        as_keys = [(i,) for i in ids]
1694
 
        head_keys = self._graph.heads(as_keys)
1695
 
        return set([h[0] for h in head_keys])
1696
 
 
1697
 
    def merge_sort(self, tip_revision):
1698
 
        return self._graph.merge_sort((tip_revision,))
1699
 
 
1700
 
 
1701
1661
_counters = [0,0,0,0,0,0,0]
1702
1662
try:
1703
1663
    from bzrlib._known_graph_pyx import KnownGraph