dulwich.diff_tree
module documentationdulwich
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 |
Parameters | path | A path to prepend to all tree entry names. |
tree1 | The first Tree object to iterate, or None. | |
tree2 | The second Tree object to iterate, or None. | |
Returns | A 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. |
Recursively walk all the entries of two trees.
Iteration is depth-first pre-order, as in e.g. os.walk.
Parameters | store | An ObjectStore for looking up objects. |
tree1_id | The SHA of the first Tree object to iterate, or None. | |
tree2_id | The SHA of the second Tree object to iterate, or None. | |
prune_identical | If True, identical subtrees will not be walked. | |
Returns | Iterator 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. |
Parameters | store | An ObjectStore for looking up objects. |
tree1_id | The SHA of the source tree. | |
tree2_id | The SHA of the target tree. | |
want_unchanged | If True, include TreeChanges for unmodified entries as well. | |
include_trees | Whether to include trees | |
rename_detector | RenameDetector object for detecting renames. | |
change_type_same | Whether to report change types in the same entry or as delete+add. | |
Returns | Iterator over TreeChange instances for each change between the source and target tree. |
Parameters | store | An ObjectStore for looking up objects. |
parent_tree_ids | An iterable of the SHAs of the parent trees. | |
tree_id | The SHA of the merge tree. | |
rename_detector | RenameDetector 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. |
Count the blocks in an object.
Splits the data into blocks either on lines or <=64-byte chunks of lines.
Parameters | obj | The object to count blocks for. |
Returns | A dict of block hashcode -> total bytes occurring. |
Parameters | block1 | The first dict of block hashcode -> total bytes. |
block2 | The second dict of block hashcode -> total bytes. | |
Returns | The number of bytes in common between blocks1 and blocks2. This is only approximate due to possible hash collisions. |
Parameters | obj1 | The first object to score. |
obj2 | The second object to score. | |
block_cache | An optional dict of SHA to block counts to cache results between calls. | |
Returns | The 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. |