[Pkg-bazaar-commits] ./bzr-gtk/unstable r329: Make broken_line_length setting from higher up.

Jelmer Vernooij jelmer at samba.org
Fri Apr 10 07:49:57 UTC 2009


------------------------------------------------------------
revno: 329
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Wed 2007-10-31 03:18:28 +0100
message:
  Make broken_line_length setting from higher up.
modified:
  viz/branchwin.py
  viz/linegraph.py
  viz/treeview.py
-------------- next part --------------
=== modified file 'viz/branchwin.py'
--- a/viz/branchwin.py	2007-10-30 23:42:27 +0000
+++ b/viz/branchwin.py	2007-10-31 02:18:28 +0000
@@ -100,7 +100,8 @@
 
     def construct_top(self):
         """Construct the top-half of the window."""
-        self.treeview = TreeView(self.branch, self.start, self.maxnum)
+        # FIXME: Make broken_line_length configurable
+        self.treeview = TreeView(self.branch, self.start, self.maxnum, 32)
 
         self.treeview.connect("revision-selected",
                 self._treeselection_changed_cb)

=== modified file 'viz/linegraph.py'
--- a/viz/linegraph.py	2007-10-31 02:11:04 +0000
+++ b/viz/linegraph.py	2007-10-31 02:18:28 +0000
@@ -11,7 +11,7 @@
 
 from bzrlib.tsort import merge_sort
 
-def linegraph(repository, start, maxnum):
+def linegraph(repository, start, maxnum, broken_line_length=None):
     """Produce a directed graph of a bzr repository.
 
     Returns a tuple of (line_graph, revid_index, columns_len) where
@@ -41,9 +41,6 @@
     curved, kinked, etc.) and to pick the actual colours for each index.
     """
     
-    # FIXME: This should be configurable
-    BROKEN_LINE_LENGTH = 32
-    
     graph_parents = repository.get_revision_graph(start)
     graph_children = {}
     for revid in graph_parents.iterkeys():
@@ -150,8 +147,8 @@
         last_rev_index = None
         for rev_index in branch_line:
             if last_rev_index:
-                if BROKEN_LINE_LENGTH and \
-                   rev_index - last_rev_index > BROKEN_LINE_LENGTH:
+                if broken_line_length and \
+                   rev_index - last_rev_index > broken_line_length:
                     line_range.append(last_rev_index+1)
                     line_range.append(rev_index-1)
                 else:
@@ -161,8 +158,8 @@
             last_rev_index = rev_index
         
         if parent_index:
-            if BROKEN_LINE_LENGTH and \
-               parent_index - last_rev_index > BROKEN_LINE_LENGTH:
+            if broken_line_length and \
+               parent_index - last_rev_index > broken_line_length:
                 line_range.append(last_rev_index+1)
             else:
                 line_range.extend(range(last_rev_index+1, parent_index))
@@ -202,8 +199,8 @@
                         
                     # If this line is really long, break it.
                     if len(branch_id) > 0 and \
-                       BROKEN_LINE_LENGTH and \
-                       parent_index - rev_index > BROKEN_LINE_LENGTH:
+                       broken_line_length and \
+                       parent_index - rev_index > broken_line_length:
                         child_line_col_index = \
                             _find_free_column(columns,
                                               empty_column,

=== modified file 'viz/treeview.py'
--- a/viz/treeview.py	2007-10-31 02:11:04 +0000
+++ b/viz/treeview.py	2007-10-31 02:18:28 +0000
@@ -29,13 +29,15 @@
                                   ())
     }
 
-    def __init__(self, branch, start, maxnum):
+    def __init__(self, branch, start, maxnum, broken_line_length=None):
         """Create a new TreeView.
 
         :param branch: Branch object for branch to show.
         :param start: Revision id of top revision.
         :param maxnum: Maximum number of revisions to display, 
                        None for no limit.
+        :param broken_line_length: After how much lines to break 
+                                   branches.
         """
         gtk.ScrolledWindow.__init__(self)
 
@@ -47,7 +49,8 @@
         self.branch = branch
         self.branch.lock_read()
 
-        gobject.idle_add(self.populate, start, maxnum)
+        gobject.idle_add(self.populate, start, maxnum, 
+                         broken_line_length)
 
         self.revision = None
         self.children = None
@@ -117,16 +120,19 @@
             self.treeview.set_cursor(self.index[children[0]])
         self.treeview.grab_focus()
 
-    def populate(self, start, maxnum):
+    def populate(self, start, maxnum, broken_line_length=None):
         """Fill the treeview with contents.
 
         :param start: Revision id of revision to start with.
         :param maxnum: Maximum number of revisions to display, or None 
                        for no limit.
+        :param broken_line_length: After how much lines branches \
+                       should be broken.
         """
         (linegraphdata, index, columns_len) = linegraph(self.branch.repository,
                                                         start,
-                                                        maxnum)
+                                                        maxnum, 
+                                                        broken_line_length)
 
         self.model = TreeModel(self.branch.repository, linegraphdata)
         self.graph_cell.columns_len = columns_len



More information about the Pkg-bazaar-commits mailing list