gix_ref::file

Struct Transaction

source
pub struct Transaction<'s, 'p> { /* private fields */ }
Expand description

A transaction on a file store

Implementations§

source§

impl Transaction<'_, '_>

source

pub fn prepare( self, edits: impl IntoIterator<Item = RefEdit>, ref_files_lock_fail_mode: Fail, packed_refs_lock_fail_mode: Fail, ) -> Result<Self, Error>

Prepare for calling commit(…) in a way that can be rolled back perfectly.

If the operation succeeds, the transaction can be committed or dropped to cause a rollback automatically. Rollbacks happen automatically on failure and they tend to be perfect. This method is idempotent.

source

pub fn rollback(self) -> Vec<RefEdit>

Rollback all intermediate state and return the RefEdits as we know them thus far.

Note that they have been altered compared to what was initially provided as they have been split and know about their current state on disk.

§Note

A rollback happens automatically as this instance is dropped as well.

source§

impl Transaction<'_, '_>

source

pub fn commit<'a>( self, committer: impl Into<Option<SignatureRef<'a>>>, ) -> Result<Vec<RefEdit>, Error>

Make all prepared permanent and return the performed edits which represent the current state of the affected refs in the ref store in that instant. Please note that the obtained edits may have been adjusted to contain more dependent edits or additional information. committer is used in the reflog and only if the reflog is actually written, which is why it is optional. Please note that if None is passed and the reflog needs to be written, the operation will be aborted late and a few refs may have been successfully committed already, making clear the non-atomic nature of multi-file edits.

On error the transaction may have been performed partially, depending on the nature of the error, and no attempt to roll back partial changes is made.

In this stage, we perform the following operations:

  • update the ref log
  • move updated refs into place
  • delete reflogs and empty parent directories
  • delete packed refs
  • delete their corresponding reference (if applicable) along with empty parent directories

Note that transactions will be prepared automatically as needed.

source§

impl<'p> Transaction<'_, 'p>

source

pub fn packed_refs(self, packed_refs: PackedRefs<'p>) -> Self

Configure the way packed refs are handled during the transaction

Trait Implementations§

source§

impl Debug for Transaction<'_, '_>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s, 'p> Freeze for Transaction<'s, 'p>

§

impl<'s, 'p> !RefUnwindSafe for Transaction<'s, 'p>

§

impl<'s, 'p> !Send for Transaction<'s, 'p>

§

impl<'s, 'p> !Sync for Transaction<'s, 'p>

§

impl<'s, 'p> Unpin for Transaction<'s, 'p>

§

impl<'s, 'p> !UnwindSafe for Transaction<'s, 'p>

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.