class documentation

Git-style object store that exists on disk.

Class Method from_config Create a DiskObjectStore from a configuration object.
Class Method init Initialize a new disk object store.
Method __init__ Open an object store.
Method __repr__ Return string representation of DiskObjectStore.
Method add_alternate_path Add an alternate path to this object store.
Method add_object Add a single object to this object store.
Method add_pack Add a new pack to this object store.
Method add_thin_pack Add a new thin pack to this object store.
Method close Close the object store and release resources.
Method contains_packed Check if a particular object is present by SHA1 and is packed.
Method count_loose_objects Count the number of loose objects in the object store.
Method delete_loose_object Delete a loose object from disk.
Method get_commit_graph Get the commit graph for this object store.
Method get_midx Get the multi-pack-index for this object store.
Method get_object_mtime Get the modification time of an object.
Method get_raw Obtain the raw fulltext for an object.
Method iter_prefix Iterate over all object SHAs with the given prefix.
Method prune Prune/clean up this object store.
Method write_commit_graph Write a commit graph file for this object store.
Method write_midx Write a multi-pack-index file for this object store.
Instance Variable dir_mode Undocumented
Instance Variable file_mode Undocumented
Instance Variable fsync_object_files Undocumented
Instance Variable loose_compression_level Undocumented
Instance Variable pack_compression_level Undocumented
Instance Variable pack_dir Undocumented
Instance Variable pack_index_version Undocumented
Instance Variable pack_write_bitmap_hash_cache Undocumented
Instance Variable pack_write_bitmap_lookup_table Undocumented
Instance Variable pack_write_bitmaps Undocumented
Instance Variable path Undocumented
Property alternates Get the list of alternate object stores.
Method _complete_pack Move a specific file containing a pack into the pack directory.
Method _get_loose_object Undocumented
Method _get_pack_basepath Undocumented
Method _get_pack_by_name Get a pack by its base name.
Method _get_shafile_path Undocumented
Method _iter_loose_objects Iterate over the SHAs of all loose objects.
Method _read_alternate_paths Undocumented
Method _remove_pack Undocumented
Method _update_pack_cache Read and iterate over new pack files and cache them.
Instance Variable _alternates Undocumented
Instance Variable _commit_graph Undocumented
Instance Variable _midx Undocumented
Instance Variable _use_commit_graph Undocumented
Instance Variable _use_midx Undocumented

Inherited from PackBasedObjectStore:

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 __iter__ Iterate over the SHAs that are present in this store.
Method add_objects Add a set of objects to this object store.
Method add_pack_data Add pack data to this object store.
Method contains_loose Check if a particular object is present by SHA1 and is loose.
Method count_pack_files Count the number of pack files.
Method generate_pack_bitmaps Generate bitmap indexes for all packs that don't have them.
Method generate_pack_data Generate pack data objects for a set of wants/haves.
Method get_reachability_provider Get the best reachability provider for the object store.
Method get_unpacked_object Obtain the unpacked object.
Method iter_unpacked_subset Iterate over a subset of objects, yielding UnpackedObject instances.
Method iterobjects_subset Iterate over a subset of objects in the store.
Method pack_loose_objects Pack loose objects.
Method repack Repack the packs in this repository.
Instance Variable delta_base_cache_limit Undocumented
Instance Variable pack_big_file_threshold Undocumented
Instance Variable pack_delta_cache_size Undocumented
Instance Variable pack_delta_window_size Undocumented
Instance Variable pack_depth Undocumented
Instance Variable pack_threads Undocumented
Instance Variable pack_window_memory Undocumented
Instance Variable packed_git_limit Undocumented
Property packs List with pack objects.
Method _add_cached_pack Add a newly appeared pack to the cache by path.
Method _clear_cached_packs Undocumented
Method _enforce_packed_git_limit Evict least-recently-used packs if the memory limit is exceeded.
Method _iter_alternate_objects Iterate over the SHAs of all the objects in alternate stores.
Method _iter_cached_packs Undocumented
Method _mark_pack_used Mark a pack as recently used for LRU tracking.
Method _total_pack_mmap_size Return the total mmapped memory across all cached packs.
Instance Variable _pack_access_order Undocumented
Instance Variable _pack_cache Undocumented

Inherited from BaseObjectStore (via PackBasedObjectStore, PackCapableObjectStore):

Method __getitem__ Obtain an object by SHA1.
Method determine_wants_all Determine which objects are wanted based on refs.
Method find_common_revisions Find which revisions this store has in common using graphwalker.
Method find_missing_objects Find the missing objects required for a set of revisions.
Method iter_tree_contents Iterate the contents of a tree and all subtrees.
Method peel_sha Peel all tags from a SHA.
Method tree_changes Find the differences between the contents of two trees.
Instance Variable object_format Undocumented
Method _get_depth Return the current available depth for the given head.
def from_config(cls, path: str | os.PathLike[str], config: Config, *, file_mode: int | None = None, dir_mode: int | None = None) -> DiskObjectStore:

