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>
impl<'parent> PlatformRef<'parent>
Plumbing
sourcepub fn prepare_external_driver(
&self,
merge_command: BString,
_: Labels<'_>,
context: Context,
) -> Result<Command, Error>
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
withX
replaced with characters for uniqueness.
sourcepub fn configured_driver(&self) -> Result<&'parent Driver, BuiltinDriver>
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>
impl<'parent> PlatformRef<'parent>
Plumbing
sourcepub fn builtin_merge(
&self,
driver: BuiltinDriver,
out: &mut Vec<u8>,
input: &mut InternedInput<&'parent [u8]>,
labels: Labels<'_>,
) -> Option<(Pick, Resolution)>
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>
impl<'parent> PlatformRef<'parent>
Convenience
sourcepub fn merge(
&self,
out: &mut Vec<u8>,
labels: Labels<'_>,
context: Context,
) -> Result<(Pick, Resolution), Error>
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.
Trait Implementations§
source§impl<'parent> Clone for PlatformRef<'parent>
impl<'parent> Clone for PlatformRef<'parent>
source§fn clone(&self) -> PlatformRef<'parent>
fn clone(&self) -> PlatformRef<'parent>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreimpl<'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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)