Rev 3: Clean up some var names in http://bzr.arbash-meinel.com/plugins/per_file_graph

John Arbash Meinel john at arbash-meinel.com
Thu Oct 29 15:42:23 GMT 2009


At http://bzr.arbash-meinel.com/plugins/per_file_graph

------------------------------------------------------------
revno: 3
revision-id: john at arbash-meinel.com-20091029154207-ytmk9o5cc8z7k5c2
parent: john at arbash-meinel.com-20091029154149-mm48de8ndfczj3qt
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: per_file_graph
timestamp: Thu 2009-10-29 10:42:07 -0500
message:
  Clean up some var names
-------------- next part --------------
=== modified file 'simple_btree.py'
--- a/simple_btree.py	2009-10-29 15:18:30 +0000
+++ b/simple_btree.py	2009-10-29 15:42:07 +0000
@@ -16,7 +16,7 @@
 
 """A per-file graph that just stores the simple values in a btree."""
 
-from bzrlib import btree_index, ui
+from bzrlib import btree_index
 
 from bzrlib.plugins.per_file_graph import builder
 
@@ -24,40 +24,37 @@
 class SimpleBTreeBuilder(builder.Builder):
     """Builds a simple BTreeGraphIndex with no 'values'."""
 
-    def build(self):
+    def _build(self):
         """Actually build the index."""
         parent_map = self.get_per_file_graph()
         # Avoid spilling to disk, it takes time, but more importantly, if we
         # change the page size, then we will fail to read the index that was
         # spilled
-        builder = btree_index.BTreeBuilder(reference_lists=1, key_elements=2,
-                                           spill_at=1*1000*1000)
+        btbuilder = btree_index.BTreeBuilder(reference_lists=1, key_elements=2,
+                                             spill_at=1*1000*1000)
+        btbuilder.set_optimize(for_size=True)
         total = len(parent_map)
-        pb = ui.ui_factory.nested_progress_bar()
-        try:
-            count = 0
-            for key, parents in parent_map.iteritems():
-                count += 1
-                if count & 0xFF == 0:
-                    pb.update('building', count, total)
-                builder.add_node(key, '', (parents,))
-            self.mark_writing(pb, total, builder)
-            self.finish(builder)
-        finally:
-            pb.finished()
+        count = 0
+        for key, parents in parent_map.iteritems():
+            count += 1
+            if count & 0xFF == 0:
+                self.update('building', count, total)
+            btbuilder.add_node(key, '', (parents,))
+        self.mark_writing(total, btbuilder)
+        self.finish(btbuilder)
 
-    def mark_writing(self, pb, total, builder):
+    def mark_writing(self, total, btbuilder):
         """Just override some btree functions to give progress indication."""
-        orig = builder.iter_all_entries
+        orig = btbuilder.iter_all_entries
         def iter_all_entries():
             for idx, e in enumerate(orig()):
                 if idx & 0xFF:
-                    pb.update('writing', idx, total)
+                    self.update('writing', idx, total)
                 yield e
-        builder.iter_all_entries = iter_all_entries
+        btbuilder.iter_all_entries = iter_all_entries
 
-    def finish(self, builder):
-        stream = builder.finish()
+    def finish(self, btbuilder):
+        stream = btbuilder.finish()
         self.transport.put_file(self.filename, stream)
 
 
@@ -70,11 +67,11 @@
 
     _NEW_PAGE_SIZE = 8*1024
 
-    def finish(self, builder):
+    def finish(self, btbuilder):
         old = btree_index._PAGE_SIZE
         try:
             btree_index._PAGE_SIZE = self._NEW_PAGE_SIZE
-            super(SimpleBTreeBuilder8k, self).finish(builder)
+            super(SimpleBTreeBuilder8k, self).finish(btbuilder)
         finally:
             btree_index._PAGE_SIZE = old
 



More information about the bazaar-commits mailing list