/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: Jelmer Vernooij
  • Date: 2007-07-21 18:40:41 UTC
  • Revision ID: jelmer@samba.org-20070721184041-i27qx95a3ugs8y5t
Use repository rather than branch where possible.

Show diffs side-by-side

added added

removed removed

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