/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to branchview/linegraph.py

  • Committer: Martin Albisetti
  • Date: 2008-04-04 01:46:01 UTC
  • Revision ID: argentina@gmail.com-20080404014601-hutl46uqxx7psg2o
Removed duplicate code

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
__copyright__ = "Copyright © 2005 Canonical Ltd."
10
10
__author__    = "Scott James Remnant <scott@ubuntu.com>"
11
11
 
12
 
from bzrlib.revision import NULL_REVISION
13
12
from bzrlib.tsort import merge_sort
14
13
 
15
 
def linegraph(graph, start_revs, maxnum, broken_line_length = None,
 
14
def linegraph(repository, start_revs, maxnum, broken_line_length = None,
16
15
              graph_data = True, mainline_only = False):
17
16
    """Produce a directed graph of a bzr repository.
18
17
 
43
42
    curved, kinked, etc.) and to pick the actual colours for each index.
44
43
    """
45
44
    
 
45
    graph = repository.get_graph()
46
46
    graph_parents = {}
47
 
    ghosts = set()
48
47
    graph_children = {}
49
48
    for (revid, parent_revids) in graph.iter_ancestry(start_revs):
50
 
        if parent_revids is None:
51
 
            ghosts.add(revid)
52
 
            continue
53
 
        if parent_revids == (NULL_REVISION,):
54
 
            graph_parents[revid] = ()
55
 
        else:
56
 
            graph_parents[revid] = parent_revids
57
 
        for parent in parent_revids:
58
 
            graph_children.setdefault(parent, []).append(revid)
59
 
        graph_children.setdefault(revid, [])
60
 
    for ghost in ghosts:
61
 
        for ghost_child in graph_children[ghost]:
62
 
            graph_parents[ghost_child] = [p for p in graph_parents[ghost_child]
63
 
                                          if p not in ghosts]
 
49
        graph_parents[revid] = parent_revids
 
50
        graph_children[revid] = []
 
51
 
64
52
    graph_parents["top:"] = start_revs
65
53
 
66
54
    if len(graph_parents)>0:
102
90
        revid_index[revid] = rev_index
103
91
        
104
92
        parents = graph_parents[revid]
 
93
        for parent_revid in parents:
 
94
            graph_children[parent_revid].append(revid)
 
95
        
105
96
        linegraph.append([revid,
106
97
                          None,
107
98
                          [],