d.r.RefsContainer(object) : class documentation

Part of dulwich.repo View In Hierarchy

Known subclasses: dulwich.repo.DictRefsContainer, dulwich.repo.DiskRefsContainer, dulwich.repo.InfoRefsContainer

A container for refs.
Method set_ref Undocumented
Method set_symbolic_ref Make a ref point at another ref.
Method get_packed_refs Get contents of the packed-refs file.
Method get_peeled Return the cached peeled value of a ref, if available.
Method import_refs Undocumented
Method allkeys All refs present in this container.
Method keys Refs present in this container.
Method subkeys Refs present in this container under a base.
Method as_dict Return the contents of this container as a dictionary.
Method read_ref Read a reference without following any references.
Method read_loose_ref Read a loose reference and return its contents.
Method __contains__ Undocumented
Method __getitem__ Get the SHA1 for a reference name.
Method set_if_equals Set a refname to new_ref only if it currently equals old_ref.
Method add_if_new Add a new reference only if it does not already exist.
Method __setitem__ Set a reference name to point to the given SHA1.
Method remove_if_equals Remove a refname only if it currently equals old_ref.
Method __delitem__ Remove a refname.
Method _check_refname Ensure a refname is valid and lives in refs or is HEAD.
Method _follow Follow a reference name.
def set_ref(self, name, other):
Undocumented
def set_symbolic_ref(self, name, other):
Make a ref point at another ref.
ParametersnameName of the ref to set
otherName of the ref to point at
def get_packed_refs(self):
Get contents of the packed-refs file.
ReturnsDictionary mapping ref names to SHA1s
NoteWill return an empty dictionary when no packed-refs file is present.
def get_peeled(self, name):
Return the cached peeled value of a ref, if available.
ParametersnameName of the ref to peel
ReturnsThe peeled value of the ref. If the ref is known not point to a tag, this will be the SHA the ref refers to. If the ref may point to a tag, but no cached information is available, None is returned.
def import_refs(self, base, other):
Undocumented
def allkeys(self):
All refs present in this container.
def keys(self, base=None):
Refs present in this container.
ParametersbaseAn optional base to return refs under.
ReturnsAn unsorted set of valid refs in this container, including packed refs.
def subkeys(self, base):
Refs present in this container under a base.
ParametersbaseThe base to return refs under.
ReturnsA set of valid refs in this container under the base; the base prefix is stripped from the ref names returned.
def as_dict(self, base=None):
Return the contents of this container as a dictionary.
def _check_refname(self, name):

Ensure a refname is valid and lives in refs or is HEAD.

HEAD is not a valid refname according to git-check-ref-format, but this class needs to be able to touch HEAD. Also, check_ref_format expects refnames without the leading 'refs/', but this class requires that so it cannot touch anything outside the refs dir (or HEAD).

ParametersnameThe name of the reference.
RaisesKeyErrorif a refname is not HEAD or is otherwise not valid.
def read_ref(self, refname):
Read a reference without following any references.
ParametersrefnameThe name of the reference
ReturnsThe contents of the ref file, or None if it does not exist.
def read_loose_ref(self, name):
Read a loose reference and return its contents.
Parametersnamethe refname to read
ReturnsThe contents of the ref file, or None if it does not exist.
def _follow(self, name):
Follow a reference name.
Returnsa tuple of (refname, sha), where refname is the name of the last reference in the symbolic reference chain
def __contains__(self, refname):
Undocumented
def __getitem__(self, name):

Get the SHA1 for a reference name.

This method follows all symbolic references.

def set_if_equals(self, name, old_ref, new_ref):

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

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

ParametersnameThe refname to set.
old_refThe old sha the refname must refer to, or None to set unconditionally.
new_refThe new sha the refname will refer to.
ReturnsTrue if the set was successful, False otherwise.
def add_if_new(self, name, ref):
Add a new reference only if it does not already exist.
def __setitem__(self, name, ref):

Set a reference name to point to the given SHA1.

This method follows all symbolic references if applicable for the subclass.

ParametersnameThe refname to set.
refThe new sha the refname will refer to.
NoteThis method unconditionally overwrites the contents of a reference. To update atomically only if the reference has not changed, use set_if_equals().
def remove_if_equals(self, name, old_ref):

Remove a refname only if it currently equals old_ref.

This method does not follow symbolic references, even if applicable for the subclass. It can be used to perform an atomic compare-and-delete operation.

ParametersnameThe refname to delete.
old_refThe old sha the refname must refer to, or None to delete unconditionally.
ReturnsTrue if the delete was successful, False otherwise.
def __delitem__(self, name):

Remove a refname.

This method does not follow symbolic references, even if applicable for the subclass.

ParametersnameThe refname to delete.
NoteThis method unconditionally deletes the contents of a reference. To delete atomically only if the reference has not changed, use remove_if_equals().
API Documentation for Dulwich, generated by pydoctor at 2013-10-16 22:58:09.