class documentation

Filter for rewriting commits during filter-branch operations.

Method __init__ Initialize a commit filter.
Method get_mapping Get the mapping of old commit SHAs to new commit SHAs.
Method process_commit Process a single commit, creating a filtered version.
Instance Variable commit_filter Undocumented
Instance Variable filter_author Undocumented
Instance Variable filter_committer Undocumented
Instance Variable filter_fn Undocumented
Instance Variable filter_message Undocumented
Instance Variable index_filter Undocumented
Instance Variable object_store Undocumented
Instance Variable parent_filter Undocumented
Instance Variable prune_empty Undocumented
Instance Variable subdirectory_filter Undocumented
Instance Variable tag_name_filter Undocumented
Instance Variable tree_filter Undocumented
Method _apply_index_filter Apply index filter by creating temp index and running filter.
Method _apply_tree_filter Apply tree filter by checking out tree and running filter.
Method _filter_tree_with_subdirectory Extract a subdirectory from a tree as the new root.
Instance Variable _old_to_new Undocumented
Instance Variable _processed Undocumented
Instance Variable _tree_cache Undocumented
def __init__(self, object_store: BaseObjectStore, *, filter_fn: Callable[[Commit], CommitData | None] | None = None, filter_author: Callable[[bytes], bytes | None] | None = None, filter_committer: Callable[[bytes], bytes | None] | None = None, filter_message: Callable[[bytes], bytes | None] | None = None, tree_filter: Callable[[ObjectID, str], ObjectID | None] | None = None, index_filter: Callable[[ObjectID, str], ObjectID | None] | None = None, parent_filter: Callable[[Sequence[ObjectID]], list[ObjectID]] | None = None, commit_filter: Callable[[Commit, ObjectID], ObjectID | None] | None = None, subdirectory_filter: bytes | None = None, prune_empty: bool = False, tag_name_filter: Callable[[bytes], bytes | None] | None = None):

Initialize a commit filter.

Parameters
object_store:BaseObjectStoreObject store to read from and write to
filter_fn:Callable[[Commit], CommitData | None] | NoneOptional callable that takes a Commit object and returns a dict of updated fields (author, committer, message, etc.)
filter_author:Callable[[bytes], bytes | None] | NoneOptional callable that takes author bytes and returns updated author bytes or None to keep unchanged
filter_committer:Callable[[bytes], bytes | None] | NoneOptional callable that takes committer bytes and returns updated committer bytes or None to keep unchanged
filter_message:Callable[[bytes], bytes | None] | NoneOptional callable that takes commit message bytes and returns updated message bytes
tree_filter:Callable[[ObjectID, str], ObjectID | None] | NoneOptional callable that takes (tree_sha, temp_dir) and returns new tree SHA after modifying working directory
index_filter:Callable[[ObjectID, str], ObjectID | None] | NoneOptional callable that takes (tree_sha, temp_index_path) and returns new tree SHA after modifying index
parent_filter:Callable[[Sequence[ObjectID]], list[ObjectID]] | NoneOptional callable that takes parent list and returns modified parent list
commit_filter:Callable[[Commit, ObjectID], ObjectID | None] | NoneOptional callable that takes (Commit, tree_sha) and returns new commit SHA or None to skip commit
subdirectory_filter:bytes | NoneOptional subdirectory path to extract as new root
prune_empty:boolWhether to prune commits that become empty
tag_name_filter:Callable[[bytes], bytes | None] | NoneOptional callable to rename tags
def get_mapping(self) -> dict[ObjectID, ObjectID]:

Get the mapping of old commit SHAs to new commit SHAs.

Returns
dict[ObjectID, ObjectID]Dictionary mapping old SHAs to new SHAs
def process_commit(self, commit_sha: ObjectID) -> ObjectID | None:

Process a single commit, creating a filtered version.

Parameters
commit_sha:ObjectIDSHA of the commit to process
Returns
ObjectID | NoneSHA of the new commit, or None if object not found
commit_filter =

Undocumented

filter_author =

Undocumented

filter_committer =

Undocumented

filter_fn =

Undocumented

filter_message =

Undocumented

index_filter =

Undocumented

object_store =

Undocumented

parent_filter =

Undocumented

prune_empty =

Undocumented

subdirectory_filter =

Undocumented

tag_name_filter =

Undocumented

tree_filter =

Undocumented

def _apply_index_filter(self, tree_sha: ObjectID) -> ObjectID:

Apply index filter by creating temp index and running filter.

Parameters
tree_sha:ObjectIDSHA of the tree to filter
Returns
ObjectIDSHA of the filtered tree
def _apply_tree_filter(self, tree_sha: ObjectID) -> ObjectID:

Apply tree filter by checking out tree and running filter.

Parameters
tree_sha:ObjectIDSHA of the tree to filter
Returns
ObjectIDSHA of the filtered tree
def _filter_tree_with_subdirectory(self, tree_sha: ObjectID, subdirectory: bytes) -> ObjectID | None:

Extract a subdirectory from a tree as the new root.

Parameters
tree_sha:ObjectIDSHA of the tree to filter
subdirectory:bytesPath to subdirectory to extract
Returns
ObjectID | NoneSHA of the new tree containing only the subdirectory, or None if not found
_old_to_new: dict[ObjectID, ObjectID] =

Undocumented

_processed: set[ObjectID] =

Undocumented

_tree_cache: dict[ObjectID, ObjectID] =

Undocumented