Rev 51: Add a progress indicator for chk pages. in http://bazaar.launchpad.net/%7Ebzr/bzr-groupcompress/trunk
John Arbash Meinel
john at arbash-meinel.com
Fri Feb 27 03:55:07 GMT 2009
At http://bazaar.launchpad.net/%7Ebzr/bzr-groupcompress/trunk
------------------------------------------------------------
revno: 51
revision-id: john at arbash-meinel.com-20090227035442-4sk2vcl343hg9afv
parent: john at arbash-meinel.com-20090227033445-gk1o5rr6t0u0d14i
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Thu 2009-02-26 21:54:42 -0600
message:
Add a progress indicator for chk pages.
Fix a bug with handling signatures, which don't have a parent graph
-------------- next part --------------
=== modified file 'groupcompress.py'
--- a/groupcompress.py 2009-02-27 03:34:45 +0000
+++ b/groupcompress.py 2009-02-27 03:54:42 +0000
@@ -110,17 +110,18 @@
"""
# gc-optimal ordering is approximately reverse topological,
# properly grouped by file-id.
- per_prefix_map = {'': []}
+ per_prefix_map = {}
present_keys = []
for item in parent_map.iteritems():
key = item[0]
if isinstance(key, str) or len(key) == 1:
- per_prefix_map[''].append(item)
+ prefix = ''
else:
- try:
- per_prefix_map[key[0]].append(item)
- except KeyError:
- per_prefix_map[key[0]] = [item]
+ prefix = key[0]
+ try:
+ per_prefix_map[prefix].append(item)
+ except KeyError:
+ per_prefix_map[prefix] = [item]
for prefix in sorted(per_prefix_map):
present_keys.extend(reversed(topo_sort(per_prefix_map[prefix])))
@@ -585,7 +586,8 @@
keys = set(orig_keys)
if not keys:
return
- if not self._index.has_graph and ordering == 'topological':
+ if (not self._index.has_graph
+ and ordering in ('topological', 'gc-optimal')):
# Cannot topological order when no graph has been stored.
ordering = 'unordered'
# Cheap: iterate
@@ -604,7 +606,7 @@
# Now group by source:
elif ordering == 'gc-optimal':
parent_map = dict((key, details[2]) for key, details in
- locations.iteritems())
+ locations.iteritems())
for key in local_keys:
parent_map[key] = self._unadded_refs[key]
# XXX: This only optimizes for the target ordering. We may need to
=== modified file 'repofmt.py'
--- a/repofmt.py 2009-02-27 03:04:49 +0000
+++ b/repofmt.py 2009-02-27 03:54:42 +0000
@@ -267,7 +267,7 @@
stream = source_vf.get_record_stream(keys, 'gc-optimal', True)
return _filter_inv_stream(stream), id_roots, p_id_roots
- def _get_chk_stream(self, source_vf, keys, id_roots, p_id_roots):
+ def _get_chk_stream(self, source_vf, keys, id_roots, p_id_roots, pb=None):
# We want to stream the keys from 'id_roots', and things they
# reference, and then stream things from p_id_roots and things they
# reference, and then any remaining keys that we didn't get to.
@@ -309,9 +309,18 @@
cur_keys = []
for prefix in sorted(keys_by_search_prefix):
cur_keys.extend(keys_by_search_prefix[prefix])
+ counter = 0
for record in _get_referenced_stream(id_roots):
+ # We don't know how many total
+ counter += 1
+ if pb is not None:
+ pb.update('chk node', counter)
yield record
for record in _get_referenced_stream(p_id_roots):
+ # We don't know how many total
+ counter += 1
+ if pb is not None:
+ pb.update('chk node', counter)
yield record
if remaining_keys:
trace.note('There were %d keys in the chk index, which'
@@ -320,6 +329,10 @@
stream = source_vf.get_record_stream(remaining_keys, 'unordered',
True)
for record in stream:
+ # We don't know how many total
+ counter += 1
+ if pb is not None:
+ pb.update('chk node', counter)
yield record
def _execute_pack_operations(self, pack_operations, _packer_class=Packer,
@@ -395,16 +408,20 @@
access=target_access,
delta=source_vf._delta)
stream = None
- if has_chk:
- if vf_name == 'inventories':
- stream, id_roots, p_id_roots = self._get_filtered_inv_stream(
- source_vf, keys)
- elif vf_name == 'chk_bytes':
- stream = self._get_chk_stream(source_vf, keys,
- id_roots, p_id_roots)
- if stream is None:
- stream = source_vf.get_record_stream(keys, 'gc-optimal', True)
- target_vf.insert_record_stream(stream)
+ child_pb = ui.ui_factory.nested_progress_bar()
+ try:
+ if has_chk:
+ if vf_name == 'inventories':
+ stream, id_roots, p_id_roots = self._get_filtered_inv_stream(
+ source_vf, keys)
+ elif vf_name == 'chk_bytes':
+ stream = self._get_chk_stream(source_vf, keys,
+ id_roots, p_id_roots, pb=child_pb)
+ if stream is None:
+ stream = source_vf.get_record_stream(keys, 'gc-optimal', True)
+ target_vf.insert_record_stream(stream)
+ finally:
+ child_pb.finished()
new_pack._check_references() # shouldn't be needed
except:
pb.finished()
More information about the bazaar-commits
mailing list