stop_at = lambda x: x.decode('hex') in trees_visited
approx_live_count = 0
for ref_name, ref_id in git.list_refs():
- for item in walk_object(cat_pipe, ref_id.encode('hex'),
+ for item in walk_object(cat_pipe.get, ref_id.encode('hex'),
stop_at=stop_at,
include_data=None):
# FIXME: batch ids
# ...
-def walk_object(cat_pipe, oidx,
- stop_at=None,
- include_data=None):
- """Yield everything reachable from oidx via cat_pipe as a WalkItem,
- stopping whenever stop_at(oidx) returns true. Throw MissingObject
- if a hash encountered is missing from the repository, and don't
- read or return blob content in the data field unless include_data
- is set.
+def walk_object(get_ref, oidx, stop_at=None, include_data=None):
+ """Yield everything reachable from oidx via get_ref (which must behave
+ like CatPipe get) as a WalkItem, stopping whenever stop_at(oidx)
+ returns true. Throw MissingObject if a hash encountered is
+ missing from the repository, and don't read or return blob content
+ in the data field unless include_data is set.
+
"""
# Maintain the pending stack on the heap to avoid stack overflow
pending = [(oidx, [], [], None)]
data=None)
continue
- item_it = cat_pipe.get(oidx)
+ item_it = get_ref(oidx)
get_oidx, typ, _ = next(item_it)
if not get_oidx:
raise MissingObject(oidx.decode('hex'))