class documentation

Repo that stores refs, objects, and named files in memory.

MemoryRepos are always bare: they have no working tree and no index, since those have a stronger dependency on the filesystem.

Class Method init_bare Create a new bare repository in memory.
Method __init__ Create a new repository in memory.
Method close Close any resources opened by this repository.
Method do_commit Create a new commit.
Method get_blob_normalizer Return a BlobNormalizer object for checkin/checkout operations.
Method get_config Retrieve the config object.
Method get_description Get the description of this repository.
Method get_gitattributes Read gitattributes for the repository.
Method get_named_file Get a file from the control dir with a specific name.
Method get_rebase_state_manager Get the appropriate rebase state manager for this repository.
Method open_index Fail to open index for this repo, since it is bare.
Method set_description Set the description for this repository.
Instance Variable bare Undocumented
Instance Variable filter_context Undocumented
Instance Variable object_format Undocumented
Method _append_reflog Undocumented
Method _del_named_file Delete a file in the control directory with the given name.
Method _determine_file_mode Probe the file-system to determine whether permissions can be trusted.
Method _determine_symlinks Probe the file-system to determine whether permissions can be trusted.
Method _init_config Initialize repository configuration for MemoryRepo.
Method _put_named_file Write a file to the control dir with the given name and contents.
Instance Variable _config Undocumented
Instance Variable _description Undocumented
Instance Variable _named_files Undocumented
Instance Variable _reflog Undocumented

Inherited from BaseRepo:

Method __contains__ Check if a specific Git object or ref is present.
Method __delitem__ Remove a ref.
Method __getitem__ Retrieve a Git object by SHA1 or ref.
Method __setitem__ Set a ref.
Method fetch Fetch objects into another repository.
Method fetch_pack_data Fetch the pack data required for a set of revisions.
Method find_missing_objects Fetch the missing objects required for a set of revisions.
Method generate_pack_data Generate pack data objects for a set of wants/haves.
Method get_config_stack Return a config stack for this repository.
Method get_graph_walker Retrieve a graph walker.
Method get_object Retrieve the object with the specified SHA.
Method get_parents Retrieve the parents of a specific commit.
Method get_peeled Get the peeled value of a ref.
Method get_refs Get dictionary with all refs.
Method get_shallow Get the set of shallow commits.
Method get_walker Obtain a walker for this repository.
Method get_worktree Get the working tree for this repository.
Method get_worktree_config Retrieve the worktree config object.
Method head Return the SHA1 pointed at by HEAD.
Method parents_provider Get a parents provider for this repository.
Method update_shallow Update the list of shallow objects.
Instance Variable hooks Undocumented
Instance Variable object_store Dictionary-like object for accessing the objects
Instance Variable refs Dictionary-like object with the refs in this repository
Property notes Access notes functionality for this repository.
Method _add_graftpoints Add or modify graftpoints.
Method _change_object_format Change the object format of this repository.
Method _get_object Undocumented
Method _get_user_identity Determine the identity to use for new commits.
Method _init_files Initialize a default set of named files.
Method _read_heads Undocumented
Method _remove_graftpoints Remove graftpoints.
Instance Variable _graftpoints Undocumented
def init_bare(cls, objects: Iterable[ShaFile], refs: Mapping[Ref, ObjectID], format: int | None = None, object_format: str | None = None) -> MemoryRepo:

Create a new bare repository in memory.

Parameters
objects:Iterable[ShaFile]Objects for the new repository, as iterable
refs:Mapping[Ref, ObjectID]Refs as dictionary, mapping names to object SHA1s
format:int | NoneRepository format version (defaults to 0)
object_format:str | NoneObject format to use ("sha1" or "sha256", defaults to "sha1")
Returns
MemoryRepoUndocumented
def __init__(self):

Create a new repository in memory.

def close(self):

Close any resources opened by this repository.

