/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: Chad MILLER
  • Date: 2008-05-01 12:06:26 UTC
  • mto: (511.5.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: chad@mysql.com-20080501120626-8k0ay6jee6tfz1sz
Make "vizualize" use the GUI progress bar defined in the parent 'ui' module.

Update the progress bar so that one need not specify both the total steps and 
the current step with every update.

Remove extraneous signaling and put related progress-bar element close to its
use.

TODO:  Given a nested-progress-bar object, one should be able to use it as a
factory of sub-bars.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
from bzrlib.revision import NULL_REVISION
13
13
from bzrlib.tsort import merge_sort
14
 
 
15
 
def linegraph(repository, start_revs, maxnum, broken_line_length = None,
16
 
              graph_data = True, mainline_only = False):
 
14
from bzrlib import ui
 
15
 
 
16
 
 
17
def linegraph(repository, start_revs, maxnum, root_progress, 
 
18
              broken_line_length = None, graph_data = True,
 
19
              mainline_only = False):
17
20
    """Produce a directed graph of a bzr repository.
18
21
 
19
22
    Returns a tuple of (line_graph, revid_index, columns_len) where
47
50
    graph_parents = {}
48
51
    ghosts = set()
49
52
    graph_children = {}
50
 
    for (revid, parent_revids) in graph.iter_ancestry(start_revs):
 
53
    root_progress.update(current=1)
 
54
    progress_bar = ui.ui_factory.nested_progress_bar()
 
55
    progress_bar.update(msg="Arranging tree fragments")
 
56
    for i, (revid, parent_revids) in enumerate(graph.iter_ancestry(start_revs)):
 
57
        if i % 25 == 0:
 
58
            progress_bar.tick()
 
59
 
51
60
        if parent_revids is None:
52
61
            ghosts.add(revid)
53
62
            continue
58
67
        for parent in parent_revids:
59
68
            graph_children.setdefault(parent, []).append(revid)
60
69
        graph_children[revid] = []
61
 
    for ghost in ghosts:
 
70
    progress_bar.finished()
 
71
 
 
72
    root_progress.update(current=2)
 
73
    progress_bar = ui.ui_factory.nested_progress_bar()
 
74
    progress_bar.update(msg="Removing ghosts", total=len(ghosts))
 
75
    for i, ghost in enumerate(ghosts):
 
76
        if i % 25 == 0:
 
77
            progress_bar.update(current=i)
62
78
        for ghost_child in graph_children[ghost]:
63
79
            graph_parents[ghost_child] = [p for p in graph_parents[ghost_child]
64
80
                                          if p not in ghosts]
 
81
    progress_bar.finished()
65
82
    graph_parents["top:"] = start_revs
66
83
 
67
84
    if len(graph_parents)>0:
93
110
    
94
111
    linegraph = []    
95
112
    
 
113
    root_progress.update(current=3)
 
114
    progress_bar = ui.ui_factory.nested_progress_bar()
 
115
    progress_bar.update(msg="Finding nodes", total=len(merge_sorted_revisions))
96
116
    for (rev_index, (sequence_number,
97
117
                     revid,
98
118
                     merge_depth,
99
119
                     revno_sequence,
100
120
                     end_of_merge)) in enumerate(merge_sorted_revisions):
 
121
 
 
122
        if rev_index % 25 == 0:
 
123
            progress_bar.update(current=rev_index)
101
124
        if maxnum and rev_index >= maxnum:
102
125
            break
103
126
        revid_index[revid] = rev_index
123
146
                branch_line = branch_lines[branch_id]
124
147
            
125
148
            branch_line.append(rev_index)        
 
149
    progress_bar.finished()
126
150
 
127
151
    if graph_data:
128
152
        branch_ids = branch_lines.keys()
150
174
        columns = [list(empty_column)]
151
175
        
152
176
        
153
 
        for branch_id in branch_ids:
 
177
        root_progress.update(current=4)
 
178
        progress_bar = ui.ui_factory.nested_progress_bar()
 
179
        progress_bar.update(msg="Organizing edges", total=len(branch_ids))
 
180
        for i, branch_id in enumerate(branch_ids):
 
181
            if i % 25 == 0:
 
182
                progress_bar.update(current=i)
154
183
            branch_line = branch_lines[branch_id]
155
184
            
156
185
            # Find the col_index for the direct parent branch. This will be the
271
300
                            lines.append((rev_index,
272
301
                                          parent_index,
273
302
                                          (line_col_index,)))
 
303
        progress_bar.finished()
274
304
        
275
 
        for (child_index, parent_index, line_col_indexes) in lines:
 
305
        root_progress.update(current=5)
 
306
        progress_bar = ui.ui_factory.nested_progress_bar()
 
307
        progress_bar.update(msg="Pretifying graph", total=len(lines))
 
308
        for i, (child_index, parent_index, line_col_indexes) in enumerate(lines):
 
309
            if i % 25 == 0:
 
310
                progress_bar.update(current=i)
276
311
            (child_col_index, child_color) = linegraph[child_index][1]
277
312
            (parent_col_index, parent_color) = linegraph[parent_index][1]
278
313
            
322
357
                    (line_col_indexes[1],
323
358
                     parent_col_index,
324
359
                     parent_color))
 
360
        progress_bar.finished()
325
361
        return (linegraph, revid_index, len(columns))
326
362
    else:
327
363
        return (linegraph, revid_index, 0)