~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/deprecated_graph.py

  • Committer: Michael Hudson
  • Date: 2007-11-26 13:45:49 UTC
  • mto: (3008.1.10 tree-less-merge-diffs)
  • mto: This revision was merged to the branch mainline in revision 3189.
  • Revision ID: michael.hudson@canonical.com-20071126134549-8l3hqyg2bie5yqdv
extract merger creation into a method

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2008 Canonical Ltd
 
1
# Copyright (C) 2005 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
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
 
18
from bzrlib.tsort import topo_sort
 
19
 
 
20
 
18
21
def max_distance(node, ancestors, distances, root_descendants):
19
22
    """Calculate the max distance to an ancestor.  
20
23
    Return None if not all possible ancestors have known distances"""
57
60
        new_lines = set()
58
61
        for line in lines:
59
62
            line_descendants = graph[line]
 
63
            assert line not in line_descendants, "%s refers to itself" % line
60
64
            for descendant in line_descendants:
61
65
                distance = max_distance(descendant, ancestors, distances,
62
66
                                        root_descendants)
141
145
    def get_ancestry(self, node_id, topo_sorted=True):
142
146
        """Return the inclusive ancestors of node_id in topological order."""
143
147
        # maybe optimise this ?
144
 
        from bzrlib.tsort import topo_sort
145
148
        result = {}
146
149
        pending = set([node_id])
147
150
        while len(pending):