/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: Aaron Bentley
  • Date: 2008-03-04 18:03:39 UTC
  • Revision ID: aaron@aaronbentley.com-20080304180339-5is215gbue9ff3tu
Update window titles

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(repository, start_revs, maxnum, broken_line_length = None,
 
14
def linegraph(repository, start, 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
    
46
 
    graph = repository.get_graph()
47
 
    graph_parents = {}
48
 
    ghosts = set()
 
45
    graph_parents = repository.get_revision_graph(start)
49
46
    graph_children = {}
50
 
    for (revid, parent_revids) in graph.iter_ancestry(start_revs):
51
 
        if parent_revids is None:
52
 
            ghosts.add(revid)
53
 
            continue
54
 
        if parent_revids == (NULL_REVISION,):
55
 
            graph_parents[revid] = ()
56
 
        else:
57
 
            graph_parents[revid] = parent_revids
58
 
        for parent in parent_revids:
59
 
            graph_children.setdefault(parent, []).append(revid)
60
 
        graph_children.setdefault(revid, [])
61
 
    for ghost in ghosts:
62
 
        for ghost_child in graph_children[ghost]:
63
 
            graph_parents[ghost_child] = [p for p in graph_parents[ghost_child]
64
 
                                          if p not in ghosts]
65
 
    graph_parents["top:"] = start_revs
 
47
    for revid in graph_parents.iterkeys():
 
48
        graph_children[revid] = []
66
49
 
67
50
    if len(graph_parents)>0:
68
51
        merge_sorted_revisions = merge_sort(
69
52
            graph_parents,
70
 
            "top:",
 
53
            start,
71
54
            generate_revno=True)
72
55
    else:
73
56
        merge_sorted_revisions = ()
75
58
    if mainline_only:
76
59
        merge_sorted_revisions = [elem for elem in merge_sorted_revisions \
77
60
                                  if len(elem[3])==1 ]
78
 
 
79
 
    assert merge_sorted_revisions[0][1] == "top:"
80
 
    merge_sorted_revisions = merge_sorted_revisions[1:]
81
61
    
82
62
    revid_index = {}
83
63
    revno_index = {}
103
83
        revid_index[revid] = rev_index
104
84
        
105
85
        parents = graph_parents[revid]
 
86
        for parent_revid in parents:
 
87
            graph_children[parent_revid].append(revid)
 
88
        
106
89
        linegraph.append([revid,
107
90
                          None,
108
91
                          [],