Skip to main content

ShadowRepo

Struct ShadowRepo 

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

A shared shadow bare git repository for a workspace.

Per-session checkpoint chains live under refs/sessions/<sid>/HEAD.

Implementations§

Source§

impl ShadowRepo

Source

pub fn open(workspace: impl Into<PathBuf>) -> Result<Self>

Open or create the shadow repo for workspace. Idempotent. Returns an error if git is not on PATH.

Source

pub fn open_at( workspace: impl Into<PathBuf>, shadow_dir: impl Into<PathBuf>, ) -> Result<Self>

Open or create a shadow repo with an explicit shadow_dir, bypassing paths::user_data_dir() resolution.

Used by tests so they don’t have to mutate RECURSIVE_HOME (and thus don’t need the cross-module env lock), letting checkpoint tests run in parallel. Production callers should stick to [open].

Source

pub fn workspace(&self) -> &Path

The workspace this repo snapshots.

Source

pub fn snapshot_for_session( &self, session_id: &str, message: &str, ) -> Result<CheckpointId>

Snapshot the current workspace state and advance refs/sessions/<session_id>/HEAD to the new commit.

Per-session temporary index files prevent concurrent snapshots from racing each other.

Source

pub fn list_for_session(&self, session_id: &str) -> Result<Vec<CheckpointInfo>>

List checkpoints for session_id in reverse chronological order.

Source

pub fn read_file_at( &self, checkpoint: &CheckpointId, path: &str, ) -> Result<Option<Vec<u8>>>

Read a single file’s contents at checkpoint. Returns Ok(None) if the file did not exist at that checkpoint.

Source

pub fn restore_paths( &self, checkpoint: &CheckpointId, paths: &[String], ) -> Result<RestoreStats>

Restore only the given workspace-relative file paths to their state at checkpoint. Files not in paths remain untouched. Files present in the workspace but not in the checkpoint tree are deleted (when listed in paths).

Source

pub fn diff( &self, a: &CheckpointId, b: Option<&CheckpointId>, paths: &[String], ) -> Result<String>

Diff between two checkpoints (or a vs current workspace if b is None), optionally limited to paths.

Source

pub fn changed_paths( &self, a: &CheckpointId, b: &CheckpointId, ) -> Result<Vec<String>>

List file paths changed between checkpoints a and b. Used for “shell-diff” attribution after run_shell calls.

Source

pub fn clean(&self) -> Result<()>

Drop the shadow repo entirely. Used by tests and clean UX.

Trait Implementations§

Source§

impl Clone for ShadowRepo

Source§

fn clone(&self) -> ShadowRepo

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 ShadowRepo

Source§

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

Formats the value using the given formatter. Read more

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more