Create a DiskObjectStore from a configuration object.

Parameters
path:str | os.PathLike[str]Path to the object store directory
config:ConfigConfiguration object to read settings from
file_mode:int | NoneOptional file permission mask for shared repository
dir_mode:int | NoneOptional directory permission mask for shared repository
Returns
DiskObjectStoreNew DiskObjectStore instance configured according to config
def init(cls, path: str | os.PathLike[str], *, file_mode: int | None = None, dir_mode: int | None = None, object_format: ObjectFormat | None = None) -> DiskObjectStore:

Initialize a new disk object store.

Creates the necessary directory structure for a Git object store.

Parameters
path:str | os.PathLike[str]Path where the object store should be created
file_mode:int | NoneOptional file permission mask for shared repository
dir_mode:int | NoneOptional directory permission mask for shared repository
object_format:ObjectFormat | NoneHash algorithm to use (SHA1 or SHA256)
Returns
DiskObjectStoreNew DiskObjectStore instance
def __init__(self, path: str | os.PathLike[str], *, loose_compression_level: int = -1, pack_compression_level: 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, fsync_object_files: bool = False, pack_write_bitmaps: bool = False, pack_write_bitmap_hash_cache: bool = True, pack_write_bitmap_lookup_table: bool = True, file_mode: int | None = None, dir_mode: int | None = None, object_format: ObjectFormat | None = None):

Open an object store.

Parameters
path:str | os.PathLike[str]Path of the object store.
loose_compression_level:intzlib compression level for loose objects
pack_compression_level:intzlib compression level for pack objects
pack_index_version:int | Nonepack index version to use (1, 2, or 3)
pack_delta_window_size:int | Nonesliding window size for delta compression
pack_window_memory:int | Nonememory limit for delta window operations
pack_delta_cache_size:int | Nonesize of cache for delta operations
pack_depth:int | Nonemaximum delta chain depth
pack_threads:int | Nonenumber of threads for pack operations
pack_big_file_threshold:int | Nonethreshold for treating files as big
packed_git_limit:int | Nonemaximum total bytes for mmapped pack files
delta_base_cache_limit:int | Nonemaximum bytes for delta base object cache
fsync_object_files:boolwhether to fsync object files for durability
pack_write_bitmaps:boolwhether to write bitmap indexes for packs
pack_write_bitmap_hash_cache:boolwhether to include name-hash cache in bitmaps
pack_write_bitmap_lookup_table:boolwhether to include lookup table in bitmaps
file_mode:int | NoneFile permission mask for shared repository
dir_mode:int | NoneDirectory permission mask for shared repository
object_format:ObjectFormat | NoneHash algorithm to use (SHA1 or SHA256)
def __repr__(self) -> str:

Return string representation of DiskObjectStore.

Returns
strString representation including the store path
def add_alternate_path(self, path: str | os.PathLike[str]):

Add an alternate path to this object store.

def add_object(self, obj: ShaFile):

Add a single object to this object store.

Parameters
obj:ShaFileObject to add
def add_pack(self) -> tuple[BinaryIO, Callable[[], None], Callable[[], None]]:

Add a new pack to this object store.

Returns: Fileobject to write to, a commit function to
call when the pack is finished and an abort function.
def add_thin_pack(self, read_all: Callable[[int], bytes], read_some: Callable[[int], bytes] | None, progress: Callable[..., None] | None = None) -> Pack:

Add a new thin pack to this object store.

Thin packs are packs that contain deltas with parents that exist outside the pack. They should never be placed in the object store directly, and always indexed and completed as they are copied.

Returns: A Pack object pointing at the now-completed thin pack in the
objects/pack directory.
Parameters
read_all:Callable[[int], bytes]Read function that blocks until the number of requested bytes are read.
read_some:Callable[[int], bytes] | NoneRead function that returns at least one byte, but may not return the number of bytes requested.
progress:Callable[..., None] | NoneOptional progress reporting function.
Returns
PackUndocumented
def close(self):

Close the object store and release resources.

This method closes all cached pack files, MIDX, and frees associated resources. Can be called multiple times safely.

def contains_packed(self, sha: ObjectID | RawObjectID) -> bool:

Check if a particular object is present by SHA1 and is packed.

This checks the MIDX first if available, then falls back to checking individual pack indexes.

Parameters
sha:ObjectID | RawObjectIDBinary SHA of the object
Returns
boolTrue if the object is in a pack file
def count_loose_objects(self) -> int:

Count the number of loose objects in the object store.

Returns
intNumber of loose objects
def delete_loose_object(self, sha: ObjectID):

Delete a loose object from disk.

Parameters
sha:ObjectIDSHA1 of the object to delete
Raises
FileNotFoundErrorIf the object file doesn't exist
def get_commit_graph(self) -> CommitGraph | None:

