Skip to main content

Review

Struct Review 

Source
pub struct Review {
    pub repo_root: PathBuf,
    pub vcs: Box<dyn Vcs>,
    pub status: StatusModel,
    pub session: Session,
    /* private fields */
}

Fields§

§repo_root: PathBuf§vcs: Box<dyn Vcs>§status: StatusModel§session: Session

The working-tree review session, the default view.

Implementations§

Source§

impl Review

Source

pub fn open(repo_root: &Path) -> Result<Self, ReviewError>

Open the git backend at DiffSettings::default, load the persisted session (if any), and compute the status sections. The working-tree review diff is deferred until first Review::model access.

Source

pub fn open_with_settings( repo_root: &Path, settings: &DiffSettings, ) -> Result<Self, ReviewError>

Like Review::open with a custom context, line-diff algorithm and indent heuristic (config keys ui.context_lines, diff.algorithm, diff.indent_heuristic).

Source

pub fn set_diff_algorithm( &self, algorithm: DiffAlgorithm, indent_heuristic: bool, )

Switch the session’s line-diff algorithm live, so every diff this review’s own backend computes afterward uses it.

Source

pub fn model(&self) -> &DiffModel

The working-tree review diff, computed and cached on first access. A backend error yields an empty diff rather than panicking; the next Review::refresh gets another chance to compute it.

Source

pub fn model_mut(&mut self) -> &mut DiffModel

Mutable view of the working-tree review diff, computing it first if needed. The TUI uses this to enrich a file with intra-line emphasis just before rendering it.

Source

pub fn refresh(&mut self) -> Result<(), ReviewError>

Recompute status + diff (the watcher calls this on changes) and drop viewed marks for files that changed or left the diff.

Source

pub fn compute_refresh( repo_root: &Path, settings: &DiffSettings, against: Option<&str>, pinned: Option<(&ReviewSource, Option<(&str, &str)>)>, ) -> Result<Refreshed, ReviewError>

Compute a refresh on a separate repo handle, so it can run off the UI thread; the result is applied later with Review::install_refresh. against recomputes the open three-dot review in the same pass, since it tracks edits and cannot be pinned like a commit’s diff. pinned additionally recomputes a commit, range, or PR source’s diff on this same backend (an algorithm switch re-diffing whatever source is open).

Source

pub fn compute_declared( repo_root: &Path, paths: &[String], ) -> Result<HashMap<String, Kind>, ReviewError>

What the repo’s git attributes declare about each of paths, for the kinds sidebar. One attribute lookup walks the directory chain and the global attribute files, so this is real IO per path and belongs on a worker; paths the repo says nothing about are left out.

Source

pub fn compute_walkthrough_files( repo_root: &Path, rev: Option<&str>, read_first: ReadFirst, files: &[String], ) -> WalkthroughFiles

Every requested file’s content, from the copy read_first names and else the other: the walkthrough’s own rev, or the live worktree (the only copy when rev is None, a walkthrough saved before it was tracked). Opens its own backend so it runs on a worker thread like Review::compute_refresh; a path neither the revision nor the worktree can produce is left out rather than failing the whole read. rev itself can also stop resolving (a squash, a rebase, a gc): that is distinct from a path merely absent from a revision that still resolves, so it comes back as pin_broken rather than folding into the same silent worktree fallback.

Source

pub fn compute_binary_sides( repo_root: &Path, path: &str, blobs: &BlobIds, deleted: bool, ) -> BinarySides

Both sides of a binary file as raw bytes, for the image preview: each side from its blob, the new side from the worktree when the store has no blob for it (a working-tree diff). A side over MAX_PREVIEW_BYTES comes back as its size alone, so a huge asset never loads into memory.

Source

pub fn compute_file( repo_root: &Path, rel: &str, ) -> Result<FileSnapshot, ReviewError>

One file’s worktree text and blame, for the file view. Opens its own backend so it runs on a worker thread like Review::compute_refresh. A file git cannot blame (untracked, or newly staged) still loads: it comes back with text and no spans.

Source

pub fn install_refresh(&mut self, status: StatusModel, model: DiffModel)

Swap in freshly computed status + diff and reconcile viewed marks.

Source

pub fn save(&self) -> Result<(), ReviewError>

Source

pub fn ensure_source( &mut self, source: &ReviewSource, ) -> Result<(), ReviewError>

Load a non-working source’s session into the cache if not already there. Call before reading via Review::session_for for that source.

Source

pub fn session_for(&self, source: &ReviewSource) -> &Session

The session for a source. The working tree is always present; other sources must be Review::ensure_sourced first, else an empty session is returned.

Source

pub fn session_for_mut(&mut self, source: &ReviewSource) -> &mut Session

Source

pub fn save_for(&self, source: &ReviewSource) -> Result<(), ReviewError>

Source

pub fn forget_source(&mut self, source: &ReviewSource)

Forget a non-working source’s cached session, after its file is deleted from disk (e.g. a walkthrough removed for good), so a later access reloads default state rather than serving stale memory.

Source

pub fn all_reviews(&self) -> Result<Vec<(ReviewSource, Session)>, ReviewError>

Every review across all sources, in-memory state overriding disk, sorted by source key. Powers the agent-facing aggregate feed. A review file that fails to parse is skipped rather than failing the whole call; see Review::all_reviews_and_corrupt for the list of what was skipped.

Source

pub fn all_reviews_and_corrupt(&self) -> Result<LoadedReviews, ReviewError>

Review::all_reviews plus the path of every review file that failed to parse and was skipped, for a caller that wants to tell the reader.

Source

pub fn restore_model(&mut self, model: DiffModel)

Swap a previously computed model back in. Used when a refresh proved a no-op (same fingerprint): the old model carries render-time emphasis the rebuilt one lacks.

Auto Trait Implementations§

§

impl !Freeze for Review

§

impl !RefUnwindSafe for Review

§

impl !Sync for Review

§

impl !UnwindSafe for Review

§

impl Send for Review

§

impl Unpin for Review

§

impl UnsafeUnpin for Review

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.