class documentation

class NamespacedRefsContainer(RefsContainer):

Constructor: NamespacedRefsContainer(refs, namespace)

View In Hierarchy

Wrapper that adds namespace prefix to all ref operations.

This implements Git's GIT_NAMESPACE feature, which stores refs under refs/namespaces/<namespace>/ and filters operations to only show refs within that namespace.

Example

With namespace "foo", a ref "refs/heads/master" is stored as "refs/namespaces/foo/refs/heads/master" in the underlying container.

Method __init__ Initialize NamespacedRefsContainer.
Method add_if_new Add a new reference only if it does not already exist.
Method add_packed_refs Add packed refs with namespace prefix.
Method allkeys Return all reference keys in this namespace.
Method get_packed_refs Get packed refs within this namespace.
Method get_peeled Return the cached peeled value of a ref.
Method pack_refs Pack loose refs into packed-refs file.
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 _apply_namespace Apply namespace prefix to a ref name.
Method _strip_namespace Remove namespace prefix from a ref name.
Instance Variable _namespace_prefix Undocumented
Instance Variable _refs 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 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 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: RefsContainer, namespace: bytes):

Initialize NamespacedRefsContainer.

Parameters
refs:RefsContainerThe underlying refs container to wrap
namespace:bytesThe namespace prefix (e.g., b"foo" or b"foo/bar")
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.

def add_packed_refs(self, new_refs: Mapping[Ref, ObjectID | None]):

Add packed refs with namespace prefix.

def allkeys(self) -> set[Ref]:

Return all reference keys in this namespace.

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

Get packed refs within this namespace.

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

Return the cached peeled value of a ref.

def pack_refs(self, all: bool = False):

Pack loose refs into packed-refs file.

Note: This packs all refs in the underlying container, not just those in the namespace.

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.

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.

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.

def _apply_namespace(self, name: bytes) -> bytes:

Apply namespace prefix to a ref name.

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

Remove namespace prefix from a ref name.

Returns None if the ref is not in our namespace.

_namespace_prefix: bytes =

Undocumented

_refs =

Undocumented