Get the commit graph for this object store.

Returns
CommitGraph | NoneCommitGraph object if available, None otherwise
def get_midx(self) -> MultiPackIndex | None:

Get the multi-pack-index for this object store.

Returns
MultiPackIndex | NoneMultiPackIndex object if available, None otherwise
Raises
ValueErrorIf MIDX file is corrupt
OSErrorIf MIDX file cannot be read
def get_object_mtime(self, sha: ObjectID) -> float:

Get the modification time of an object.

Parameters
sha:ObjectIDSHA1 of the object
Returns
floatModification time as seconds since epoch
Raises
KeyErrorif the object is not found
def get_raw(self, name: RawObjectID | ObjectID) -> tuple[int, bytes]:

Obtain the raw fulltext for an object.

This uses the MIDX if available for faster lookups.

Parameters
name:RawObjectID | ObjectIDSHA for the object (20 bytes binary or 40 bytes hex)
Returns
tuple[int, bytes]Tuple with numeric type and object contents
Raises
KeyErrorIf object not found
def iter_prefix(self, prefix: bytes) -> Iterator[ObjectID]:

Iterate over all object SHAs with the given prefix.

Parameters
prefix:bytesHex prefix to search for (as bytes)
Returns
Iterator[ObjectID]Iterator of object SHAs (as ObjectID) matching the prefix
def prune(self, grace_period: int | None = None):

Prune/clean up this object store.

This removes temporary files that were left behind by interrupted pack operations. These are files that start with tmp_pack_ in the repository directory or files with .pack extension but no corresponding .idx file in the pack directory.

Parameters
grace_period:int | NoneGrace period in seconds for removing temporary files. If None, uses DEFAULT_TEMPFILE_GRACE_PERIOD.
def write_commit_graph(self, refs: Iterable[ObjectID] | None = None, reachable: bool = True):

Write a commit graph file for this object store.

Parameters
refs:Iterable[ObjectID] | NoneList of refs to include. If None, includes all refs from object store.
reachable:boolIf True, includes all commits reachable from refs. If False, only includes the direct ref targets.
def write_midx(self) -> bytes:

Write a multi-pack-index file for this object store.

Creates a MIDX file that indexes all pack files in the pack directory.

Returns
bytesSHA-1 checksum of the written MIDX file
Raises
OSErrorIf the pack directory doesn't exist or MIDX can't be written
dir_mode =

Undocumented

file_mode =

Undocumented

fsync_object_files =

Undocumented

loose_compression_level =

Undocumented

pack_compression_level =
pack_dir: str | os.PathLike[str] =

Undocumented

pack_write_bitmap_hash_cache =

Undocumented

pack_write_bitmap_lookup_table =

Undocumented

pack_write_bitmaps =

Undocumented

path: str | os.PathLike[str] =

Undocumented

Get the list of alternate object stores.

Reads from .git/objects/info/alternates if not already cached.

Returns
List of DiskObjectStore instances for alternate object directories
def _complete_pack(self, f: BinaryIO, path: str, num_objects: int, indexer: PackIndexer, progress: Callable[..., None] | None = None, refs: dict[Ref, ObjectID] | None = None) -> Pack:

Move a specific file containing a pack into the pack directory.

Note: The file should be on the same file system as the
packs directory.
Parameters
f:BinaryIOOpen file object for the pack.
path:strPath to the pack file.
num_objects:intNumber of objects in the pack.
indexer:PackIndexerA PackIndexer for indexing the pack.
progress:Callable[..., None] | NoneOptional progress reporting function.
refs:dict[Ref, ObjectID] | NoneOptional dictionary of refs for bitmap generation.
Returns
PackUndocumented
def _get_loose_object(self, sha: ObjectID | RawObjectID) -> ShaFile | None:
def _get_pack_basepath(self, entries: Iterable[tuple[bytes, int, int | None]]) -> str:

Undocumented

def _get_pack_by_name(self, pack_name: str) -> Pack:

Get a pack by its base name.

Parameters
pack_name:strBase name of the pack (e.g., 'pack-abc123.pack' or 'pack-abc123.idx')
Returns
PackPack object
Raises
KeyErrorIf pack doesn't exist
def _get_shafile_path(self, sha: ObjectID | RawObjectID) -> str:

Undocumented

def _iter_loose_objects(self) -> Iterator[ObjectID]:

Iterate over the SHAs of all loose objects.

def _read_alternate_paths(self) -> Iterator[str]:

Undocumented

def _remove_pack(self, pack: Pack):
def _update_pack_cache(self) -> list[Pack]:

Read and iterate over new pack files and cache them.

_alternates: list[BaseObjectStore] | None =

Undocumented

_commit_graph: CommitGraph | None =

Undocumented

Undocumented

_use_commit_graph: bool =

Undocumented

_use_midx: bool =

Undocumented