class PackBasedObjectStore(PackCapableObjectStore, PackedObjectContainer):
Known subclasses: dulwich.object_store.BucketBasedObjectStore, dulwich.object_store.DiskObjectStore
Constructor: PackBasedObjectStore(pack_compression_level, pack_index_version, pack_delta_window_size, pack_window_memory, ...)
Object store that uses pack files for storage.
This class provides a base implementation for object stores that use Git pack files as their primary storage mechanism. It handles caching of open pack files and provides configuration for pack file operations.
| Method | __contains__ |
Check if a particular object is present by SHA1. |
| Method | __del__ |
Warn if the object store is being deleted with unclosed packs. |
| Method | __init__ |
Initialize a PackBasedObjectStore. |
| Method | __iter__ |
Iterate over the SHAs that are present in this store. |
| Method | add |
Add a set of objects to this object store. |
| Method | add |
Add a new pack to this object store. |
| Method | add |
Add pack data to this object store. |
| Method | close |
Close the object store and release resources. |
| Method | contains |
Check if a particular object is present by SHA1 and is loose. |
| Method | contains |
Check if a particular object is present by SHA1 and is packed. |
| Method | count |
Count the number of pack files. |
| Method | delete |
Delete a loose object. |
| Method | generate |
Generate bitmap indexes for all packs that don't have them. |
| Method | generate |
Generate pack data objects for a set of wants/haves. |
| Method | get |
Obtain the raw fulltext for an object. |
| Method | get |
Get the best reachability provider for the object store. |
| Method | get |
Obtain the unpacked object. |
| Method | iter |
Iterate over a subset of objects, yielding UnpackedObject instances. |
| Method | iterobjects |
Iterate over a subset of objects in the store. |
| Method | pack |
Pack loose objects. |
| Method | repack |
Repack the packs in this repository. |
| Instance Variable | delta |
Undocumented |
| Instance Variable | pack |
Undocumented |
| Instance Variable | pack |
Undocumented |
| Instance Variable | pack |
Undocumented |
| Instance Variable | pack |
Undocumented |
| Instance Variable | pack |
Undocumented |
| Instance Variable | pack |
Undocumented |
| Instance Variable | pack |
Undocumented |
| Instance Variable | pack |
Undocumented |
| Instance Variable | packed |
Undocumented |
| Property | alternates |
Return list of alternate object stores. |
| Property | packs |
List with pack objects. |
| Method | _add |
Add a newly appeared pack to the cache by path. |
| Method | _clear |
Undocumented |
| Method | _enforce |
Evict least-recently-used packs if the memory limit is exceeded. |
| Method | _get |
Undocumented |
| Method | _iter |
Iterate over the SHAs of all the objects in alternate stores. |
| Method | _iter |
Undocumented |
| Method | _iter |
Iterate over the SHAs of all loose objects. |
| Method | _mark |
Mark a pack as recently used for LRU tracking. |
| Method | _remove |
Undocumented |
| Method | _total |
Return the total mmapped memory across all cached packs. |
| Method | _update |
Undocumented |
| Instance Variable | _pack |
Undocumented |
| Instance Variable | _pack |
Undocumented |
Inherited from BaseObjectStore (via PackCapableObjectStore):
| Method | __getitem__ |
Obtain an object by SHA1. |
| Method | add |
Add a single object to this object store. |
| Method | determine |
Determine which objects are wanted based on refs. |
| Method | find |
Find which revisions this store has in common using graphwalker. |
| Method | find |
Find the missing objects required for a set of revisions. |
| Method | get |
Get the commit graph for this object store. |
| Method | get |
Get the modification time of an object. |
| Method | iter |
Iterate over all SHA1s that start with a given prefix. |
| Method | iter |
Iterate the contents of a tree and all subtrees. |
| Method | peel |
Peel all tags from a SHA. |
| Method | prune |
Prune/clean up this object store. |
| Method | tree |
Find the differences between the contents of two trees. |
| Method | write |
Write a commit graph file for this object store. |
| Instance Variable | object |
Undocumented |
| Method | _get |
Return the current available depth for the given head. |
Check if a particular object is present by SHA1.
This method makes no distinction between loose and packed objects.
int = -1, pack_index_version: int | None = None, pack_delta_window_size: int | None = None, pack_window_memory: int | None = None, pack_delta_cache_size: int | None = None, pack_depth: int | None = None, pack_threads: int | None = None, pack_big_file_threshold: int | None = None, *, packed_git_limit: int | None = None, delta_base_cache_limit: int | None = None, object_format: ObjectFormat | None = None):
¶
Initialize a PackBasedObjectStore.
| Parameters | |
packint | Compression level for pack files (-1 to 9) |
packint | None | Pack index version to use |
packint | None | Window size for delta compression |
packint | None | Maximum memory to use for delta window |
packint | None | Cache size for delta operations |
packint | None | Maximum depth for pack deltas |
packint | None | Number of threads to use for packing |
packint | None | Threshold for treating files as "big" |
packedint | None | Maximum total bytes for mmapped pack files. When exceeded, least-recently-used packs are closed to free memory. |
deltaint | None | Maximum bytes for caching delta base objects. Controls memory used to cache resolved base objects during delta unpacking, corresponding to Git's core.deltaBaseCacheLimit. |
objectObjectFormat | None | Hash algorithm to use |
Sequence[ tuple[ ShaFile, str | None]], progress: Callable[ [ str], None] | None = None) -> Pack | None:
¶
Add a set of objects to this object store.
Returns: Pack object of the objects written.
| Parameters | |
objects:Sequence[ | Iterable over (object, path) tuples, should support __len__. |
progress:Callable[ | Optional progress reporting function. |
| Returns | |
Pack | None | Undocumented |
int, unpacked_objects: Iterator[ UnpackedObject], progress: Callable[ ..., None] | None = None) -> Pack | None:
¶
dulwich.object_store.DiskObjectStoreClose the object store and release resources.
This method closes all cached pack files and frees associated resources. Can be called multiple times safely.
dulwich.object_store.DiskObjectStoreCheck if a particular object is present by SHA1 and is packed.
This does not check alternates.
Delete a loose object.
This method only handles loose objects. For packed objects, use repack(exclude=...) to exclude them during repacking.
dict[ Ref, ObjectID], *, commit_interval: int | None = None, progress: Callable[ [ str], None] | None = None) -> int:
¶
Generate bitmap indexes for all packs that don't have them.
This generates .bitmap files for packfiles, enabling fast reachability queries. Equivalent to the bitmap generation part of 'git repack -b'.
| Parameters | |
refs:dict[ | Dictionary of ref names to commit SHAs |
commitint | None | Include every Nth commit in bitmap index (None for default) |
progress:Callable[ | Optional progress reporting callback |
| Returns | |
int | Number of bitmaps generated |
Iterable[ ObjectID], want: Iterable[ ObjectID], *, shallow: Set[ ObjectID] | None = None, progress: Callable[ ..., None] | None = None, ofs_delta: bool = True) -> tuple[ int, Iterator[ UnpackedObject]]:
¶
Generate pack data objects for a set of wants/haves.
| Parameters | |
have:Iterable[ | List of SHA1s of objects that should not be sent |
want:Iterable[ | List of SHA1s of objects that should be sent |
shallow:Set[ | Set of shallow commit SHA1s to skip |
progress:Callable[ | Optional progress reporting method |
ofsbool | Whether OFS deltas can be included |
| Returns | |
tuple[ | Undocumented |
dulwich.object_store.DiskObjectStoreObtain the raw fulltext for an object.
Returns: tuple with numeric type and object contents.
| Parameters | |
name:RawObjectID | ObjectID | sha for the object. |
| Returns | |
tuple[ | Undocumented |
Get the best reachability provider for the object store.
| Parameters | |
preferbool | Whether to use bitmaps if available |
| Returns | |
ObjectReachabilityProvider | ObjectReachabilityProvider implementation (either bitmap-accelerated or graph traversal) |
Obtain the unpacked object.
| Parameters | |
sha1:bytes | sha for the object. |
includebool | Whether to include compression metadata. |
| Returns | |
UnpackedObject | Undocumented |
Iterable[ ObjectID | RawObjectID], include_comp: bool = False, allow_missing: bool = False, convert_ofs_delta: bool = True) -> Iterator[ UnpackedObject]:
¶
Iterate over a subset of objects, yielding UnpackedObject instances.
| Parameters | |
shas:Iterable[ | Set of object SHAs to retrieve |
includebool | Whether to include compressed data |
allowbool | If True, skip missing objects; if False, raise KeyError |
convertbool | Whether to convert OFS_DELTA objects |
| Returns | |
Iterator[ | Iterator of UnpackedObject instances |
| Raises | |
KeyError | If an object is missing and allow_missing is False |
Iterable[ ObjectID], *, allow_missing: bool = False) -> Iterator[ ShaFile]:
¶
Iterate over a subset of objects in the store.
This method searches for objects in pack files, alternates, and loose storage.
| Parameters | |
shas:Iterable[ | Iterable of object SHAs to retrieve |
allowbool | If True, skip missing objects; if False, raise KeyError |
| Returns | |
Iterator[ | Iterator of ShaFile objects |
| Raises | |
KeyError | If an object is missing and allow_missing is False |
Set[ bytes] | None = None, progress: Callable[ [ str], None] | None = None) -> int:
¶
Repack the packs in this repository.
Note that this implementation is fairly naive and currently keeps all objects in memory while it repacks.
| Parameters | |
exclude:Set[ | Optional set of object SHAs to exclude from repacking |
progress:Callable[ | Optional progress reporting callback |
| Returns | |
int | Undocumented |