pub trait Vcs {
// Required methods
fn ensure_commit(&self, repo: &Path, refspec_or_sha: &str) -> Result<()>;
fn add_workspace(
&self,
repo: &Path,
ws: &Path,
checkout: &Checkout,
name: &str,
version: &str,
) -> Result<String>;
fn update_workspace(
&self,
repo: &Path,
ws: &Path,
checkout: &Checkout,
name: &str,
version: &str,
) -> Result<String>;
fn is_dirty(&self, ws: &Path, expected_head: &str) -> Result<bool>;
fn position(&self, ws: &Path, commit: &str) -> Result<()>;
fn commits(
&self,
ws: &Path,
tip: &str,
limit: usize,
) -> Result<Vec<(String, String)>>;
fn remove_workspace(&self, repo: &Path, ws: &Path, name: &str) -> Result<()>;
}Required Methods§
Sourcefn ensure_commit(&self, repo: &Path, refspec_or_sha: &str) -> Result<()>
fn ensure_commit(&self, repo: &Path, refspec_or_sha: &str) -> Result<()>
Fetch refspec_or_sha into the canonical repo if not already present.
Sourcefn add_workspace(
&self,
repo: &Path,
ws: &Path,
checkout: &Checkout,
name: &str,
version: &str,
) -> Result<String>
fn add_workspace( &self, repo: &Path, ws: &Path, checkout: &Checkout, name: &str, version: &str, ) -> Result<String>
Create a new worktree/workspace at ws from the canonical repo, applying checkout.
name is the review’s key slug (e.g. moz/D12345), used to namespace the ref that pins
this version so it survives future updates; see update_workspace. Returns the
resulting head id.
Sourcefn update_workspace(
&self,
repo: &Path,
ws: &Path,
checkout: &Checkout,
name: &str,
version: &str,
) -> Result<String>
fn update_workspace( &self, repo: &Path, ws: &Path, checkout: &Checkout, name: &str, version: &str, ) -> Result<String>
Re-point an existing, clean workspace at a new checkout/version. The commit the
workspace pointed at before this call remains reachable afterwards (each call pins its
own resulting head under a name/version-namespaced ref rather than overwriting the
previous one), so old versions stay available for interdiffing until remove_workspace
drops them all. Returns the new head id.
Sourcefn is_dirty(&self, ws: &Path, expected_head: &str) -> Result<bool>
fn is_dirty(&self, ws: &Path, expected_head: &str) -> Result<bool>
True if the workspace has local modifications, or its head isn’t expected_head (the
stack tip) or one of its ancestors - either case means sync must not touch it silently.
Sitting on an earlier patch of the stack (see position) is not dirty.
Sourcefn position(&self, ws: &Path, commit: &str) -> Result<()>
fn position(&self, ws: &Path, commit: &str) -> Result<()>
Move a clean workspace to commit, one of the patches reachable from the stack tip. Never
rewrites any of the stack’s commits, so the tip stays valid for is_dirty.
Sourcefn commits(
&self,
ws: &Path,
tip: &str,
limit: usize,
) -> Result<Vec<(String, String)>>
fn commits( &self, ws: &Path, tip: &str, limit: usize, ) -> Result<Vec<(String, String)>>
Up to limit commits reachable from tip (newest first) as (commit id, message), so a
caller can find the one carrying a particular review’s patch.
Sourcefn remove_workspace(&self, repo: &Path, ws: &Path, name: &str) -> Result<()>
fn remove_workspace(&self, repo: &Path, ws: &Path, name: &str) -> Result<()>
Remove the worktree/workspace and every ref/bookmark add_workspace/update_workspace
pinned for it under name. Callers only ever call this on a workspace is_dirty has
already confirmed is clean - there’s no way to force-remove a dirty one.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".