class documentation
class Pack:
Constructors: Pack.from_lazy_objects(data_fn, idx_fn), Pack.from_objects(data, idx), Pack(basename, object_format, resolve_ext_ref, delta_window_size, ...)
A Git pack object.
| Class Method | from |
Create a new pack object from callables to load pack data and index objects. |
| Class Method | from |
Create a new pack object from pack data and index objects. |
| Method | __contains__ |
Check whether this pack contains a particular SHA1. |
| Method | __del__ |
Ensure pack file is closed when Pack is garbage collected. |
| Method | __enter__ |
Enter context manager. |
| Method | __eq__ |
Check equality with another pack. |
| Method | __exit__ |
Exit context manager. |
| Method | __getitem__ |
Retrieve the specified SHA1. |
| Method | __init__ |
Initialize a Pack object. |
| Method | __iter__ |
Iterate over all the sha1s of the objects in this pack. |
| Method | __len__ |
Number of entries in this pack. |
| Method | __repr__ |
Return string representation of this pack. |
| Method | check |
Check the integrity of this pack. |
| Method | check |
Sanity check the length and checksum of the pack index and data. |
| Method | close |
Close the pack file and index. |
| Method | ensure |
Ensure a bitmap exists for this pack, generating one if needed. |
| Method | entries |
Yield entries summarizing the contents of this pack. |
| Method | get |
Get raw object data by SHA1. |
| Method | get |
Get the object for a ref SHA, only looking in this pack. |
| Method | get |
Return the stored checksum of the pack data. |
| Method | get |
Get the unpacked object for a sha. |
| Method | iter |
Iterate over all unpacked objects in this pack. |
| Method | iter |
Iterate over unpacked objects in subset. |
| Method | iterobjects |
Iterate over the objects in this pack. |
| Method | iterobjects |
Iterate over a subset of objects in this pack. |
| Method | keep |
Add a .keep file for the pack, preventing git from garbage collecting it. |
| Method | name |
The SHA over the SHAs of the objects in this pack. |
| Method | pack |
Return pack tuples for all objects in pack. |
| Method | resolve |
Resolve an object, possibly resolving deltas when necessary. |
| Method | sorted |
Return entries in this pack, sorted by SHA. |
| Instance Variable | big |
Undocumented |
| Instance Variable | delta |
Undocumented |
| Instance Variable | delta |
Undocumented |
| Instance Variable | delta |
Undocumented |
| Instance Variable | depth |
Undocumented |
| Instance Variable | object |
Undocumented |
| Instance Variable | resolve |
Undocumented |
| Instance Variable | threads |
Undocumented |
| Instance Variable | window |
Undocumented |
| Property | bitmap |
The bitmap being used, if available. |
| Property | data |
The pack data object being used. |
| Property | index |
The index being used. |
| Property | mmap |
Return the total mmapped memory usage of this pack. |
| Instance Variable | _basename |
Undocumented |
| Instance Variable | _bitmap |
Undocumented |
| Instance Variable | _bitmap |
Undocumented |
| Instance Variable | _data |
Undocumented |
| Instance Variable | _data |
Undocumented |
| Instance Variable | _data |
Undocumented |
| Instance Variable | _idx |
Undocumented |
| Instance Variable | _idx |
Undocumented |
| Instance Variable | _idx |
Undocumented |
def from_lazy_objects(cls, data_fn:
Callable[ [], PackData], idx_fn: Callable[ [], PackIndex]) -> Pack:
¶
Create a new pack object from callables to load pack data and index objects.
def __exit__(self, exc_type:
type | None, exc_val: BaseException | None, exc_tb: TracebackType | None):
¶
Exit context manager.
def __init__(self, basename:
str, *, object_format: ObjectFormat, resolve_ext_ref: ResolveExtRefFn | None = None, delta_window_size: int | None = None, window_memory: int | None = None, delta_cache_size: int | None = None, depth: int | None = None, threads: int | None = None, big_file_threshold: int | None = None, delta_base_cache_limit: int | None = None):
¶
Initialize a Pack object.
| Parameters | |
basename:str | Base path for pack files (without .pack/.idx extension) |
objectObjectFormat | Hash algorithm used by the repository |
resolveResolveExtRefFn | None | Optional function to resolve external references |
deltaint | None | Size of the delta compression window |
windowint | None | Memory limit for delta compression window |
deltaint | None | Size of the delta cache |
depth:int | None | Maximum depth for delta chains |
threads:int | None | Number of threads to use for operations |
bigint | None | Size threshold for big file handling |
deltaint | None | Maximum bytes for delta base object cache |
def ensure_bitmap(self, object_store:
BaseObjectStore, refs: dict[ Ref, ObjectID], commit_interval: int | None = None, progress: Callable[ [ str], None] | None = None) -> PackBitmap:
¶
Ensure a bitmap exists for this pack, generating one if needed.
| Parameters | |
objectBaseObjectStore | Object store to read objects from |
refs:dict[ | Dictionary of ref names to commit SHAs |
commitint | None | Include every Nth commit in bitmap index |
progress:Callable[ | Optional progress reporting callback |
| Returns | |
PackBitmap | PackBitmap instance (either existing or newly generated) |
def get_unpacked_object(self, sha:
ObjectID | RawObjectID, *, include_comp: bool = False, convert_ofs_delta: bool = True) -> UnpackedObject:
¶
Get the unpacked object for a sha.
| Parameters | |
sha:ObjectID | RawObjectID | SHA of object to fetch |
includebool | Whether to include compression data in UnpackedObject |
convertbool | Whether to convert offset deltas to ref deltas |
| Returns | |
UnpackedObject | Undocumented |
def iter_unpacked_subset(self, shas:
Iterable[ ObjectID | RawObjectID], *, include_comp: bool = False, allow_missing: bool = False, convert_ofs_delta: bool = False) -> Iterator[ UnpackedObject]:
¶
Iterate over unpacked objects in subset.
def iterobjects_subset(self, shas:
Iterable[ ObjectID], *, allow_missing: bool = False) -> Iterator[ ShaFile]:
¶
Iterate over a subset of objects in this pack.
def resolve_object(self, offset:
int, type: int, obj: OldUnpackedObject, get_ref: Callable[ [ (RawObjectID | ObjectID)], tuple[ int | None, int, OldUnpackedObject]] | None = None) -> tuple[ int, OldUnpackedObject]:
¶
Resolve an object, possibly resolving deltas when necessary.
Returns: Tuple with object type and contents.
The bitmap being used, if available.
| Returns | |
| PackBitmap instance or None if no bitmap exists |
| Raises | |
ValueError | If bitmap file is invalid or corrupt |