gix_merge::blob

Struct PlatformRef

source
pub struct PlatformRef<'parent> {
    pub current: ResourceRef<'parent>,
    pub ancestor: ResourceRef<'parent>,
    pub other: ResourceRef<'parent>,
    pub driver: DriverChoice,
    pub options: Options,
    /* private fields */
}
Expand description

The product of a prepare_merge() call to finally perform the merge and retrieve the merge results.

Fields§

§current: ResourceRef<'parent>

The current or our side of the merge operation.

§ancestor: ResourceRef<'parent>

The ancestor or base of the merge operation.

§other: ResourceRef<'parent>

The other or their side of the merge operation.

§driver: DriverChoice

Which driver to use according to the resource’s configuration, using the path of current to read git-attributes.

§options: Options

Possibly processed options for use when performing the actual merge.

They may be inspected before the merge, or altered at will.

Implementations§

source§

impl<'parent> PlatformRef<'parent>

Plumbing

source

pub fn prepare_external_driver( &self, merge_command: BString, _: Labels<'_>, context: Context, ) -> Result<Command, Error>

Given merge_command and context, typically obtained from git-configuration, and the currently set merge-resources, prepare the invocation and temporary files needed to launch it according to protocol. See the documentation of Driver::command for possible substitutions.

Please note that this is an expensive operation this will always create three temporary files to hold all sides of the merge.

The resulting command should be spawned, and when successful, the result file can be opened to read back the result into a suitable buffer.

§Deviation
  • We allow passing more context than Git would by taking a whole context, it’s up to the caller to decide how much is filled.
  • Our tempfiles aren’t suffixed .merge_file_XXXXXX with X replaced with characters for uniqueness.
source

pub fn configured_driver(&self) -> Result<&'parent Driver, BuiltinDriver>

Return the configured driver program for use with Self::prepare_external_driver(), or Err with the built-in driver to use instead.

source§

impl<'parent> PlatformRef<'parent>

Plumbing

source

pub fn builtin_merge( &self, driver: BuiltinDriver, out: &mut Vec<u8>, input: &mut InternedInput<&'parent [u8]>, labels: Labels<'_>, ) -> Option<(Pick, Resolution)>

Perform the merge using the given driver, possibly placing the output in out. input can be used to keep tokens between runs, but note it will only grow in size unless cleared manually. Use labels to annotate conflict sections in case of a text-merge. Returns None if one of the buffers is too large, making a merge impossible. Note that if the pick wasn’t Pick::Buffer, then out will not have been cleared, and one has to take the data from the respective resource.

source§

impl<'parent> PlatformRef<'parent>

Convenience

source

pub fn merge( &self, out: &mut Vec<u8>, labels: Labels<'_>, context: Context, ) -> Result<(Pick, Resolution), Error>

Perform the merge, possibly invoking an external merge command, and store the result in out, returning (pick, resolution). Note that pick indicates which resource the buffer should be taken from, unless it’s Pick::Buffer to indicate it’s out. Use labels to annotate conflict sections in case of a text-merge. The merge is configured by opts and possible merge driver command executions are affected by context.

Note that at this stage, none-existing input data will simply default to an empty buffer when running the actual merge algorithm. Too-large resources will result in an error.

Generally, it is assumed that standard logic, like deletions of files, is handled before any of this is called, so we are lenient in terms of buffer handling to make it more useful in the face of missing local files.

source

pub fn buffer_by_pick(&self, pick: Pick) -> Option<&'parent [u8]>

Using a pick obtained from merge(), obtain the respective buffer suitable for reading or copying. Return None if the buffer is too large, or if the pick corresponds to a buffer (that was written separately).

Trait Implementations§

source§

impl<'parent> Clone for PlatformRef<'parent>

source§

fn clone(&self) -> PlatformRef<'parent>

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<'parent> Copy for PlatformRef<'parent>

Auto Trait Implementations§

§

impl<'parent> Freeze for PlatformRef<'parent>

§

impl<'parent> RefUnwindSafe for PlatformRef<'parent>

§

impl<'parent> Send for PlatformRef<'parent>

§

impl<'parent> Sync for PlatformRef<'parent>

§

impl<'parent> Unpin for PlatformRef<'parent>

§

impl<'parent> UnwindSafe for PlatformRef<'parent>

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 T)

🔬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.