class documentation

class DictRefsContainer(RefsContainer):

Constructor: DictRefsContainer(refs, logger)

View In Hierarchy

RefsContainer backed by a simple dict.

This container does not support symbolic or packed references and is not threadsafe.

Method __init__ Initialize DictRefsContainer with refs dictionary and optional logger.
Method add_if_new Add a new reference only if it does not already exist.
Method allkeys Return all reference keys.
Method get_packed_refs Get packed references.
Method get_peeled Get peeled version of a reference.
Method read_loose_ref Read a loose reference.
Method remove_if_equals Remove a refname only if it currently equals old_ref.
Method set_if_equals Set a refname to new_ref only if it currently equals old_ref.
Method set_symbolic_ref Make a ref point at another ref.
Method _notify Undocumented
Method _update Update multiple refs; intended only for testing.
Method _update_peeled Update cached peeled refs; intended only for testing.
Instance Variable _peeled Undocumented
Instance Variable _refs Undocumented
Instance Variable _watchers Undocumented

Inherited from RefsContainer:

Method __contains__ Check if a reference exists.
Method __delitem__ Remove a refname.
Method __getitem__ Get the SHA1 for a reference name.
Method __iter__ Iterate over all reference keys.
Method __setitem__ Set a reference name to point to the given SHA1.
Method add_packed_refs Add the given refs as packed refs.
Method as_dict Return the contents of this container as a dictionary.
Method follow Follow a reference name.
Method get_symrefs Get a dict with all symrefs in this container.
Method import_refs Import refs from another repository.
Method keys Refs present in this container.
Method pack_refs Pack loose refs into packed-refs file.
Method read_ref Read a reference without following any references.
Method subkeys Refs present in this container under a base.
Method _check_refname Ensure a refname is valid and lives in refs or is HEAD.
Method _log Undocumented
Instance Variable _logger Undocumented
def __init__(self, refs: dict[Ref, bytes], logger: Callable[[bytes, (bytes | None), (bytes | None), (bytes | None), (int | None), (int | None), (bytes | None)], None] | None = None):

Initialize DictRefsContainer with refs dictionary and optional logger.

def add_if_new(self, name: Ref, ref: ObjectID, committer: bytes | None = None, timestamp: int | None = None, timezone: int | None = None, message: bytes | None = None) -> bool:

Add a new reference only if it does not already exist.

Parameters
name:RefRef name
ref:ObjectIDRef value
committer:bytes | NoneOptional committer name for reflog
timestamp:int | NoneOptional timestamp for reflog
timezone:int | NoneOptional timezone for reflog
message:bytes | NoneOptional message for reflog
Returns
boolTrue if the add was successful, False otherwise.
def allkeys(self) -> set[Ref]:

Return all reference keys.

def get_packed_refs(self) -> dict[Ref, ObjectID]:

Get packed references.

def get_peeled(self, name: Ref) -> ObjectID | None:

Get peeled version of a reference.

def read_loose_ref(self, name: Ref) -> bytes | None:

Read a loose reference.

def remove_if_equals(self, name: Ref, old_ref: ObjectID | None, committer: bytes | None = None, timestamp: int | None = None, timezone: int | None = None, message: bytes | None = None) -> bool:

Remove a refname only if it currently equals old_ref.

This method does not follow symbolic references. It can be used to perform an atomic compare-and-delete operation.

Parameters
name:RefThe refname to delete.
old_ref:ObjectID | NoneThe old sha the refname must refer to, or None to delete unconditionally.
committer:bytes | NoneOptional committer name for reflog
timestamp:int | NoneOptional timestamp for reflog
timezone:int | NoneOptional timezone for reflog
message:bytes | NoneOptional message for reflog
Returns
boolTrue if the delete was successful, False otherwise.
def set_if_equals(self, name: Ref, old_ref: ObjectID | None, new_ref: ObjectID, committer: bytes | None = None, timestamp: int | None = None, timezone: int | None = None, message: bytes | None = None) -> bool:

Set a refname to new_ref only if it currently equals old_ref.

This method follows all symbolic references, and can be used to perform an atomic compare-and-swap operation.

Parameters
name:RefThe refname to set.
old_ref:ObjectID | NoneThe old sha the refname must refer to, or None to set unconditionally.
new_ref:ObjectIDThe new sha the refname will refer to.
committer:bytes | NoneOptional committer name for reflog
timestamp:int | NoneOptional timestamp for reflog
timezone:int | NoneOptional timezone for reflog
message:bytes | NoneOptional message for reflog
Returns
boolTrue if the set was successful, False otherwise.
def set_symbolic_ref(self, name: Ref, other: Ref, committer: bytes | None = None, timestamp: int | None = None, timezone: int | None = None, message: bytes | None = None):

Make a ref point at another ref.

Parameters
name:RefName of the ref to set
other:RefName of the ref to point at
committer:bytes | NoneOptional committer name for reflog
timestamp:int | NoneOptional timestamp for reflog
timezone:int | NoneOptional timezone for reflog
message:bytes | NoneOptional message for reflog
def _notify(self, ref: bytes, newsha: bytes | None):

Undocumented

def _update(self, refs: Mapping[Ref, ObjectID]):

Update multiple refs; intended only for testing.

def _update_peeled(self, peeled: Mapping[Ref, ObjectID]):

Update cached peeled refs; intended only for testing.

_peeled: dict[Ref, ObjectID] =

Undocumented

_refs =

Undocumented

_watchers: set[Any] =

Undocumented