~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/graph.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-07-16 20:52:54 UTC
  • mfrom: (5193.5.9 cleanup)
  • Revision ID: pqm@pqm.ubuntu.com-20100716205254-j0m65wckb90rj54w
(vila) Cleanup some bogus rest constructs in the doc. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2007-2010 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
19
19
from bzrlib import (
20
20
    debug,
21
21
    errors,
 
22
    osutils,
22
23
    revision,
23
24
    trace,
24
 
    tsort,
25
25
    )
26
26
from bzrlib.symbol_versioning import deprecated_function, deprecated_in
27
27
 
926
926
        An ancestor may sort after a descendant if the relationship is not
927
927
        visible in the supplied list of revisions.
928
928
        """
 
929
        from bzrlib import tsort
929
930
        sorter = tsort.TopoSorter(self.get_parent_map(revisions))
930
931
        return sorter.iter_topo_order()
931
932
 
1678
1679
    return result
1679
1680
 
1680
1681
 
 
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
 
1681
1701
_counters = [0,0,0,0,0,0,0]
1682
1702
try:
1683
1703
    from bzrlib._known_graph_pyx import KnownGraph
1684
 
except ImportError:
 
1704
except ImportError, e:
 
1705
    osutils.failed_to_load_extension(e)
1685
1706
    from bzrlib._known_graph_py import KnownGraph