gix_diff::tree_with_rewrites

Enum Change

Source
pub enum Change {
    Addition {
        location: BString,
        relation: Option<Relation>,
        entry_mode: EntryMode,
        id: ObjectId,
    },
    Deletion {
        location: BString,
        relation: Option<Relation>,
        entry_mode: EntryMode,
        id: ObjectId,
    },
    Modification {
        location: BString,
        previous_entry_mode: EntryMode,
        previous_id: ObjectId,
        entry_mode: EntryMode,
        id: ObjectId,
    },
    Rewrite {
        source_location: BString,
        source_entry_mode: EntryMode,
        source_relation: Option<Relation>,
        source_id: ObjectId,
        diff: Option<DiffLineStats>,
        entry_mode: EntryMode,
        id: ObjectId,
        location: BString,
        relation: Option<Relation>,
        copy: bool,
    },
}
Available on crate feature blob only.
Expand description

Represents any possible change in order to turn one tree into another, with fully-owned data.

Variants§

§

Addition

An entry was added, like the addition of a file or directory.

Fields

§location: BString

The location of the file or directory.

It may be empty if file names is None.

§relation: Option<Relation>

Identifies a relationship between this instance and another one, making it easy to reconstruct the top-level of directory changes.

§entry_mode: EntryMode

The mode of the added entry.

§id: ObjectId

The object id of the added entry.

§

Deletion

An entry was deleted, like the deletion of a file or directory.

Fields

§location: BString

The location of the file or directory.

It may be empty if file names is None.

§relation: Option<Relation>

Identifies a relationship between this instance and another one, making it easy to reconstruct the top-level of directory changes.

§entry_mode: EntryMode

The mode of the deleted entry.

§id: ObjectId

The object id of the deleted entry.

§

Modification

An entry was modified, e.g. changing the contents of a file adjusts its object id and turning a file into a symbolic link adjusts its mode.

Fields

§location: BString

The location of the file or directory.

It may be empty if file names is None.

§previous_entry_mode: EntryMode

The mode of the entry before the modification.

§previous_id: ObjectId

The object id of the entry before the modification.

§entry_mode: EntryMode

The mode of the entry after the modification.

§id: ObjectId

The object id after the modification.

§

Rewrite

Entries are considered rewritten if they are not trees and they, according to some understanding of identity, were renamed or copied. In case of renames, this means they originally appeared as Deletion signalling their source as well as an Addition acting as destination.

In case of copies, the copy flag is true and typically represents a perfect copy of a source was made.

This variant can only be encountered if rewrite tracking is enabled.

Note that mode changes may have occurred as well, i.e. changes from executable to non-executable or vice-versa.

Fields

§source_location: BString

The location of the source of the rename operation.

It may be empty if file names is None.

§source_entry_mode: EntryMode

The mode of the entry before the rename.

§source_relation: Option<Relation>

Identifies a relationship between the source and another source, making it easy to reconstruct the top-level of directory changes.

§source_id: ObjectId

The object id of the entry before the rename.

Note that this is the same as id if we require the similarity to be 100%, but may be different otherwise.

§diff: Option<DiffLineStats>

Information about the diff we performed to detect similarity and match the source_id with the current state at id. It’s None if source_id is equal to id, as identity made an actual diff computation unnecessary.

§entry_mode: EntryMode

The mode of the entry after the rename. It could differ but still be considered a rename as we are concerned only about content.

§id: ObjectId

The object id after the rename.

§location: BString

The location after the rename or copy operation.

It may be empty if file names is None.

§relation: Option<Relation>

Identifies a relationship between this destination and another destination, making it easy to reconstruct the top-level of directory changes.

§copy: bool

If true, this rewrite is created by copy, and source_id is pointing to its source. Otherwise, it’s a rename, and source_id points to a deleted object, as renames are tracked as deletions and additions of the same or similar content.

Implementations§

Source§

impl Change

Lifecycle

Source

pub fn to_ref(&self) -> ChangeRef<'_>

Return an attached version of this instance that uses old_repo for previous values and new_repo for current values.

Source§

impl Change

Source

pub fn relation(&self) -> Option<Relation>

Return the relation this instance may have to other changes.

Source

pub fn entry_mode(&self) -> EntryMode

Return the current mode of this instance.

Source

pub fn entry_mode_and_id(&self) -> (EntryMode, &oid)

Return the current mode of this instance, along with its object id.

Source

pub fn source_entry_mode_and_id(&self) -> (EntryMode, &oid)

Return the previous mode and id of the resource where possible, i.e. the source of a rename or copy, or a modification.

Source

pub fn location(&self) -> &BStr

Return the current location of the resource, i.e. the destination of a rename or copy, or the location at which an addition, deletion or modification took place.

Source

pub fn source_location(&self) -> &BStr

Return the previous location of the resource where possible, i.e. the source of a rename or copy, or the location at which an addition, deletion or modification took place.

Trait Implementations§

Source§

impl Clone for Change

Source§

fn clone(&self) -> Change

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Change

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Change

Source§

fn eq(&self, other: &Change) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Change

Auto Trait Implementations§

§

impl Freeze for Change

§

impl RefUnwindSafe for Change

§

impl Send for Change

§

impl Sync for Change

§

impl Unpin for Change

§

impl UnwindSafe for Change

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.