Struct gix_diff::rewrites::Tracker

source ·
pub struct Tracker<T> { /* private fields */ }
Available on crate feature 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>

Lifecycle

source

pub fn new(rewrites: Rewrites) -> Self

Create a new instance with rewrites configuration.

source§

impl<T: Change> Tracker<T>

build state and find matches.

source

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.

source

pub fn emit<PushSourceTreeFn, E>( &mut self, cb: impl FnMut(Destination<'_, T>, Option<Source<'_, T>>) -> Action, diff_cache: &mut Platform, objects: &impl FindObjectOrHeader, push_source_tree: PushSourceTreeFn, ) -> Result<Outcome, Error>
where PushSourceTreeFn: FnMut(&mut dyn FnMut(T, &BStr)) -> Result<(), E>, E: Error + Send + Sync + 'static,

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.

Auto Trait Implementations§

§

impl<T> Freeze for Tracker<T>

§

impl<T> RefUnwindSafe for Tracker<T>
where T: RefUnwindSafe,

§

impl<T> Send for Tracker<T>
where T: Send,

§

impl<T> Sync for Tracker<T>
where T: Sync,

§

impl<T> Unpin for Tracker<T>
where T: Unpin,

§

impl<T> UnwindSafe for Tracker<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.