[Pkg-bazaar-commits] ./bzr/unstable r947: - new 'weave stats' command
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:21:32 UTC 2009
------------------------------------------------------------
revno: 947
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Mon 2005-07-18 15:53:46 -0300
message:
- new 'weave stats' command
modified:
bzrlib/weave.py
-------------- next part --------------
=== modified file 'bzrlib/weave.py'
--- a/bzrlib/weave.py 2005-07-18 16:03:21 +0000
+++ b/bzrlib/weave.py 2005-07-18 18:53:46 +0000
@@ -682,6 +682,33 @@
+def weave_stats(weave_file):
+ from bzrlib.progress import ProgressBar
+ from bzrlib.weavefile import read_weave
+
+ pb = ProgressBar()
+
+ wf = file(weave_file, 'rb')
+ w = read_weave(wf)
+ # FIXME: doesn't work on pipes
+ weave_size = wf.tell()
+
+ total = 0
+ vers = len(w)
+ for i in range(vers):
+ pb.update('checking sizes', i, vers)
+ for line in w.get_iter(i):
+ total += len(line)
+
+ pb.clear()
+
+ print 'versions %9d' % vers
+ print 'weave file %9d bytes' % weave_size
+ print 'total contents %9d bytes' % total
+ print 'compression ratio %9.2fx' % (float(total) / float(weave_size))
+
+
+
def usage():
print """bzr weave tool
@@ -784,6 +811,9 @@
elif cmd == 'info':
weave_info(readit())
+
+ elif cmd == 'stats':
+ weave_stats(argv[2])
elif cmd == 'check':
w = readit()
More information about the Pkg-bazaar-commits
mailing list