Skip to main content

RefTransaction

Struct RefTransaction 

Source
pub struct RefTransaction { /* private fields */ }
Expand description

Batch of ref updates prepared for super::RefStore::prepare.

Implementations§

Source§

impl RefTransaction

Source

pub fn new() -> Self

Start an empty transaction.

Source

pub fn update(self, update: RefUpdate) -> Result<Self, RefStoreError>

Append an update, rejecting duplicate ref names in the same batch.

§Errors

Returns RefStoreError::DuplicateUpdate when update.name was already queued.

Source

pub fn push_update(&mut self, update: RefUpdate) -> Result<(), RefStoreError>

Append an update in place.

§Errors

Returns RefStoreError::DuplicateUpdate when update.name was already queued.

Source

pub fn updates(&self) -> &[RefUpdate]

Borrow the queued updates.

Source

pub fn into_updates(self) -> Vec<RefUpdate>

Consume the transaction and return the update list.

Source

pub fn reflog_renames(&self) -> &[RefReflogRename]

Reflog rename operations bundled with this transaction.

Source

pub fn case_only_renames(&self) -> &[RefCaseOnlyRename]

Case-only ref renames bundled with this transaction.

Source

pub fn with_reflog_rename(self, rename: RefReflogRename) -> Self

Append a branch reflog rename to this transaction.

Source

pub fn with_case_only_rename(self, rename: RefCaseOnlyRename) -> Self

Append a case-only branch ref rename (files backend).

Source

pub fn initial(self) -> Self

Mark this as the first ref transaction of a new repository, such as the remote refs a clone imports (Git’s initial ref transaction).

The files backend then writes the batch as one packed-refs rewrite, without a loose file or lock per ref, when every update creates a direct ref (no reflog, expectation Expected::Any or Expected::Missing) that does not exist yet in the common directory. Any other batch, and every other backend, commits as usual, so the flag never changes which refs end up stored, only how they are laid out.

The packed write takes only packed-refs.lock: callers promise no other writer is creating the same refs, which holds for a repository nobody else knows about yet.

Source

pub fn is_initial(&self) -> bool

Whether Self::initial marked this transaction.

Source

pub fn allowing_failures(self) -> Self

Allow per-ref rejections during prepare while committing the rest in one batch.

Rejections are returned from super::PreparedRefTransaction::rejected_updates. Compare-and-swap, directory/file, and object-target failures on one ref do not roll back sibling updates in the same transaction. Duplicate names, invalid ref names, and other whole-transaction errors still fail prepare entirely.

Source

pub fn allows_failures(&self) -> bool

Whether Self::allowing_failures was set.

Source

pub fn into_parts( self, ) -> (Vec<RefUpdate>, Vec<RefReflogRename>, Vec<RefCaseOnlyRename>)

Split into ref updates, reflog renames, and case-only ref renames.

Trait Implementations§

Source§

impl Clone for RefTransaction

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RefTransaction

Source§

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

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

impl Default for RefTransaction

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for RefTransaction

Source§

impl PartialEq for RefTransaction

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RefTransaction

Auto Trait Implementations§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.