RebaseStateMachine

Struct RebaseStateMachine 

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

State machine for fault-tolerant rebase operations.

This state machine manages rebase operations with:

  • Checkpoint-based persistence
  • Automatic recovery from interruptions
  • Maximum recovery attempt limits
  • Conflict tracking

Implementations§

Source§

impl RebaseStateMachine

Source

pub fn new(upstream_branch: String) -> Self

Create a new state machine for a rebase operation.

§Arguments
  • upstream_branch - The branch to rebase onto
Source

pub fn load_or_create(upstream_branch: String) -> Result<Self>

Load an existing state machine from checkpoint or create a new one.

If a checkpoint exists, this will resume from that state. Otherwise, creates a new state machine.

This method handles corrupted checkpoints by:

  • Attempting to load backup checkpoint
  • Creating a fresh state if checkpoint is completely corrupted
§Arguments
  • upstream_branch - The branch to rebase onto (used if no checkpoint exists)
§Returns

Returns Ok(state_machine) if successful, or an error if loading fails.

Source

pub fn with_max_recovery_attempts(self, max: u32) -> Self

Set the maximum number of recovery attempts.

Source

pub fn transition_to(&mut self, phase: RebasePhase) -> Result<()>

Transition to a new phase and save checkpoint.

§Arguments
  • phase - The new phase to transition to
§Returns

Returns Ok(()) if the transition succeeded, or an error if saving failed.

Source

pub fn record_conflict(&mut self, file: String)

Record a conflict in a file.

§Arguments
  • file - The file path that has conflicts
Source

pub fn record_resolution(&mut self, file: String)

Record that a conflict has been resolved.

§Arguments
  • file - The file path that was resolved
Source

pub fn record_error(&mut self, error: String)

Record an error that occurred.

§Arguments
  • error - The error message to record
Source

pub fn all_conflicts_resolved(&self) -> bool

Check if all conflicts have been resolved.

Returns true if all conflicted files have been marked as resolved.

Source

pub fn checkpoint(&self) -> &RebaseCheckpoint

Get the current checkpoint.

Source

pub fn phase(&self) -> &RebasePhase

Get the current phase.

Source

pub fn upstream_branch(&self) -> &str

Get the upstream branch.

Source

pub fn unresolved_conflict_count(&self) -> usize

Get the number of unresolved conflicts.

Source

pub fn clear_checkpoint(self) -> Result<()>

Clear the checkpoint (typically on successful completion).

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.