#[non_exhaustive]pub struct RepoSnapshot {
pub head: Option<String>,
pub branch: Option<String>,
pub tracking: Option<UpstreamTracking>,
pub dirty: bool,
pub change_count: usize,
pub conflicted: bool,
pub operation: OperationState,
}Expand description
A one-shot snapshot of the common repository state — branch, upstream
tracking, ahead/behind, dirtiness, and operation state — gathered in a
small fixed number of process spawns instead of a call per field. The
data a prompt, status line, or TUI refresh needs. See
Repo::snapshot.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.head: Option<String>The working-copy commit’s full object id (git HEAD oid / jj @
commit id) on both backends; None on an unborn git repo. Truncate for
display.
branch: Option<String>Current branch (git) / bookmark (jj). On jj this is the nearest bookmark
reachable from @ (heads(::@ & bookmarks())), so it stays set across a
jj describe/jj new/jj commit; None when detached / no bookmark on
or above @. Matches Repo::current_branch
by construction.
tracking: Option<UpstreamTracking>Upstream tracking and how far the branch is ahead/behind it, as one unit —
Some only when an upstream is configured, None otherwise (and always
None on jj, which has no git-style upstream tracking). Bundling the
three together makes the “all-or-nothing” relationship unrepresentable as a
half-populated state. See UpstreamTracking.
dirty: boolWhether the working copy has any uncommitted change (tracked or untracked).
change_count: usizeNumber of changed paths (tracked + untracked on git; the @ change’s
files on jj).
conflicted: boolWhether the working copy has an unresolved conflict.
operation: OperationStateIn-progress operation / conflict state (see OperationState).
Implementations§
Source§impl RepoSnapshot
impl RepoSnapshot
Sourcepub fn new() -> Self
pub fn new() -> Self
A clean snapshot: detached (no head/branch), no upstream tracking, not
dirty or conflicted, change count 0, OperationState::Clear. Chain the
setters to fill it — for a test double or a custom VcsRepo backend that must
return a RepoSnapshot (the struct is #[non_exhaustive], so it can’t be
built with a literal outside this crate).
Sourcepub fn branch(self, branch: impl Into<String>) -> Self
pub fn branch(self, branch: impl Into<String>) -> Self
Set the current branch (git) / bookmark (jj).
Sourcepub fn tracking(self, tracking: UpstreamTracking) -> Self
pub fn tracking(self, tracking: UpstreamTracking) -> Self
Set the upstream tracking (see UpstreamTracking).
Sourcepub fn dirty(self, change_count: usize) -> Self
pub fn dirty(self, change_count: usize) -> Self
Mark the working copy dirty and record how many paths changed (a real snapshot
has change_count >= 1 when dirty — the two fields move together, so this
setter couples them). A clean copy is the new default.
Sourcepub fn conflicted(self) -> Self
pub fn conflicted(self) -> Self
Mark the working copy as having an unresolved conflict.
Sourcepub fn operation(self, operation: OperationState) -> Self
pub fn operation(self, operation: OperationState) -> Self
Set the in-progress operation / conflict state.
Trait Implementations§
Source§impl Clone for RepoSnapshot
impl Clone for RepoSnapshot
Source§fn clone(&self) -> RepoSnapshot
fn clone(&self) -> RepoSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RepoSnapshot
impl Debug for RepoSnapshot
Source§impl Default for RepoSnapshot
impl Default for RepoSnapshot
impl Eq for RepoSnapshot
Source§impl PartialEq for RepoSnapshot
impl PartialEq for RepoSnapshot
Source§fn eq(&self, other: &RepoSnapshot) -> bool
fn eq(&self, other: &RepoSnapshot) -> bool
self and other values to be equal, and is used by ==.