Skip to main content

RepoSnapshot

Struct RepoSnapshot 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: bool

Whether the working copy has any uncommitted change (tracked or untracked).

§change_count: usize

Number of changed paths (tracked + untracked on git; the @ change’s files on jj).

§conflicted: bool

Whether the working copy has an unresolved conflict.

§operation: OperationState

In-progress operation / conflict state (see OperationState).

Implementations§

Source§

impl RepoSnapshot

Source

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

Source

pub fn head(self, head: impl Into<String>) -> Self

Set the working-copy commit’s object id.

Source

pub fn branch(self, branch: impl Into<String>) -> Self

Set the current branch (git) / bookmark (jj).

Source

pub fn tracking(self, tracking: UpstreamTracking) -> Self

Set the upstream tracking (see UpstreamTracking).

Source

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.

Source

pub fn conflicted(self) -> Self

Mark the working copy as having an unresolved conflict.

Source

pub fn operation(self, operation: OperationState) -> Self

Set the in-progress operation / conflict state.

Trait Implementations§

Source§

impl Clone for RepoSnapshot

Source§

fn clone(&self) -> RepoSnapshot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RepoSnapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RepoSnapshot

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for RepoSnapshot

Source§

impl PartialEq for RepoSnapshot

Source§

fn eq(&self, other: &RepoSnapshot) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for RepoSnapshot

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RepoSnapshot

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more