class documentation

class ObjectReachabilityProvider(Protocol):

View In Hierarchy

Protocol for computing object reachability queries.

This abstraction allows reachability computations to be backed by either naive graph traversal or optimized bitmap indexes, with a consistent interface.

Method get_reachable_commits Get all commits reachable from heads, excluding those in exclude.
Method get_reachable_objects Get all objects (commits + trees + blobs) reachable from commits.
Method get_tree_objects Get all trees and blobs reachable from the given trees.
def get_reachable_commits(self, heads: Iterable[ObjectID], exclude: Iterable[ObjectID] | None = None, shallow: Set[ObjectID] | None = None) -> set[ObjectID]:

Get all commits reachable from heads, excluding those in exclude.

Parameters
heads:Iterable[ObjectID]Starting commit SHAs
exclude:Iterable[ObjectID] | NoneCommit SHAs to exclude (and their ancestors)
shallow:Set[ObjectID] | NoneSet of shallow commit boundaries (traversal stops here)
Returns
set[ObjectID]Set of commit SHAs reachable from heads but not from exclude
def get_reachable_objects(self, commits: Iterable[ObjectID], exclude_commits: Iterable[ObjectID] | None = None) -> set[ObjectID]:

Get all objects (commits + trees + blobs) reachable from commits.

Parameters
commits:Iterable[ObjectID]Starting commit SHAs
exclude_commits:Iterable[ObjectID] | NoneCommits whose objects should be excluded
Returns
set[ObjectID]Set of all object SHAs (commits, trees, blobs, tags)
def get_tree_objects(self, tree_shas: Iterable[ObjectID]) -> set[ObjectID]:

Get all trees and blobs reachable from the given trees.

Parameters
tree_shas:Iterable[ObjectID]Starting tree SHAs
Returns
set[ObjectID]Set of tree and blob SHAs