Skip to main content

Vcs

Trait Vcs 

Source
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§

Source

fn ensure_commit(&self, repo: &Path, refspec_or_sha: &str) -> Result<()>

Fetch refspec_or_sha into the canonical repo if not already present.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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".

Implementors§