[Pkg-bazaar-commits] ./bzr/unstable r81: show space usage for various stores in the info command

mbp at sourcefrog.net mbp at sourcefrog.net
Fri Apr 10 07:51:05 UTC 2009


------------------------------------------------------------
revno: 81
committer: mbp at sourcefrog.net
timestamp: Thu 2005-03-24 11:44:18 +1100
message:
  show space usage for various stores in the info command
modified:
  NEWS
  bzrlib/info.py
  bzrlib/store.py
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2005-03-23 06:37:30 +0000
+++ b/NEWS	2005-03-24 00:44:18 +0000
@@ -1,5 +1,9 @@
 bzr-0.0.1  NOT RELEASED YET
 
+  ENHANCEMENTS:
+
+    * More information from info command.
+
   PORTABILITY:
 
     * Include a subset of ElementTree-1.2.20040618 to make

=== modified file 'bzrlib/info.py'
--- a/bzrlib/info.py	2005-03-24 00:26:38 +0000
+++ b/bzrlib/info.py	2005-03-24 00:44:18 +0000
@@ -77,12 +77,20 @@
 
     print
     print 'text store:'
-    print '  %5d file texts' % len(b.text_store)
+    c, t = b.text_store.total_size()
+    print '  %5d file texts' % c
+    print '  %5d kB' % (t/1024)
 
     print
     print 'revision store:'
-    print '  %5d revisions' % len(b.revision_store)
+    c, t = b.revision_store.total_size()
+    print '  %5d revisions' % c
+    print '  %5d kB' % (t/1024)
+
 
     print
     print 'inventory store:'
-    print '  %5d inventories' % len(b.inventory_store)
+    c, t = b.inventory_store.total_size()
+    print '  %5d inventories' % c
+    print '  %5d kB' % (t/1024)
+

=== modified file 'bzrlib/store.py'
--- a/bzrlib/store.py	2005-03-24 00:26:38 +0000
+++ b/bzrlib/store.py	2005-03-24 00:44:18 +0000
@@ -24,6 +24,7 @@
 __author__ = "Martin Pool <mbp at canonical.com>"
 
 import os, tempfile, types, osutils
+from stat import ST_SIZE
 from StringIO import StringIO
 from trace import mutter
 
@@ -117,6 +118,15 @@
         """Returns a file reading from a particular entry."""
         return file(self._path(fileid), 'rb')
 
+    def total_size(self):
+        """Return (count, bytes)"""
+        total = 0
+        count = 0
+        for fid in self:
+            count += 1
+            total += os.stat(self._path(fid))[ST_SIZE]
+        return count, total
+
     def delete_all(self):
         for fileid in self:
             self.delete(fileid)



More information about the Pkg-bazaar-commits mailing list