/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: John Arbash Meinel
  • Date: 2007-11-02 22:29:12 UTC
  • mfrom: (330 trunk)
  • mto: (330.3.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 368.
  • Revision ID: john@arbash-meinel.com-20071102222912-ei8ll3bla3w2h2gp
Merge in trunk, and update logview per-file commit messages.

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(branch, start, maxnum):
15
 
    """Produce a directed graph of a bzr branch.
 
14
def linegraph(repository, start, maxnum, broken_line_length=None):
 
15
    """Produce a directed graph of a bzr repository.
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
 
    # 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)
 
44
    graph_parents = repository.get_revision_graph(start)
52
45
    graph_children = {}
53
46
    for revid in graph_parents.iterkeys():
54
47
        graph_children[revid] = []
56
49
    merge_sorted_revisions = merge_sort(
57
50
        graph_parents,
58
51
        start,
59
 
        mainline,
60
52
        generate_revno=True)
61
53
    
62
54
    revid_index = {}
155
147
        last_rev_index = None
156
148
        for rev_index in branch_line:
157
149
            if last_rev_index:
158
 
                if BROKEN_LINE_LENGTH and \
159
 
                   rev_index - last_rev_index > BROKEN_LINE_LENGTH:
 
150
                if broken_line_length and \
 
151
                   rev_index - last_rev_index > broken_line_length:
160
152
                    line_range.append(last_rev_index+1)
161
153
                    line_range.append(rev_index-1)
162
154
                else:
166
158
            last_rev_index = rev_index
167
159
        
168
160
        if parent_index:
169
 
            if BROKEN_LINE_LENGTH and \
170
 
               parent_index - last_rev_index > BROKEN_LINE_LENGTH:
 
161
            if broken_line_length and \
 
162
               parent_index - last_rev_index > broken_line_length:
171
163
                line_range.append(last_rev_index+1)
172
164
            else:
173
165
                line_range.extend(range(last_rev_index+1, parent_index))
207
199
                        
208
200
                    # If this line is really long, break it.
209
201
                    if len(branch_id) > 0 and \
210
 
                       BROKEN_LINE_LENGTH and \
211
 
                       parent_index - rev_index > BROKEN_LINE_LENGTH:
 
202
                       broken_line_length and \
 
203
                       parent_index - rev_index > broken_line_length:
212
204
                        child_line_col_index = \
213
205
                            _find_free_column(columns,
214
206
                                              empty_column,