Rev 4: Allow wider sizes. in http://people.ubuntu.com/~robertc/baz2.0/plugins/repodetails/trunk

Robert Collins robertc at robertcollins.net
Fri Oct 17 05:51:17 BST 2008


At http://people.ubuntu.com/~robertc/baz2.0/plugins/repodetails/trunk

------------------------------------------------------------
revno: 4
revision-id: robertc at robertcollins.net-20081017045112-a2aqrvtf9hlfh4lh
parent: robertc at robertcollins.net-20081017031930-xo8c5rxqi06qztzd
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Fri 2008-10-17 15:51:12 +1100
message:
  Allow wider sizes.
modified:
  __init__.py                    __init__.py-20081017014933-iriuw53viune2txe-2
  tests/test_repositorydetails.py test_repositorydetai-20081017014933-iriuw53viune2txe-6
=== modified file '__init__.py'
--- a/__init__.py	2008-10-17 03:19:30 +0000
+++ b/__init__.py	2008-10-17 04:51:12 +0000
@@ -129,10 +129,14 @@
     details = vf._index.get_build_details(keys)
     for detail in details.itervalues():
         objectstats.compressed_size += detail[0][2]
-    for entry in vf.get_record_stream(keys, 'unordered', True):
-        bytes = entry.get_bytes_as('fulltext')
-        objectstats.raw_size += len(bytes)
-        yield bytes, entry.key
+    keys = sorted(keys)
+    batch_size = 200
+    for offset in xrange(batch_size):
+        batch = keys[batch_size * offset:batch_size * (offset + 1)]
+        for entry in vf.get_record_stream(batch, 'unordered', True):
+            bytes = entry.get_bytes_as('fulltext')
+            objectstats.raw_size += len(bytes)
+            yield bytes, entry.key
 
 
 def _gather_chk_inv(objectstats, repo):
@@ -204,7 +208,7 @@
         # Mangle the percentages for very small repos to avoid divide by zero.
         raw_percent = (objectstats.raw_size + 1)*100/(total.raw_size + 1)
         compressed_percent = (objectstats.compressed_size + 1)*100/(total.compressed_size + 1)
-        return "%6d KiB %3d%%  %6d KiB %3d%%  %7d" % (objectstats.raw_size/1024,
+        return "%7d KiB %3d%%  %7d KiB %3d%%  %7d" % (objectstats.raw_size/1024,
             raw_percent, objectstats.compressed_size/1024, compressed_percent,
             objectstats.objects)
 
@@ -212,7 +216,7 @@
         repo = repository.Repository.open(path)
         stats = gather_stats(repo)
         self.outf.write("Commits: %d\n" % stats.revision_count)
-        self.outf.write("                    Raw    %  Compressed    %  Objects\n")
+        self.outf.write("                     Raw    %   Compressed    %  Objects\n")
         self.outf.write("Revisions:   %s\n" %
             self._format_object(stats.revisions, stats.total))
         self.outf.write("Inventories: %s\n" %

=== modified file 'tests/test_repositorydetails.py'
--- a/tests/test_repositorydetails.py	2008-10-17 03:11:36 +0000
+++ b/tests/test_repositorydetails.py	2008-10-17 04:51:12 +0000
@@ -32,12 +32,12 @@
         out, err = self.run_bzr(["repository-details"])
         self.assertEqual(
             "Commits: 1\n"
-            "                    Raw    %  Compressed    %  Objects\n"
-            "Revisions:        0 KiB  53%       0 KiB  45%        1\n"
-            "Inventories:      0 KiB  44%       0 KiB  35%        1\n"
-            "Texts:            0 KiB   2%       0 KiB  19%        1\n"
-            "Signatures:       0 KiB   0%       0 KiB   0%        0\n"
-            "Total:            0 KiB 100%       0 KiB 100%        3\n"
+            "                     Raw    %   Compressed    %  Objects\n"
+            "Revisions:         0 KiB  53%        0 KiB  45%        1\n"
+            "Inventories:       0 KiB  44%        0 KiB  35%        1\n"
+            "Texts:             0 KiB   2%        0 KiB  19%        1\n"
+            "Signatures:        0 KiB   0%        0 KiB   0%        0\n"
+            "Total:             0 KiB 100%        0 KiB 100%        3\n"
             , out)
         self.assertEqual("", err)
 




More information about the bazaar-commits mailing list