/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-09-09 19:21:19 UTC
  • mto: (256.2.37 gtk)
  • mto: This revision was merged to the branch mainline in revision 289.
  • Revision ID: garyvdm@gmail.com-20070909192119-9rveq7u8ol6m8pl5
RevertĀ fastĀ test

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
                 end_of_merge)) in enumerate(merge_sorted_revisions):
61
61
        
62
62
        revid_index[revid] = index
 
63
        revno_index[revno_sequence] = index
63
64
        
64
65
        branch_id = revno_sequence[0:-1]
65
66
        
 
67
        branch_line = None
 
68
        if branch_id not in branch_lines:
 
69
            branch_line = {}
 
70
            branch_lines[branch_id] = branch_line
 
71
            branch_line["rev_indexes"] = []
 
72
            branch_line["min_index"] = index - 1            
 
73
            branch_line["max_index"] = 0
 
74
        else:
 
75
            branch_line = branch_lines[branch_id]
 
76
        branch_line["rev_indexes"].append(index)
 
77
        if index > branch_line["max_index"]:
 
78
            branch_line["max_index"] = index
 
79
        
66
80
        parents = graph_parents[revid]
67
81
        for parent_revid in parents:
68
82
            graph_children[parent_revid].append(revid)
69
83
        
70
 
        children = graph_children[revid]
71
 
        
72
 
        color = reduce(lambda x, y: x+y, branch_id, 0)
73
 
        linegraph.append((revid,
74
 
                          (0, color),
 
84
        linegraph.append([revid,
 
85
                          None,
75
86
                          [],
76
87
                          parents,
77
 
                          children,
78
 
                          revno_sequence))
 
88
                          None,
 
89
                          revno_sequence])
 
90
 
 
91
    branch_ids = branch_lines.keys()
 
92
    branch_ids.sort()
 
93
    columns = []
 
94
    
 
95
    for branch_id in branch_ids:
 
96
        branch_line = branch_lines[branch_id]
 
97
        if len(branch_id) >= 2:
 
98
            branch_parent_revno = branch_id[0:-1]
 
99
            if branch_parent_revno in revno_index:
 
100
                branch_line["max_index"] = revno_index[branch_parent_revno]
 
101
        
 
102
        col_index = None
 
103
        start_col_index = 0
 
104
        if branch_id:
 
105
            start_col_index = branch_lines[branch_id[0:-2]]["col_index"]+1
 
106
        for col_search_index in range(start_col_index,len(columns)):
 
107
            column = columns[col_search_index]
 
108
            clashing_lines = []
 
109
            for line in column:
 
110
                if (line["min_index"] <= branch_line["min_index"] and \
 
111
                    line["max_index"] >  branch_line["min_index"]) or \
 
112
                   (line["max_index"] >= branch_line["max_index"] and \
 
113
                    line["min_index"] <  branch_line["max_index"]):
 
114
                        clashing_lines.append(line)
 
115
            
 
116
            if not clashing_lines:
 
117
                col_index = col_search_index
 
118
                break
 
119
        
 
120
        if not col_index:
 
121
            col_index = len(columns)
 
122
            columns.append([])
 
123
        
 
124
        columns[col_index].append(branch_line)
 
125
        branch_line["col_index"] = col_index
 
126
 
 
127
 
 
128
    for branch_id in branch_ids:
 
129
        branch_line = branch_lines[branch_id]
 
130
        color = reduce(lambda x, y: x+y, branch_id, 0)
 
131
        col_index = branch_line["col_index"]
 
132
        node = (col_index, color)
 
133
        
 
134
        for rev_index in branch_line["rev_indexes"]:
 
135
            (sequence_number,
 
136
                 revid,
 
137
                 merge_depth,
 
138
                 revno_sequence,
 
139
                 end_of_merge) = merge_sorted_revisions[rev_index]
 
140
            children = graph_children[revid]
 
141
            
 
142
            linegraph[rev_index][1] = node
 
143
            linegraph[rev_index][4] = children
 
144
            for child_revid in children:
 
145
                if child_revid in revid_index:
 
146
                    child_index = revid_index[child_revid]
 
147
                    child_revno_sequence = \
 
148
                                        merge_sorted_revisions[child_index][3]
 
149
                    child_merge_depth = merge_sorted_revisions[child_index][2]
 
150
                    child_branch_id = child_revno_sequence[0:-1]
 
151
                    child_col_index = branch_lines[child_branch_id]["col_index"]
 
152
                    if child_merge_depth < merge_depth:
 
153
                        #out from the child to line
 
154
                        linegraph[child_index][2].append(
 
155
                            (child_col_index,
 
156
                             col_index,
 
157
                             color))
 
158
                        for line_part_index in range(child_index+1, rev_index):
 
159
                            linegraph[line_part_index][2].append(
 
160
                                (col_index,
 
161
                                 col_index,
 
162
                                 color))
 
163
                    else:
 
164
                        for line_part_index in range(child_index, rev_index-1):
 
165
                            linegraph[line_part_index][2].append(
 
166
                                (child_col_index,   
 
167
                                 child_col_index,
 
168
                                 color))
 
169
 
 
170
                        linegraph[rev_index-1][2].append(
 
171
                            (child_col_index,
 
172
                             col_index,
 
173
                             color))
79
174
    
80
175
    return (linegraph, revid_index)
81
176