Rev 279: Pass in the maxnum value to the distances function. in http://bzr.arbash-meinel.com/branches/bzr/gtk/gtk_limit

John Arbash Meinel john at arbash-meinel.com
Fri Sep 21 18:48:23 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/gtk/gtk_limit

------------------------------------------------------------
revno: 279
revision-id: john at arbash-meinel.com-20070921174204-ux87radq4k80m8zg
parent: szilveszter.farkas at gmail.com-20070917212330-4hpgmm4rb6gxbs6u
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               branchwin.py-20051016222514-15fd120652fcf25c
  viz/graph.py                   graph.py-20051016214152-ebf565808c860cf7
-------------- 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 bazaar-commits mailing list