pub struct MergeStateFile {
pub phase: MergePhase,
pub sources: Vec<WorkspaceId>,
pub epoch_before: EpochId,
pub frozen_heads: BTreeMap<WorkspaceId, GitOid>,
pub epoch_candidate: Option<GitOid>,
pub validation_result: Option<ValidationResult>,
pub epoch_after: Option<EpochId>,
pub started_at: u64,
pub updated_at: u64,
pub abort_reason: Option<String>,
}Expand description
The persisted merge-state file.
Written to .manifold/merge-state.json. Every mutation is fsynced to
disk so a crash always leaves a valid, recoverable file.
Fields§
§phase: MergePhaseCurrent merge phase.
sources: Vec<WorkspaceId>Source workspaces being merged.
epoch_before: EpochIdThe epoch before this merge started.
frozen_heads: BTreeMap<WorkspaceId, GitOid>Frozen workspace HEAD commit OIDs, recorded during PREPARE.
Maps each source workspace to its HEAD at the time inputs were frozen. After PREPARE, these are immutable references — the merge operates on these exact commits regardless of any concurrent workspace activity.
epoch_candidate: Option<GitOid>The candidate commit produced during BUILD (set in Build phase).
validation_result: Option<ValidationResult>The validation result (set in Validate phase).
epoch_after: Option<EpochId>The new epoch after COMMIT (set in Commit phase).
started_at: u64Unix timestamp (seconds) when the merge started.
updated_at: u64Unix timestamp (seconds) of the last state update.
abort_reason: Option<String>Abort reason, if the merge was aborted.
Implementations§
Source§impl MergeStateFile
impl MergeStateFile
Sourcepub const fn new(
sources: Vec<WorkspaceId>,
epoch_before: EpochId,
now: u64,
) -> Self
pub const fn new( sources: Vec<WorkspaceId>, epoch_before: EpochId, now: u64, ) -> Self
Create a new merge-state file in the Prepare phase.
§Arguments
sources- The workspaces being merged.epoch_before- The current epoch at the start of the merge.now- The current Unix timestamp in seconds.
Sourcepub fn advance(
&mut self,
next: MergePhase,
now: u64,
) -> Result<(), MergeStateError>
pub fn advance( &mut self, next: MergePhase, now: u64, ) -> Result<(), MergeStateError>
Advance to the next phase, updating the timestamp.
§Errors
Returns MergeStateError::InvalidTransition if the transition is
not allowed.
Sourcepub fn abort(
&mut self,
reason: impl Into<String>,
now: u64,
) -> Result<(), MergeStateError>
pub fn abort( &mut self, reason: impl Into<String>, now: u64, ) -> Result<(), MergeStateError>
Abort the merge with a reason.
§Errors
Returns MergeStateError::InvalidTransition if the merge is
already in a terminal state.
Sourcepub fn to_json(&self) -> Result<String, MergeStateError>
pub fn to_json(&self) -> Result<String, MergeStateError>
Serialize to pretty-printed JSON.
§Errors
Returns MergeStateError::Serialize on serialization failure.
Sourcepub fn from_json(json: &str) -> Result<Self, MergeStateError>
pub fn from_json(json: &str) -> Result<Self, MergeStateError>
Sourcepub fn write_exclusive(&self, path: &Path) -> Result<bool, MergeStateError>
pub fn write_exclusive(&self, path: &Path) -> Result<bool, MergeStateError>
Create the merge-state file exclusively (O_CREAT | O_EXCL).
Uses OpenOptions::create_new(true) so exactly one writer wins.
Returns Ok(true) on success, Ok(false) if the file already exists,
and Err on any other I/O error.
The write is crash-safe: data is serialized, written, and fsynced
directly to the target path. Unlike write_atomic, there is no
temp+rename dance because the O_EXCL flag already guarantees
the file did not exist.
Sourcepub fn write_atomic(&self, path: &Path) -> Result<(), MergeStateError>
pub fn write_atomic(&self, path: &Path) -> Result<(), MergeStateError>
Write the merge-state file atomically with fsync.
- Serialize to pretty JSON.
- Write to a temporary file in the same directory.
- fsync the temporary file.
- Rename (atomic on POSIX) over the target path.
§Errors
Returns MergeStateError on I/O or serialization failure.
Sourcepub fn read(path: &Path) -> Result<Self, MergeStateError>
pub fn read(path: &Path) -> Result<Self, MergeStateError>
Read a merge-state file from disk.
§Errors
Returns MergeStateError::NotFound if the file does not exist.
Returns MergeStateError::Deserialize if the file is malformed.
Sourcepub fn default_path(manifold_dir: &Path) -> PathBuf
pub fn default_path(manifold_dir: &Path) -> PathBuf
Return the default merge-state file path for a .manifold/ directory.
Trait Implementations§
Source§impl Clone for MergeStateFile
impl Clone for MergeStateFile
Source§fn clone(&self) -> MergeStateFile
fn clone(&self) -> MergeStateFile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MergeStateFile
impl Debug for MergeStateFile
Source§impl<'de> Deserialize<'de> for MergeStateFile
impl<'de> Deserialize<'de> for MergeStateFile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for MergeStateFile
impl PartialEq for MergeStateFile
Source§impl Serialize for MergeStateFile
impl Serialize for MergeStateFile
impl Eq for MergeStateFile
impl StructuralPartialEq for MergeStateFile
Auto Trait Implementations§
impl Freeze for MergeStateFile
impl RefUnwindSafe for MergeStateFile
impl Send for MergeStateFile
impl Sync for MergeStateFile
impl Unpin for MergeStateFile
impl UnsafeUnpin for MergeStateFile
impl UnwindSafe for MergeStateFile
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.