/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: Daniel Schierbeck
  • Date: 2007-10-14 15:54:57 UTC
  • mto: This revision was merged to the branch mainline in revision 317.
  • Revision ID: daniel.schierbeck@gmail.com-20071014155457-m3ek29p4ima8ev7d
Added the new Window base class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
from bzrlib.tsort import merge_sort
13
13
 
14
 
def linegraph(repository, start, maxnum, broken_line_length=None):
15
 
    """Produce a directed graph of a bzr repository.
 
14
def linegraph(branch, start, maxnum):
 
15
    """Produce a directed graph of a bzr branch.
16
16
 
17
17
    Returns a tuple of (line_graph, revid_index, columns_len) where
18
18
    * line_graph is a list of tuples of (revid,
41
41
    curved, kinked, etc.) and to pick the actual colours for each index.
42
42
    """
43
43
    
44
 
    graph_parents = repository.get_revision_graph(start)
 
44
    # FIXME: This should be configurable
 
45
    BROKEN_LINE_LENGTH = 32
 
46
    
 
47
    # We get the mainline so we can pass it to merge_sort to make merge_sort
 
48
    # run faster.
 
49
    mainline = [None]
 
50
    mainline.extend(branch.revision_history())
 
51
    graph_parents = branch.repository.get_revision_graph(start)
45
52
    graph_children = {}
46
53
    for revid in graph_parents.iterkeys():
47
54
        graph_children[revid] = []
49
56
    merge_sorted_revisions = merge_sort(
50
57
        graph_parents,
51
58
        start,
 
59
        mainline,
52
60
        generate_revno=True)
53
61
    
54
62
    revid_index = {}
147
155
        last_rev_index = None
148
156
        for rev_index in branch_line:
149
157
            if last_rev_index:
150
 
                if broken_line_length and \
151
 
                   rev_index - last_rev_index > broken_line_length:
 
158
                if BROKEN_LINE_LENGTH and \
 
159
                   rev_index - last_rev_index > BROKEN_LINE_LENGTH:
152
160
                    line_range.append(last_rev_index+1)
153
161
                    line_range.append(rev_index-1)
154
162
                else:
158
166
            last_rev_index = rev_index
159
167
        
160
168
        if parent_index:
161
 
            if broken_line_length and \
162
 
               parent_index - last_rev_index > broken_line_length:
 
169
            if BROKEN_LINE_LENGTH and \
 
170
               parent_index - last_rev_index > BROKEN_LINE_LENGTH:
163
171
                line_range.append(last_rev_index+1)
164
172
            else:
165
173
                line_range.extend(range(last_rev_index+1, parent_index))
199
207
                        
200
208
                    # If this line is really long, break it.
201
209
                    if len(branch_id) > 0 and \
202
 
                       broken_line_length and \
203
 
                       parent_index - rev_index > broken_line_length:
 
210
                       BROKEN_LINE_LENGTH and \
 
211
                       parent_index - rev_index > BROKEN_LINE_LENGTH:
204
212
                        child_line_col_index = \
205
213
                            _find_free_column(columns,
206
214
                                              empty_column,