class documentation

Object store interface.

Method __contains__ Check if a particular object is present by SHA1.
Method __getitem__ Obtain an object by SHA1.
Method __iter__ Iterate over the SHAs that are present in this store.
Method add_object Add a single object to this object store.
Method add_objects Add a set of objects to this object store.
Method add_pack Add a new pack to this object store.
Method add_pack_data Add pack data to this object store.
Method close Close any files opened by this object store.
Method contains_loose Check if a particular object is present by SHA1 and is loose.
Method contains_packed Check if a particular object is present by SHA1 and is packed.
Method determine_wants_all Undocumented
Method find_common_revisions Find which revisions this store has in common using graphwalker.
Method find_missing_objects Find the missing objects required for a set of revisions.
Method generate_pack_contents Iterate over the contents of a pack file.
Method generate_pack_data Generate pack data objects for a set of wants/haves.
Method get_raw Obtain the raw text for an object.
Method iter_shas Iterate over the objects for the specified shas.
Method iter_tree_contents Iterate the contents of a tree and all subtrees.
Method peel_sha Peel all tags from a SHA.
Method tree_changes Find the differences between the contents of two trees
Property packs Iterable of pack objects.
Method _collect_ancestors Collect all ancestors of heads up to (excluding) those in common.
Method _get_depth Return the current available depth for the given head. For commits with multiple parents, the largest possible depth will be returned.
def __contains__(self, sha):

Check if a particular object is present by SHA1.

This method makes no distinction between loose and packed objects.

def __getitem__(self, sha):

Obtain an object by SHA1.

Parameters
sha:ObjectIDUndocumented
def __iter__(self):
def add_objects(self, objects, progress=None):

Add a set of objects to this object store.

Parameters
objectsIterable over a list of (object, path) tuples
progressUndocumented
def add_pack_data(self, count, pack_data, progress=None):

Add pack data to this object store.

Parameters
countNumber of items to add
pack_dataIterator over pack data tuples
progressUndocumented
def close(self):

Close any files opened by this object store.

def contains_loose(self, sha):

Check if a particular object is present by SHA1 and is loose.

def contains_packed(self, sha):

Check if a particular object is present by SHA1 and is packed.

def determine_wants_all(self, refs, depth=None):

Undocumented

Parameters
refs:Dict[Ref, ObjectID]Undocumented
depth:Optional[int]Undocumented
Returns
List[ObjectID]Undocumented
def find_common_revisions(self, graphwalker):

Find which revisions this store has in common using graphwalker.

Returns: List of SHAs that are in common

Parameters
graphwalkerA graphwalker object.
def find_missing_objects(self, haves, wants, shallow=None, progress=None, get_tagged=None, get_parents=(lambda commit: commit.parents), depth=None):

Find the missing objects required for a set of revisions.

Returns: Iterator over (sha, path) pairs.

Parameters
havesIterable over SHAs already in common.
wantsIterable over SHAs of objects to fetch.
shallowSet of shallow commit SHA1s to skip
progressSimple progress function that will be called with updated progress strings.
get_taggedFunction that returns a dict of pointed-to sha -> tag sha for including tags.
get_parentsOptional function for getting the parents of a commit.
depthUndocumented
def generate_pack_contents(self, have, want, shallow=None, progress=None):

Iterate over the contents of a pack file.

Parameters
haveList of SHA1s of objects that should not be sent
wantList of SHA1s of objects that should be sent
shallowSet of shallow commit SHA1s to skip
progressOptional progress reporting method
def generate_pack_data(self, have, want, shallow=None, progress=None, ofs_delta=True):

Generate pack data objects for a set of wants/haves.

Parameters
haveList of SHA1s of objects that should not be sent
wantList of SHA1s of objects that should be sent
shallowSet of shallow commit SHA1s to skip
progressOptional progress reporting method
ofs_deltaWhether OFS deltas can be included
def get_raw(self, name):

Obtain the raw text for an object.

Returns: tuple with numeric type and object contents.

Parameters
namesha for the object.
def iter_shas(self, shas):

Iterate over the objects for the specified shas.

Returns: Object iterator

Parameters
shasIterable object with SHAs
def iter_tree_contents(self, tree_id, include_trees=False):

Iterate the contents of a tree and all subtrees.

Iteration is depth-first pre-order, as in e.g. os.walk.

Returns: Iterator over TreeEntry namedtuples for all the objects in a
tree.
Parameters
tree_idSHA1 of the tree.
include_treesIf True, include tree objects in the iteration.
def peel_sha(self, sha):

Peel all tags from a SHA.

Returns: The fully-peeled SHA1 of a tag object, after peeling all
intermediate tags; if the original ref does not point to a tag, this will equal the original SHA1.
Parameters
shaThe object SHA to peel.
def tree_changes(self, source, target, want_unchanged=False, include_trees=False, change_type_same=False, rename_detector=None):

Find the differences between the contents of two trees

Returns: Iterator over tuples with
(oldpath, newpath), (oldmode, newmode), (oldsha, newsha)
Parameters
sourceSHA1 of the source tree
targetSHA1 of the target tree
want_unchangedWhether unchanged files should be reported
include_treesWhether to include trees
change_type_sameWhether to report files changing type in the same entry.
rename_detectorUndocumented
def _collect_ancestors(self, heads, common=frozenset(), shallow=frozenset(), get_parents=(lambda commit: commit.parents)):

Collect all ancestors of heads up to (excluding) those in common.

Returns: a tuple (A, B) where A - all commits reachable
from heads but not present in common, B - common (shared) elements that are directly reachable from heads
Parameters
headscommits to start from
commoncommits to end at, or empty set to walk repository completely
shallowUndocumented
get_parentsOptional function for getting the parents of a commit.
def _get_depth(self, head, get_parents=(lambda commit: commit.parents), max_depth=None):

Return the current available depth for the given head. For commits with multiple parents, the largest possible depth will be returned.

Parameters
headcommit to start from
get_parentsoptional function for getting the parents of a commit
max_depthmaximum depth to search