/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/graph.py

  • Committer: John Arbash Meinel
  • Date: 2007-09-21 17:42:04 UTC
  • mto: (322.1.1 trunk) (330.3.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 279.
  • Revision ID: john@arbash-meinel.com-20070921174204-ux87radq4k80m8zg
Pass in the maxnum value to the distances function.
That way we can avoid actually reading all Revisions for the entire
graph.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
        self.repository = repository
69
69
        self.start_revid = start_revid
70
70
        self.revisions = {}
71
 
        self.children = {}
72
71
        self.children_of_id = {start_revid: set()}
73
72
        self.parent_ids_of = {}
74
73
        self.colours = { start_revid: 0 }
162
161
        self.distances = distances
163
162
        return sorted(distances, key=distances.get)
164
163
 
 
164
    def choose_null_colour(self, revid):
 
165
        """We know we don't need this color, so just set it to NULL"""
 
166
        self.colours[revid] = 0
 
167
 
165
168
    def choose_colour(self, revid):
166
169
        revision = self.revisions[revid]
167
170
        children_of_id = self.children_of_id
236
239
                self.colours[revid] = self.last_colour = self.last_colour + 1
237
240
 
238
241
 
239
 
def distances(repository, start_revid):
 
242
def distances(repository, start_revid, maxnum=None):
240
243
    """Sort the revisions.
241
244
 
242
245
    Traverses the branch revision tree starting at start and produces an
250
253
    distance.merge_sorted = merge_sort(distance.graph, distance.start_revid)
251
254
    children = distance.make_children_map()
252
255
    
 
256
    count = 0
253
257
    for seq, revid, merge_depth, end_of_merge in distance.merge_sorted:
254
 
        distance.choose_colour(revid)
 
258
        count += 1
 
259
        if maxnum is not None and count > maxnum:
 
260
            distance.choose_null_colour(revid)
 
261
        else:
 
262
            distance.choose_colour(revid)
255
263
 
256
264
    revisions = distance.revisions
257
265
    colours = distance.colours