gix_diff::rewrites

Struct 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. Note that directories with relation will be emitted if there is a match, along with all their matching child-items which are similarly bundled as rename.

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>,

Source§

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>,

Source§

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.