Skip to main content

OpLog

Struct OpLog 

Source
pub struct OpLog { /* private fields */ }

Implementations§

Source§

impl OpLog

Source

pub fn open(root: &Path) -> Result<Self>

Source

pub fn put(&self, rec: &OperationRecord) -> Result<()>

Persist a record. Idempotent on existing op_ids (the bytes must match by content addressing).

Crash safety: the tempfile’s data is fsync’d before rename, so a successful return implies a durable file at the final path. The containing directory is not fsync’d; on a crash between rename and the directory’s metadata flush, the file can be lost. For a content-addressed log this is acceptable — a lost record can be re-derived from the same source — but callers that also persist references to the op_id (e.g. branch heads) should fsync those refs after put returns.

Source

pub fn get(&self, op_id: &OpId) -> Result<Option<OperationRecord>>

Source

pub fn walk_back( &self, head: &OpId, limit: Option<usize>, ) -> Result<Vec<OperationRecord>>

Walk parents transitively. Newest-first, BFS, dedup’d by op_id. Stops at parentless ops or after limit records.

Source

pub fn walk_forward( &self, head: &OpId, limit: Option<usize>, ) -> Result<Vec<OperationRecord>>

Same set as walk_back but oldest-first. Used by branch_head for left-to-right transition replay.

Source

pub fn lca(&self, a: &OpId, b: &OpId) -> Result<Option<OpId>>

Common ancestor of two op_ids in the DAG.

On tree-shaped histories and chain merges this is the lowest common ancestor — the closest shared op. On criss-cross merges (two ops each with two parents from independent histories) there can be multiple incomparable common ancestors; this picks one deterministically (the first hit when traversing b’s ancestors newest-first), but not via a recursive merge. None if no shared ancestor exists.

Tier-1 merge in #129 covers linear and tree-shaped histories; criss-cross resolution is deferred to a future tier (Git’s recursive strategy is the reference).

Source

pub fn list_all(&self) -> Result<Vec<OperationRecord>>

Every record in the log. Order is whatever the directory listing produces — undefined and not stable. Used by the [crate::predicate] evaluator when no narrower candidate set is available.

Source

pub fn ops_since( &self, head: &OpId, base: Option<&OpId>, ) -> Result<Vec<OperationRecord>>

Ops in head’s history that are not in base’s history. base = None means “include all of head’s history” (used for independent-histories case where the LCA is None).

Auto Trait Implementations§

§

impl Freeze for OpLog

§

impl RefUnwindSafe for OpLog

§

impl Send for OpLog

§

impl Sync for OpLog

§

impl Unpin for OpLog

§

impl UnsafeUnpin for OpLog

§

impl UnwindSafe for OpLog

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

Source§

type Output = T

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