/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 viz/linegraph.py

  • Committer: Gary van der Merwe
  • Date: 2007-08-26 12:30:45 UTC
  • mto: (256.2.37 gtk)
  • mto: This revision was merged to the branch mainline in revision 289.
  • Revision ID: garyvdm@gmail.com-20070826123045-iogmcthus927bhsq
Refactor so that line graph is more contained.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
__author__    = "Scott James Remnant <scott@ubuntu.com>"
11
11
 
12
12
 
13
 
def linegraph(revisions, revisionparents, revindex):
 
13
def linegraph(branch, start, maxnum):
14
14
    """Produce a directed graph of a bzr branch.
15
15
 
16
16
    Returns a list of tuples of (revision, node, lines, parents, children).
30
30
    curved, kinked, etc.) and to pick the actual colours for each index.
31
31
    """
32
32
    
33
 
    directparentcache = [None for revision in revisions]
34
33
    def getdirectparent(childrevid, childindex, childsparents):
35
34
        """Return the revision id of the direct parent
36
35
        
99
98
            columns.append(column)
100
99
        return columnindex
101
100
    
 
101
    revids = []
 
102
    revindex = {}
 
103
    for (index, revid) in enumerate(reversed( \
 
104
            branch.repository.get_ancestry(start))):
 
105
        if revid is not None:
 
106
            revids.append(revid)
 
107
            revindex[revid] = index
 
108
        if maxnum is not None and index > maxnum:
 
109
            break
 
110
    
 
111
    
 
112
    revisions = branch.repository.get_revisions(revids)
 
113
    revisionparents = branch.repository.get_graph().get_parents(revids)    
 
114
    directparentcache = [None for revision in revisions]
 
115
    
102
116
    # This will hold what we plan to put in each column.
103
117
    # The position of the item in this list indicates the column, and it
104
118
    # it may change if we need to make space for other things.
270
284
        notdrawnlines = [line for line in notdrawnlines if line is not None]
271
285
        
272
286
 
273
 
    return linegraph
 
287
    return (linegraph, revindex, revisions)
274
288
 
275
289
 
276
290
def same_branch(a, b):