message=matches['message'])
-def get_commit_items(id, cp):
- commit_it = cp.get(id)
- _, typ, _ = next(commit_it)
- assert(typ == 'commit')
- commit_content = ''.join(commit_it)
- return parse_commit(commit_content)
+def get_cat_data(cat_iterator, expected_type):
+ _, kind, _ = next(cat_iterator)
+ if kind != expected_type:
+ raise Exception('expected %r, saw %r' % (expected_type, kind))
+ return ''.join(cat_iterator)
+def get_commit_items(id, cp):
+ return parse_commit(get_cat_data(cp.get(id), 'commit'))
def _local_git_date_str(epoch_sec):
return '%d %s' % (epoch_sec, utc_offset_str(epoch_sec))
# ...
-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'))