class documentation

Abstract iterator over pack data based on delta chains.

Each object in the pack is guaranteed to be inflated exactly once, regardless of how many objects reference it as a delta base. As a result, memory usage is proportional to the length of the longest delta chain.

Subclasses can override _result to define the result type of the iterator. By default, results are UnpackedObjects with the following members set:

  • offset
  • obj_type_num
  • obj_chunks
  • pack_type_num
  • delta_base (for delta types)
  • comp_chunks (if _include_comp is True)
  • decomp_chunks
  • decomp_len
  • crc32 (if _compute_crc32 is True)
Class Method for_pack_data Create a DeltaChainIterator from pack data.
Class Method for_pack_subset Create a DeltaChainIterator for a subset of objects.
Method __init__ Initialize DeltaChainIterator.
Method __iter__ Iterate over objects in the pack.
Method ext_refs Return external references.
Method record Record an unpacked object for later processing.
Method set_pack_data Set the pack data for iteration.
Instance Variable hash_func Undocumented
Method _ensure_no_pending Undocumented
Method _follow_chain Undocumented
Method _resolve_object Undocumented
Method _result Undocumented
Method _walk_all_chains Undocumented
Method _walk_ref_chains Undocumented
Class Variable _compute_crc32 Undocumented
Class Variable _include_comp Undocumented
Instance Variable _ext_refs Undocumented
Instance Variable _file Undocumented
Instance Variable _full_ofs Undocumented
Instance Variable _pending_ofs Undocumented
Instance Variable _pending_ref Undocumented
Instance Variable _resolve_ext_ref Undocumented
def for_pack_data(cls, pack_data: PackData, resolve_ext_ref: ResolveExtRefFn | None = None) -> DeltaChainIterator[T]:

Create a DeltaChainIterator from pack data.

Parameters
pack_data:PackDataPackData object to iterate
resolve_ext_ref:ResolveExtRefFn | NoneOptional function to resolve external refs
Returns
DeltaChainIterator[T]DeltaChainIterator instance
def for_pack_subset(cls, pack: Pack, shas: Iterable[ObjectID | RawObjectID], *, allow_missing: bool = False, resolve_ext_ref: ResolveExtRefFn | None = None) -> DeltaChainIterator[T]:

Create a DeltaChainIterator for a subset of objects.

Parameters
pack:PackPack object containing the data
shas:Iterable[ObjectID | RawObjectID]Iterable of object SHAs to include
allow_missing:boolIf True, skip missing objects
resolve_ext_ref:ResolveExtRefFn | NoneOptional function to resolve external refs
Returns
DeltaChainIterator[T]DeltaChainIterator instance
def __init__(self, file_obj: IO[bytes] | None, hash_func: Callable[[], HashObject], *, resolve_ext_ref: ResolveExtRefFn | None = None):

Initialize DeltaChainIterator.

Parameters
file_obj:IO[bytes] | NoneFile object to read pack data from
hash_func:Callable[[], HashObject]Hash function to use for computing object IDs
resolve_ext_ref:ResolveExtRefFn | NoneOptional function to resolve external references
def __iter__(self) -> Iterator[T]:

Iterate over objects in the pack.

def ext_refs(self) -> list[RawObjectID]:

Return external references.

def record(self, unpacked: UnpackedObject):

Record an unpacked object for later processing.

Parameters
unpacked:UnpackedObjectUnpackedObject to record
def set_pack_data(self, pack_data: PackData):

Set the pack data for iteration.

Parameters
pack_data:PackDataPackData object to use
hash_func =

Undocumented

def _ensure_no_pending(self):

Undocumented

def _follow_chain(self, offset: int, obj_type_num: int, base_chunks: list[bytes] | None) -> Iterator[T]:

Undocumented

def _resolve_object(self, offset: int, obj_type_num: int, base_chunks: list[bytes] | None) -> UnpackedObject:

Undocumented

def _walk_all_chains(self) -> Iterator[T]:

Undocumented

def _walk_ref_chains(self) -> Iterator[T]:

Undocumented

_compute_crc32: bool =

Undocumented

_include_comp: bool =

Undocumented

_ext_refs: list[RawObjectID] =

Undocumented

_file =

Undocumented

_full_ofs: list[tuple[int, int]] =

Undocumented

_pending_ofs: dict[int, list[int]] =

Undocumented

_pending_ref: dict[bytes, list[int]] =

Undocumented

_resolve_ext_ref =

Undocumented