Struct jj_lib::conflicts::Conflict

source ·
pub struct Conflict<T> { /* private fields */ }
Expand description

A generic representation of conflicting values.

There is exactly one more adds() than removes(). When interpreted as a series of diffs, the conflict’s (i+1)-st add is matched with the i-th remove. The zeroth add is considered a diff from the non-existent state.

Implementations§

source§

impl<T> Conflict<T>

source

pub fn new(removes: Vec<T>, adds: Vec<T>) -> Self

source

pub fn resolved(value: T) -> Self

source

pub fn from_legacy_form( removes: impl IntoIterator<Item = T>, adds: impl IntoIterator<Item = T> ) -> Conflict<Option<T>>

Create a Conflict from a removes and adds, padding with None to make sure that there is exactly one more adds than removes.

source

pub fn take(self) -> (Vec<T>, Vec<T>)

Returns the removes and adds as a pair.

source

pub fn removes(&self) -> &[T]

source

pub fn adds(&self) -> &[T]

source

pub fn as_resolved(&self) -> Option<&T>

Returns the resolved value, if this conflict is resolved. Does not resolve trivial conflicts.

source

pub fn simplify(self) -> Selfwhere T: PartialEq,

Simplify the conflict by joining diffs like A->B and B->C into A->C. Also drops trivial diffs like A->A.

source

pub fn resolve_trivial(&self) -> Option<&T>where T: Eq + Hash,

source

pub fn map<'a, U>(&'a self, f: impl FnMut(&'a T) -> U) -> Conflict<U>

Creates a new conflict by applying f to each remove and add.

source

pub fn maybe_map<'a, U>( &'a self, f: impl FnMut(&'a T) -> Option<U> ) -> Option<Conflict<U>>

Creates a new conflict by applying f to each remove and add, returning None if freturnsNone` for any of them.

source

pub fn try_map<'a, U, E>( &'a self, f: impl FnMut(&'a T) -> Result<U, E> ) -> Result<Conflict<U>, E>

Creates a new conflict by applying f to each remove and add, returning Err if freturnsErr` for any of them.

source§

impl<T> Conflict<Option<T>>

source

pub fn into_legacy_form(self) -> (Vec<T>, Vec<T>)

Creates lists of removes and adds from a Conflict by dropping None values. Note that the conversion is lossy: the order of None values is not preserved when converting back to a Conflict.

source§

impl<T> Conflict<Conflict<T>>

source

pub fn flatten(self) -> Conflict<T>

Flattens a nested conflict into a regular conflict.

Let’s say we have a 3-way merge of 3-way merges like this:

4 5 7 8 3 6 1 2 0

Flattening that results in this 9-way conflict:

4 5 0 7 8 3 2 1 6

source§

impl Conflict<Option<TreeValue>>

source

pub fn from_backend_conflict(conflict: Conflict) -> Self

Create a Conflict from a backend::Conflict, padding with None to make sure that there is exactly one more adds() than removes().

source

pub fn into_backend_conflict(self) -> Conflict

Creates a backend::Conflict from a Conflict by dropping None values. Note that the conversion is lossy: the order of None values is not preserved when converting back to a Conflict.

source

pub fn materialize( &self, store: &Store, path: &RepoPath, output: &mut dyn Write ) -> Result<()>

source

pub fn to_file_conflict(&self) -> Option<Conflict<Option<FileId>>>

source

pub fn describe(&self, file: &mut dyn Write) -> Result<()>

Give a summary description of the conflict’s “removes” and “adds”

source

pub fn update_from_content( &self, store: &Store, path: &RepoPath, content: &[u8] ) -> BackendResult<Option<Conflict<Option<TreeValue>>>>

Returns None if there are no conflict markers in content.

source§

impl Conflict<Option<FileId>>

source

pub fn extract_as_single_hunk( &self, store: &Store, path: &RepoPath ) -> Conflict<ContentHunk>

Trait Implementations§

source§

impl<T: Clone> Clone for Conflict<T>

source§

fn clone(&self) -> Conflict<T>

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<T: Debug> Debug for Conflict<T>

source§

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

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

impl<T: Hash> Hash for Conflict<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: PartialEq> PartialEq<Conflict<T>> for Conflict<T>

source§

fn eq(&self, other: &Conflict<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq> Eq for Conflict<T>

source§

impl<T> StructuralEq for Conflict<T>

source§

impl<T> StructuralPartialEq for Conflict<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere 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 Twhere 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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more