pub struct SnapshotRepo { /* private fields */ }Expand description
Wrapper around the per-workspace side-git repo.
Implementations§
Source§impl SnapshotRepo
impl SnapshotRepo
Sourcepub fn open_or_init(workspace: &Path) -> Result<SnapshotRepo, Error>
pub fn open_or_init(workspace: &Path) -> Result<SnapshotRepo, Error>
Open or initialize the snapshot repo for workspace.
Uses DEFAULT_SNAPSHOT_MAX_WORKSPACE_GB. Prefer
Self::open_or_init_with_max_gb when config supplies a limit.
Sourcepub fn open_or_init_with_max_gb(
workspace: &Path,
max_workspace_gb: f64,
) -> Result<SnapshotRepo, Error>
pub fn open_or_init_with_max_gb( workspace: &Path, max_workspace_gb: f64, ) -> Result<SnapshotRepo, Error>
Open or initialize the snapshot repo, skipping side-git init when the
workspace on-disk size exceeds max_workspace_gb.
Sourcepub fn snapshot(&self, label: &str) -> Result<SnapshotId, Error>
pub fn snapshot(&self, label: &str) -> Result<SnapshotId, Error>
Take a snapshot of the current working tree.
Internally: git add -A, git write-tree, git commit-tree, then
git update-ref HEAD <commit>.
git add -A honours the user’s workspace ignore rules while staging
into the side repo’s index.
Returns the snapshot’s commit SHA.
Sourcepub fn restore(&self, id: &SnapshotId) -> Result<(), Error>
pub fn restore(&self, id: &SnapshotId) -> Result<(), Error>
Restore the workspace to the state at id.
Uses git checkout <sha> -- :/ which checks out every path in the
snapshot tree relative to the workspace root. We do NOT touch the
user’s own .git — snapshots only contain working-tree files.
Sourcepub fn list(&self, limit: usize) -> Result<Vec<Snapshot>, Error>
pub fn list(&self, limit: usize) -> Result<Vec<Snapshot>, Error>
List up to limit most-recent snapshots, newest first.
Sourcepub fn prune_older_than(&self, max_age: Duration) -> Result<usize, Error>
pub fn prune_older_than(&self, max_age: Duration) -> Result<usize, Error>
Drop snapshots older than max_age, returning the count removed.
Strategy: identify keepable commits (younger than the cutoff),
reset HEAD to the oldest survivor, then git reflog expire +
git gc --prune=now to actually reclaim space. Cheap and avoids
rewriting history when nothing has aged out.
Auto Trait Implementations§
impl Freeze for SnapshotRepo
impl RefUnwindSafe for SnapshotRepo
impl Send for SnapshotRepo
impl Sync for SnapshotRepo
impl Unpin for SnapshotRepo
impl UnsafeUnpin for SnapshotRepo
impl UnwindSafe for SnapshotRepo
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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