/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: Aaron Bentley
  • Date: 2007-08-16 14:31:02 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070816143102-27yzfhdgdv3ggo6e
Fix hue selection to use author in gannotate

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    def __init__(self, revid):
26
26
        super(DummyRevision, self).__init__(revid)
27
27
        self.committer = None
 
28
        self.timestamp = None
 
29
        self.timezone = None
28
30
        self.message = revid
29
31
 
30
32
 
62
64
 
63
65
class DistanceMethod(object):
64
66
 
65
 
    def __init__(self, branch, start):
66
 
        self.branch = branch
67
 
        self.start = start
 
67
    def __init__(self, repository, start_revid):
 
68
        self.repository = repository
 
69
        self.start_revid = start_revid
68
70
        self.revisions = {}
69
71
        self.children = {}
70
 
        self.children_of_id = {start: set()}
 
72
        self.children_of_id = {start_revid: set()}
71
73
        self.parent_ids_of = {}
72
 
        self.colours = { start: 0 }
 
74
        self.colours = { start_revid: 0 }
73
75
        self.last_colour = 0
74
76
        self.direct_parent_of = {}
75
77
        self.graph = {}
76
78
 
77
79
    def fill_caches(self):
78
 
        graph = self.branch.repository.get_revision_graph_with_ghosts([self.start])
 
80
        graph = self.repository.get_revision_graph_with_ghosts([self.start_revid])
79
81
        for revid in graph.ghosts:
80
82
            self.cache_revision(DummyRevision(revid))
81
83
        for revid, parents in graph.get_ancestors().items():
82
 
            self.cache_revision(RevisionProxy(revid, parents, self.branch.repository))
 
84
            self.cache_revision(RevisionProxy(revid, parents, self.repository))
83
85
 
84
86
    def cache_revision(self, revision):
85
87
        "Set the caches for a newly retrieved revision."""
234
236
                self.colours[revid] = self.last_colour = self.last_colour + 1
235
237
 
236
238
 
237
 
def distances(branch, start):
 
239
def distances(repository, start_revid):
238
240
    """Sort the revisions.
239
241
 
240
242
    Traverses the branch revision tree starting at start and produces an
243
245
 
244
246
    Returns a tuple of (revids, revisions, colours, children)
245
247
    """
246
 
    distance = DistanceMethod(branch, start)
 
248
    distance = DistanceMethod(repository, start_revid)
247
249
    distance.fill_caches()
248
 
    distance.merge_sorted = merge_sort(distance.graph, distance.start)
 
250
    distance.merge_sorted = merge_sort(distance.graph, distance.start_revid)
249
251
    children = distance.make_children_map()
250
252
    
251
253
    for seq, revid, merge_depth, end_of_merge in distance.merge_sorted: