class documentation

class NotesTree:

Constructor: NotesTree(tree, object_store)

View In Hierarchy

Represents a Git notes tree.

Method __init__ Initialize a notes tree.
Method get_note Get the note content for an object.
Method list_notes List all notes in this tree.
Method remove_note Remove a note for an object.
Method set_note Set or update a note for an object.
Method _detect_fanout_level Detect the fanout level used in this notes tree.
Method _get_note_sha Get the SHA of the note blob for an object.
Method _reorganize_tree Reorganize the notes tree to use a different fanout level.
Method _update_tree_entry Update a tree entry and return the updated tree.
Instance Variable _fanout_level Undocumented
Instance Variable _object_store Undocumented
Instance Variable _tree Undocumented
def __init__(self, tree: Tree, object_store: BaseObjectStore):

Initialize a notes tree.

Parameters
tree:TreeThe tree object containing notes
object_store:BaseObjectStoreObject store to retrieve note contents from
def get_note(self, object_sha: bytes) -> bytes | None:

Get the note content for an object.

Parameters
object_sha:bytesSHA of the object to get notes for
Returns
bytes | NoneNote content as bytes, or None if no note exists
def list_notes(self) -> Iterator[tuple[ObjectID, ObjectID]]:

List all notes in this tree.

Yields
Tuples of (object_sha, note_sha)
def remove_note(self, object_sha: bytes) -> Tree | None:

Remove a note for an object.

Parameters
object_sha:bytesSHA of the object to remove notes from
Returns
Tree | NoneNew tree object with the note removed, or None if no note existed
def set_note(self, object_sha: bytes, note_content: bytes) -> Tree:

Set or update a note for an object.

Parameters
object_sha:bytesSHA of the object to annotate
note_content:bytesContent of the note
Returns
TreeNew tree object with the note added/updated
def _detect_fanout_level(self) -> int:

Detect the fanout level used in this notes tree.

Returns
intDetected fanout level
def _get_note_sha(self, object_sha: bytes) -> ObjectID | None:

Get the SHA of the note blob for an object.

Parameters
object_sha:bytesSHA of the object to get notes for
Returns
ObjectID | NoneSHA of the note blob, or None if no note exists
def _reorganize_tree(self, new_fanout_level: int):

Reorganize the notes tree to use a different fanout level.

Parameters
new_fanout_level:intThe desired fanout level
def _update_tree_entry(self, tree: Tree, name: bytes, mode: int, sha: ObjectID) -> Tree:

Update a tree entry and return the updated tree.

Parameters
tree:TreeThe tree to update
name:bytesName of the entry
mode:intFile mode
sha:ObjectIDSHA of the object
Returns
TreeThe updated tree
_fanout_level =

Undocumented

_object_store =

Undocumented

_tree =

Undocumented