Rev 11: Add progress bars to make the wait slightly more bearable. in http://bazaar.launchpad.net/%7Ebzr/bzr-repodetails/trunk
John Arbash Meinel
john at arbash-meinel.com
Tue Dec 2 02:25:58 GMT 2008
At http://bazaar.launchpad.net/%7Ebzr/bzr-repodetails/trunk
------------------------------------------------------------
revno: 11
revision-id: john at arbash-meinel.com-20081202020220-xx65k70hbx2ai9ne
parent: john at arbash-meinel.com-20081202014502-40sghjisv1lflwhb
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Mon 2008-12-01 20:02:20 -0600
message:
Add progress bars to make the wait slightly more bearable.
-------------- next part --------------
=== modified file 'gather_stats.py'
--- a/gather_stats.py 2008-12-02 01:45:02 +0000
+++ b/gather_stats.py 2008-12-02 02:02:20 +0000
@@ -22,7 +22,7 @@
import math
-from bzrlib import chk_map, repository
+from bzrlib import chk_map, repository, ui
from bzrlib.inventory import CHKInventory
from bzrlib.repofmt.pack_repo import (
RepositoryFormatKnitPack1,
@@ -168,12 +168,14 @@
repo.unlock()
-def _gather_object_vf_texts(objectstats, vf):
- for text in _gather_and_iter_object_vf_texts(objectstats, vf):
+def _gather_object_vf_texts(objectstats, vf, kind=None):
+ for text in _gather_and_iter_object_vf_texts(objectstats, vf, kind=kind):
pass
-def _gather_and_iter_object_vf_texts(objectstats, vf, keys=None):
+def _gather_and_iter_object_vf_texts(objectstats, vf, keys=None, kind=None):
+ if kind is None:
+ kind = '<unknown>'
if keys is None:
keys = vf.keys()
objectstats.objects += len(keys)
@@ -183,12 +185,17 @@
objectstats.add_compressed_size(detail[0][2])
keys = sorted(keys)
batch_size = 200
- for offset in xrange(0, len(keys), batch_size):
- batch = keys[offset:offset + batch_size]
- for entry in vf.get_record_stream(batch, 'unordered', True):
- bytes = entry.get_bytes_as('fulltext')
- objectstats.add_raw_size(len(bytes))
- yield bytes, entry.key
+ pb = ui.ui_factory.nested_progress_bar()
+ try:
+ for offset in xrange(0, len(keys), batch_size):
+ pb.update(kind, offset, len(keys))
+ batch = keys[offset:offset + batch_size]
+ for entry in vf.get_record_stream(batch, 'unordered', True):
+ bytes = entry.get_bytes_as('fulltext')
+ objectstats.add_raw_size(len(bytes))
+ yield bytes, entry.key
+ finally:
+ pb.finished()
def _gather_chk_map(objectstats, chk_bytes, pending, internal_counter,
@@ -201,7 +208,8 @@
done.update(pending)
next = pending
pending = set()
- for bytes, key in _gather_and_iter_object_vf_texts(objectstats, chk_bytes, next):
+ for bytes, key in _gather_and_iter_object_vf_texts(objectstats,
+ chk_bytes, next, kind='chk'):
node = chk_map._deserialise(bytes, key)
refs = node.refs()
pending.update(refs)
@@ -220,7 +228,8 @@
# first pass: the inventory objects yield chk dicts:
pending = set()
pending_parent_id = set()
- for bytes, key in _gather_and_iter_object_vf_texts(objectstats, repo.inventories):
+ for bytes, key in _gather_and_iter_object_vf_texts(objectstats,
+ repo.inventories, kind='inv'):
inv = CHKInventory.deserialise(repo.chk_bytes, bytes, key)
pending.add(inv.id_to_entry._root_node)
if inv.parent_id_basename_to_file_id is not None:
@@ -240,21 +249,24 @@
keys = repo.revisions.keys()
result.revision_count = len(keys)
if isinstance(repo._format, pack_rev_types):
- _gather_object_vf_texts(result.revisions, repo.revisions)
+ _gather_object_vf_texts(result.revisions, repo.revisions, kind='revs')
else:
raise AssertionError("Don't know how to process %r" % repo)
if isinstance(repo._format, pack_xml_inv_types):
- _gather_object_vf_texts(result.inventories, repo.inventories)
+ _gather_object_vf_texts(result.inventories, repo.inventories,
+ kind='inv')
elif isinstance(repo._format, pack_chk_inv_types):
_gather_chk_inv(result.inventories, repo)
else:
raise AssertionError("Don't know how to process %r" % repo)
if isinstance(repo._format, pack_text_types):
- _gather_object_vf_texts(result.texts, repo.texts)
+ _gather_object_vf_texts(result.texts, repo.texts,
+ kind='texts')
else:
raise AssertionError("Don't know how to process %r" % repo)
if isinstance(repo._format, pack_signature_types):
- _gather_object_vf_texts(result.signatures, repo.signatures)
+ _gather_object_vf_texts(result.signatures, repo.signatures,
+ kind='sigs')
else:
raise AssertionError("Don't know how to process %r" % repo)
result.total = ObjectStats()
More information about the bazaar-commits
mailing list