pub trait Vcs: Send {
Show 44 methods
// Required methods
fn git_dir(&self) -> Result<PathBuf, VcsError>;
fn head(&self) -> Result<HeadInfo, VcsError>;
fn has_index(&self) -> bool;
fn status(&self) -> Result<StatusModel, VcsError>;
fn working_tree_diff(&self) -> Result<DiffModel, VcsError>;
fn tree_to_workdir_diff(
&self,
base_oid: &str,
) -> Result<DiffModel, VcsError>;
fn commit_diff(&self, oid: &str) -> Result<DiffModel, VcsError>;
fn range_diff(
&self,
oldest_oid: &str,
newest_oid: &str,
) -> Result<DiffModel, VcsError>;
fn tree_diff(
&self,
base_oid: &str,
newest_oid: &str,
) -> Result<DiffModel, VcsError>;
fn merge_base(&self, a: &str, b: &str) -> Result<String, VcsError>;
fn resolve(&self, revision: &str) -> Result<String, VcsError>;
fn log(&self, limit: usize) -> Result<Vec<LogEntry>, VcsError>;
fn default_branch(&self, remote: &str) -> Result<Option<String>, VcsError>;
fn commits_between(
&self,
base: &str,
head: &str,
) -> Result<Vec<LogEntry>, VcsError>;
fn unpushed(&self, limit: usize) -> Result<Option<Vec<LogEntry>>, VcsError>;
fn blame(&self, rel: &Path) -> Result<Vec<BlameSpan>, VcsError>;
fn read_at(&self, rev: &str, path: &str) -> Result<Option<String>, VcsError>;
fn read_blob(&self, oid: &str) -> Result<Option<Vec<u8>>, VcsError>;
fn tracked_files(&self) -> Result<Vec<PathBuf>, VcsError>;
fn attr(&self, rel: &Path, name: &str) -> bool;
fn branches(&self) -> Result<Vec<BranchInfo>, VcsError>;
fn divergence(
&self,
branch: &str,
) -> Result<Option<(usize, usize)>, VcsError>;
fn all_branches(&self) -> Result<Vec<String>, VcsError>;
fn stage(&self, rel: &Path) -> Result<(), VcsError>;
fn stage_everything(&self) -> Result<(), VcsError>;
fn unstage_everything(&self) -> Result<(), VcsError>;
fn stage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>;
fn unstage(&self, rel: &Path) -> Result<(), VcsError>;
fn unstage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>;
fn discard(&self, rel: &Path) -> Result<(), VcsError>;
fn commit(&self, message: &str) -> Result<String, VcsError>;
fn head_message(&self) -> Result<String, VcsError>;
fn amend(
&self,
message: Option<&str>,
use_index: bool,
) -> Result<String, VcsError>;
fn create_branch(&self, name: &str, checkout: bool) -> Result<(), VcsError>;
fn delete_branch(&self, name: &str) -> Result<(), VcsError>;
fn checkout(&self, name: &str) -> Result<(), VcsError>;
fn native_git_checkout(&self) -> bool;
fn stash_push(&self, message: Option<&str>) -> Result<(), VcsError>;
fn stash_pop(&self) -> Result<(), VcsError>;
fn network_argv(&self, op: NetworkOp) -> Result<Vec<String>, VcsError>;
fn workdir(&self) -> Result<PathBuf, VcsError>;
fn remote_url(&self, name: &str) -> Result<Option<String>, VcsError>;
fn remotes(&self) -> Result<Vec<String>, VcsError>;
fn set_diff_algorithm(
&self,
algorithm: DiffAlgorithm,
indent_heuristic: bool,
);
}Required Methods§
Sourcefn git_dir(&self) -> Result<PathBuf, VcsError>
fn git_dir(&self) -> Result<PathBuf, VcsError>
Resolved metadata directory. In a linked worktree this is the gitdir
the .git file points at.
fn head(&self) -> Result<HeadInfo, VcsError>
Sourcefn has_index(&self) -> bool
fn has_index(&self) -> bool
Whether this backend has a staging area. jj has none, so its whole
working copy reads as StatusModel::staged.
fn status(&self) -> Result<StatusModel, VcsError>
Sourcefn working_tree_diff(&self) -> Result<DiffModel, VcsError>
fn working_tree_diff(&self) -> Result<DiffModel, VcsError>
HEAD vs index + worktree, untracked files included.
Sourcefn tree_to_workdir_diff(&self, base_oid: &str) -> Result<DiffModel, VcsError>
fn tree_to_workdir_diff(&self, base_oid: &str) -> Result<DiffModel, VcsError>
Vcs::working_tree_diff taken from base_oid.
Sourcefn commit_diff(&self, oid: &str) -> Result<DiffModel, VcsError>
fn commit_diff(&self, oid: &str) -> Result<DiffModel, VcsError>
Changes a single commit introduced over its first parent.
Sourcefn range_diff(
&self,
oldest_oid: &str,
newest_oid: &str,
) -> Result<DiffModel, VcsError>
fn range_diff( &self, oldest_oid: &str, newest_oid: &str, ) -> Result<DiffModel, VcsError>
git diff <oldest>^..<newest>. A root oldest diffs from the empty
tree.
Sourcefn tree_diff(
&self,
base_oid: &str,
newest_oid: &str,
) -> Result<DiffModel, VcsError>
fn tree_diff( &self, base_oid: &str, newest_oid: &str, ) -> Result<DiffModel, VcsError>
git diff <base> <newest>; with base a merge base this is a
three-dot diff.
fn merge_base(&self, a: &str, b: &str) -> Result<String, VcsError>
Sourcefn resolve(&self, revision: &str) -> Result<String, VcsError>
fn resolve(&self, revision: &str) -> Result<String, VcsError>
Resolve a revision (oid, ref name, remote ref) to a full commit oid.
Sourcefn log(&self, limit: usize) -> Result<Vec<LogEntry>, VcsError>
fn log(&self, limit: usize) -> Result<Vec<LogEntry>, VcsError>
History from HEAD, newest first.
Sourcefn default_branch(&self, remote: &str) -> Result<Option<String>, VcsError>
fn default_branch(&self, remote: &str) -> Result<Option<String>, VcsError>
The branch a pull request merges into by default, if the repo says.
Sourcefn commits_between(
&self,
base: &str,
head: &str,
) -> Result<Vec<LogEntry>, VcsError>
fn commits_between( &self, base: &str, head: &str, ) -> Result<Vec<LogEntry>, VcsError>
Commits reachable from head but not base, newest first.
Sourcefn unpushed(&self, limit: usize) -> Result<Option<Vec<LogEntry>>, VcsError>
fn unpushed(&self, limit: usize) -> Result<Option<Vec<LogEntry>>, VcsError>
Commits on HEAD that no remote-tracking branch contains, newest first,
at most limit. None when the repo has no remote-tracking refs. We
ask the remotes since a configured upstream may be a local branch or a
stale ref.
Sourcefn blame(&self, rel: &Path) -> Result<Vec<BlameSpan>, VcsError>
fn blame(&self, rel: &Path) -> Result<Vec<BlameSpan>, VcsError>
Last commit to touch each line of rel as the worktree has it, in line
order. Uncommitted lines come back as spans owned by no commit.
Sourcefn read_at(&self, rev: &str, path: &str) -> Result<Option<String>, VcsError>
fn read_at(&self, rev: &str, path: &str) -> Result<Option<String>, VcsError>
One file’s content in rev’s tree, None when the tree lacks it.
Sourcefn read_blob(&self, oid: &str) -> Result<Option<Vec<u8>>, VcsError>
fn read_blob(&self, oid: &str) -> Result<Option<Vec<u8>>, VcsError>
A blob’s raw bytes by its hex id (a crate::model::BlobIds side),
None when the object store has no such blob.
Sourcefn tracked_files(&self) -> Result<Vec<PathBuf>, VcsError>
fn tracked_files(&self) -> Result<Vec<PathBuf>, VcsError>
Every tracked file, repo-relative and sorted. This is the index, so a staged new file is tracked and an untracked one is not.
Sourcefn attr(&self, rel: &Path, name: &str) -> bool
fn attr(&self, rel: &Path, name: &str) -> bool
Whether the repo’s git attributes set name to true for rel.
Unreadable attribute files read as unset.
Sourcefn branches(&self) -> Result<Vec<BranchInfo>, VcsError>
fn branches(&self) -> Result<Vec<BranchInfo>, VcsError>
Local branches, their divergence left unresolved.
Sourcefn divergence(&self, branch: &str) -> Result<Option<(usize, usize)>, VcsError>
fn divergence(&self, branch: &str) -> Result<Option<(usize, usize)>, VcsError>
(ahead, behind) against the upstream, None when branch tracks
nothing.
Sourcefn all_branches(&self) -> Result<Vec<String>, VcsError>
fn all_branches(&self) -> Result<Vec<String>, VcsError>
Local and remote-tracking branch names.
Sourcefn stage(&self, rel: &Path) -> Result<(), VcsError>
fn stage(&self, rel: &Path) -> Result<(), VcsError>
Stage a whole file (worktree deletions become staged deletions).
Sourcefn stage_everything(&self) -> Result<(), VcsError>
fn stage_everything(&self) -> Result<(), VcsError>
Stage every change in the worktree, deletions and untracked files included.
Sourcefn unstage_everything(&self) -> Result<(), VcsError>
fn unstage_everything(&self) -> Result<(), VcsError>
Reset the whole index back to HEAD, keeping the worktree.
Sourcefn stage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>
fn stage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>
Stage one hunk out of the unstaged (or untracked) changes of a file.
Sourcefn unstage(&self, rel: &Path) -> Result<(), VcsError>
fn unstage(&self, rel: &Path) -> Result<(), VcsError>
Reset a file’s index entry back to HEAD, keeping the worktree.
Sourcefn unstage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>
fn unstage_hunk(&self, rel: &Path, hunk: &HunkId) -> Result<(), VcsError>
Remove one staged hunk from the index, keeping the worktree.
Sourcefn discard(&self, rel: &Path) -> Result<(), VcsError>
fn discard(&self, rel: &Path) -> Result<(), VcsError>
Throw away worktree changes only; an untracked file is deleted. Refused while the file has staged changes (unstage first).
Sourcefn commit(&self, message: &str) -> Result<String, VcsError>
fn commit(&self, message: &str) -> Result<String, VcsError>
Commit the index; returns the new commit id.
Sourcefn head_message(&self) -> Result<String, VcsError>
fn head_message(&self) -> Result<String, VcsError>
Full message of the HEAD commit, for amend/reword editor templates.
Sourcefn amend(
&self,
message: Option<&str>,
use_index: bool,
) -> Result<String, VcsError>
fn amend( &self, message: Option<&str>, use_index: bool, ) -> Result<String, VcsError>
Amend HEAD, returning the new commit id. message None reuses HEAD’s
message (extend); Some rewords it. use_index true folds the staged
index into the new tree; false keeps HEAD’s tree (a pure reword).
fn create_branch(&self, name: &str, checkout: bool) -> Result<(), VcsError>
Sourcefn delete_branch(&self, name: &str) -> Result<(), VcsError>
fn delete_branch(&self, name: &str) -> Result<(), VcsError>
Refused for the currently checked-out branch.
fn checkout(&self, name: &str) -> Result<(), VcsError>
Sourcefn native_git_checkout(&self) -> bool
fn native_git_checkout(&self) -> bool
Whether a raw git/forge CLI command may check out a branch. False for
jj, whose operation log would miss the write, so we go through
Vcs::checkout there.
Sourcefn stash_push(&self, message: Option<&str>) -> Result<(), VcsError>
fn stash_push(&self, message: Option<&str>) -> Result<(), VcsError>
Stash tracked changes, leaving untracked files in place like
git stash. message None lets the backend label it.
Sourcefn stash_pop(&self) -> Result<(), VcsError>
fn stash_pop(&self) -> Result<(), VcsError>
Restore the most recent stash and drop it. Refused when there is no stash or the pop would conflict.
Sourcefn network_argv(&self, op: NetworkOp) -> Result<Vec<String>, VcsError>
fn network_argv(&self, op: NetworkOp) -> Result<Vec<String>, VcsError>
Argv for a network op, run in Vcs::workdir so the backend’s own CLI
handles credentials. jj rejects push and pull, since they would move
git’s refs behind its back.
fn workdir(&self) -> Result<PathBuf, VcsError>
fn remote_url(&self, name: &str) -> Result<Option<String>, VcsError>
fn remotes(&self) -> Result<Vec<String>, VcsError>
Sourcefn set_diff_algorithm(&self, algorithm: DiffAlgorithm, indent_heuristic: bool)
fn set_diff_algorithm(&self, algorithm: DiffAlgorithm, indent_heuristic: bool)
Set the line-diff algorithm for every later diff of this instance.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".