[Pkg-bazaar-commits] ./bzr-gtk/unstable r279: Merge John's patch to speed up 'bzr viz --limit'.
Szilveszter Farkas (Phanatic)
Szilveszter.Farkas at gmail.com
Fri Apr 10 07:45:26 UTC 2009
------------------------------------------------------------
revno: 279
committer: Szilveszter Farkas (Phanatic) <Szilveszter.Farkas at gmail.com>
branch nick: trunk
timestamp: Sat 2007-09-22 17:31:05 +0200
message:
Merge John's patch to speed up 'bzr viz --limit'.
modified:
viz/branchwin.py
viz/graph.py
------------------------------------------------------------
revno: 278.1.1
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: gtk_limit
timestamp: Fri 2007-09-21 12:42:04 -0500
message:
Pass in the maxnum value to the distances function.
That way we can avoid actually reading all Revisions for the entire
graph.
modified:
viz/branchwin.py
viz/graph.py
-------------- next part --------------
=== modified file 'viz/branchwin.py'
--- a/viz/branchwin.py 2007-09-15 14:42:19 +0000
+++ b/viz/branchwin.py 2007-09-21 17:42:04 +0000
@@ -184,7 +184,8 @@
last_lines = []
(self.revisions, colours, self.children, self.parent_ids,
- merge_sorted) = distances(self.branch.repository, start)
+ merge_sorted) = distances(self.branch.repository, start,
+ maxnum=maxnum)
for (index, (revision, node, lines)) in enumerate(graph(
self.revisions, colours, merge_sorted)):
# FIXME: at this point we should be able to show the graph order
=== modified file 'viz/graph.py'
--- a/viz/graph.py 2007-07-21 18:40:41 +0000
+++ b/viz/graph.py 2007-09-21 17:42:04 +0000
@@ -68,7 +68,6 @@
self.repository = repository
self.start_revid = start_revid
self.revisions = {}
- self.children = {}
self.children_of_id = {start_revid: set()}
self.parent_ids_of = {}
self.colours = { start_revid: 0 }
@@ -162,6 +161,10 @@
self.distances = distances
return sorted(distances, key=distances.get)
+ def choose_null_colour(self, revid):
+ """We know we don't need this color, so just set it to NULL"""
+ self.colours[revid] = 0
+
def choose_colour(self, revid):
revision = self.revisions[revid]
children_of_id = self.children_of_id
@@ -236,7 +239,7 @@
self.colours[revid] = self.last_colour = self.last_colour + 1
-def distances(repository, start_revid):
+def distances(repository, start_revid, maxnum=None):
"""Sort the revisions.
Traverses the branch revision tree starting at start and produces an
@@ -250,8 +253,13 @@
distance.merge_sorted = merge_sort(distance.graph, distance.start_revid)
children = distance.make_children_map()
+ count = 0
for seq, revid, merge_depth, end_of_merge in distance.merge_sorted:
- distance.choose_colour(revid)
+ count += 1
+ if maxnum is not None and count > maxnum:
+ distance.choose_null_colour(revid)
+ else:
+ distance.choose_colour(revid)
revisions = distance.revisions
colours = distance.colours
More information about the Pkg-bazaar-commits
mailing list