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: SessionThe working-tree review session, the default view.
Implementations§
Source§impl Review
impl Review
Sourcepub fn open(repo_root: &Path) -> Result<Self, ReviewError>
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.
Sourcepub fn open_with_settings(
repo_root: &Path,
settings: &DiffSettings,
) -> Result<Self, ReviewError>
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).
Sourcepub fn set_diff_algorithm(
&self,
algorithm: DiffAlgorithm,
indent_heuristic: bool,
)
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.
Sourcepub fn model(&self) -> &DiffModel
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.
Sourcepub fn model_mut(&mut self) -> &mut DiffModel
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.
Sourcepub fn refresh(&mut self) -> Result<(), ReviewError>
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.
Sourcepub fn compute_refresh(
repo_root: &Path,
settings: &DiffSettings,
against: Option<&str>,
pinned: Option<(&ReviewSource, Option<(&str, &str)>)>,
) -> Result<Refreshed, ReviewError>
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).
Sourcepub fn compute_declared(
repo_root: &Path,
paths: &[String],
) -> Result<HashMap<String, Kind>, ReviewError>
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.
Sourcepub fn compute_walkthrough_files(
repo_root: &Path,
rev: Option<&str>,
read_first: ReadFirst,
files: &[String],
) -> WalkthroughFiles
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.
Sourcepub fn compute_binary_sides(
repo_root: &Path,
path: &str,
blobs: &BlobIds,
deleted: bool,
) -> BinarySides
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.
Sourcepub fn compute_file(
repo_root: &Path,
rel: &str,
) -> Result<FileSnapshot, ReviewError>
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.
Sourcepub fn install_refresh(&mut self, status: StatusModel, model: DiffModel)
pub fn install_refresh(&mut self, status: StatusModel, model: DiffModel)
Swap in freshly computed status + diff and reconcile viewed marks.
pub fn save(&self) -> Result<(), ReviewError>
Sourcepub fn ensure_source(
&mut self,
source: &ReviewSource,
) -> Result<(), ReviewError>
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.
Sourcepub fn session_for(&self, source: &ReviewSource) -> &Session
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.
pub fn session_for_mut(&mut self, source: &ReviewSource) -> &mut Session
pub fn save_for(&self, source: &ReviewSource) -> Result<(), ReviewError>
Sourcepub fn forget_source(&mut self, source: &ReviewSource)
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.
Sourcepub fn all_reviews(&self) -> Result<Vec<(ReviewSource, Session)>, ReviewError>
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.
Sourcepub fn all_reviews_and_corrupt(&self) -> Result<LoadedReviews, ReviewError>
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.
Sourcepub fn restore_model(&mut self, model: DiffModel)
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.