def do_commit(self, message: bytes | None = None, committer: bytes | None = None, author: bytes | None = None, commit_timestamp: float | None = None, commit_timezone: int | None = None, author_timestamp: float | None = None, author_timezone: int | None = None, tree: ObjectID | None = None, encoding: bytes | None = None, ref: Ref | None = HEADREF, merge_heads: list[ObjectID] | None = None, no_verify: bool = False, sign: bool = False) -> bytes:

Create a new commit.

This is a simplified implementation for in-memory repositories that doesn't support worktree operations or hooks.

Parameters
message:bytes | NoneCommit message
committer:bytes | NoneCommitter fullname
author:bytes | NoneAuthor fullname
commit_timestamp:float | NoneCommit timestamp (defaults to now)
commit_timezone:int | NoneCommit timestamp timezone (defaults to GMT)
author_timestamp:float | NoneAuthor timestamp (defaults to commit timestamp)
author_timezone:int | NoneAuthor timestamp timezone (defaults to commit timezone)
tree:ObjectID | NoneSHA1 of the tree root to use
encoding:bytes | NoneEncoding
ref:Ref | NoneOptional ref to commit to (defaults to current branch). If None, creates a dangling commit without updating any ref.
merge_heads:list[ObjectID] | NoneMerge heads
no_verify:boolSkip pre-commit and commit-msg hooks (ignored for MemoryRepo)
sign:boolGPG Sign the commit (ignored for MemoryRepo)
Returns
bytesNew commit SHA1
def get_blob_normalizer(self) -> FilterBlobNormalizer:

Return a BlobNormalizer object for checkin/checkout operations.

def get_config(self) -> ConfigFile:

Retrieve the config object.

Returns: ConfigFile object.

def get_description(self) -> bytes | None:

Get the description of this repository.

Returns
bytes | NoneRepository description as bytes
def get_gitattributes(self, tree: bytes | None = None) -> GitAttributes:

Read gitattributes for the repository.

def get_named_file(self, path: str | bytes, basedir: str | None = None) -> BytesIO | None:

Get a file from the control dir with a specific name.

Although the filename should be interpreted as a filename relative to the control dir in a disk-baked Repo, the object returned need not be pointing to a file in that location.

Returns: An open file object, or None if the file does not exist.

Parameters
path:str | bytesThe path to the file, relative to the control dir.
basedir:str | NoneOptional base directory for the path
Returns
BytesIO | NoneUndocumented
def get_rebase_state_manager(self) -> RebaseStateManager:

Get the appropriate rebase state manager for this repository.

Returns: MemoryRebaseStateManager instance

def open_index(self) -> Index:

Fail to open index for this repo, since it is bare.

Raises
NoIndexPresentRaised when no index is present
def set_description(self, description: bytes):

Set the description for this repository.

Parameters
description:bytesText to set as description
bare: bool =

Undocumented

filter_context: FilterContext | None =

Undocumented

object_format =

Undocumented

def _append_reflog(self, ref: bytes, old_sha: bytes | None, new_sha: bytes | None, committer: bytes | None, timestamp: int | None, timezone: int | None, message: bytes | None):

Undocumented

def _del_named_file(self, path: str):

Delete a file in the control directory with the given name.

def _determine_file_mode(self) -> bool:

Probe the file-system to determine whether permissions can be trusted.

Returns: True if permissions can be trusted, False otherwise.

def _determine_symlinks(self) -> bool:

Probe the file-system to determine whether permissions can be trusted.

Returns: True if permissions can be trusted, False otherwise.

def _init_config(self, config: ConfigFile):

Initialize repository configuration for MemoryRepo.

def _put_named_file(self, path: str, contents: bytes):

Write a file to the control dir with the given name and contents.

Parameters
path:strThe path to the file, relative to the control dir.
contents:bytesA string to write to the file.
_config =

Undocumented

_description: bytes | None =

Undocumented

_named_files: dict[str, bytes] =

Undocumented

_reflog: list[Any] =

Undocumented