Utilities for diffing files and trees.
Class TreeChange Named tuple a single change between two trees.
Function walk_trees Recursively walk all the entries of two trees.
Function tree_changes Find the differences between the contents of two trees.
Function tree_changes_for_merge Get the tree changes for a merge tree relative to all its parents.
Class RenameDetector Object for handling rename detection between two trees.
Function _tree_entries Undocumented
Function _merge_entries Merge the entries of two trees.
Function _is_tree Undocumented
Function _skip_tree Undocumented
Function _all_eq Undocumented
Function _all_same Undocumented
Function _count_blocks Count the blocks in an object.
Function _common_bytes Count the number of common bytes in two block count dicts.
Function _similarity_score Compute a similarity score for two objects.
Function _tree_change_key Undocumented
def _tree_entries(path, tree):
Undocumented
def _merge_entries(path, tree1, tree2):
Merge the entries of two trees.
ParameterspathA path to prepend to all tree entry names.
tree1The first Tree object to iterate, or None.
tree2The second Tree object to iterate, or None.
ReturnsA list of pairs of TreeEntry objects for each pair of entries in the trees. If an entry exists in one tree but not the other, the other entry will have all attributes set to None. If neither entry's path is None, they are guaranteed to match.
def _is_tree(entry):
Undocumented
def walk_trees(store, tree1_id, tree2_id, prune_identical=False):

Recursively walk all the entries of two trees.

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

ParametersstoreAn ObjectStore for looking up objects.
tree1_idThe SHA of the first Tree object to iterate, or None.
tree2_idThe SHA of the second Tree object to iterate, or None.
prune_identicalIf True, identical subtrees will not be walked.
ReturnsIterator over Pairs of TreeEntry objects for each pair of entries in the trees and their subtrees recursively. If an entry exists in one tree but not the other, the other entry will have all attributes set to None. If neither entry's path is None, they are guaranteed to match.
def _skip_tree(entry, include_trees):
Undocumented
def tree_changes(store, tree1_id, tree2_id, want_unchanged=False, rename_detector=None, include_trees=False, change_type_same=False):
Find the differences between the contents of two trees.
ParametersstoreAn ObjectStore for looking up objects.
tree1_idThe SHA of the source tree.
tree2_idThe SHA of the target tree.
want_unchangedIf True, include TreeChanges for unmodified entries as well.
include_treesWhether to include trees
rename_detectorRenameDetector object for detecting renames.
change_type_sameWhether to report change types in the same entry or as delete+add.
ReturnsIterator over TreeChange instances for each change between the source and target tree.
def _all_eq(seq, key, value):
Undocumented
def _all_same(seq, key):
Undocumented
def tree_changes_for_merge(store, parent_tree_ids, tree_id, rename_detector=None):
Get the tree changes for a merge tree relative to all its parents.
ParametersstoreAn ObjectStore for looking up objects.
parent_tree_idsAn iterable of the SHAs of the parent trees.
tree_idThe SHA of the merge tree.
rename_detectorRenameDetector object for detecting renames.
Returns

Iterator over lists of TreeChange objects, one per conflicted path in the merge.

Each list contains one element per parent, with the TreeChange for that path relative to that parent. An element may be None if it never existed in one parent and was deleted in two others.

A path is only included in the output if it is a conflict, i.e. its SHA in the merge tree is not found in any of the parents, or in the case of deletes, if not all of the old SHAs match.

def _count_blocks(obj):

Count the blocks in an object.

Splits the data into blocks either on lines or <=64-byte chunks of lines.

ParametersobjThe object to count blocks for.
ReturnsA dict of block hashcode -> total bytes occurring.
def _common_bytes(blocks1, blocks2):
Count the number of common bytes in two block count dicts.
Parametersblock1The first dict of block hashcode -> total bytes.
block2The second dict of block hashcode -> total bytes.
ReturnsThe number of bytes in common between blocks1 and blocks2. This is only approximate due to possible hash collisions.
def _similarity_score(obj1, obj2, block_cache=None):
Compute a similarity score for two objects.
Parametersobj1The first object to score.
obj2The second object to score.
block_cacheAn optional dict of SHA to block counts to cache results between calls.
ReturnsThe similarity score between the two objects, defined as the number of bytes in common between the two objects divided by the maximum size, scaled to the range 0-100.
def _tree_change_key(entry):
Undocumented
API Documentation for Dulwich, generated by pydoctor at 2018-11-17 19:05:54.