pub struct Tracker<T> { /* private fields */ }
blob
only.Expand description
A type to retain state related to an ongoing tracking operation to retain sets of interesting changes of which some are retained to at a later stage compute the ones that seem to be renames or copies.
Implementations§
source§impl<T: Change> Tracker<T>
impl<T: Change> Tracker<T>
build state and find matches.
sourcepub fn try_push_change(&mut self, change: T, location: &BStr) -> Option<T>
pub fn try_push_change(&mut self, change: T, location: &BStr) -> Option<T>
We may refuse the push if that information isn’t needed for what we have to track.
sourcepub fn emit<PushSourceTreeFn, E>(
&mut self,
cb: impl FnMut(Destination<'_, T>, Option<Source<'_>>) -> Action,
diff_cache: &mut Platform,
objects: &impl FindObjectOrHeader,
push_source_tree: PushSourceTreeFn
) -> Result<Outcome, Error>
pub fn emit<PushSourceTreeFn, E>( &mut self, cb: impl FnMut(Destination<'_, T>, Option<Source<'_>>) -> Action, diff_cache: &mut Platform, objects: &impl FindObjectOrHeader, push_source_tree: PushSourceTreeFn ) -> Result<Outcome, Error>
Can only be called once effectively as it alters its own state to assure each item is only emitted once.
cb(destination, source)
is called for each item, either with Some(source)
if it’s
the destination of a copy or rename, or with None
for source if no relation to other
items in the tracked set exist, which is like saying ‘no rename or rewrite or copy’ happened.
objects
is used to access blob data for similarity checks if required and is taken directly from the object database.
Worktree filters and text conversions will be applied afterwards automatically. Note that object-caching should not
be enabled as caching is implemented by diff_cache
, after all, the blob that’s actually diffed is going
through conversion steps.
diff_cache
is a way to retain a cache of resources that are prepared for rapid diffing, and it also controls
the diff-algorithm (provided no user-algorithm is set).
Note that we control a few options of diff_cache
to assure it will ignore external commands.
Note that we do not control how the diff_cache
converts resources, it’s left to the caller to decide
if it should look at what’s stored in git
, or in the working tree, along with all diff-specific conversions.
push_source_tree(push_fn: push(change, location))
is a function that is called when the entire tree of the source
should be added as modifications by calling push
repeatedly to use for perfect copy tracking. Note that push
will panic if change
is not a modification, and it’s valid to not call push
at all.