MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / show_change_diff

Method show_change_diff

atomic-cli/src/commands/diff/helpers.rs:404–438  ·  view source on GitHub ↗

Show the diff for a specific change by hash or prefix. This displays the content introduced by the change using state-based content retrieval. For each file modified by the change, we retrieve: - The file content BEFORE the change was applied (parent state) - The file content AFTER the change was applied (current state) Then we compute a proper diff between the two states, with optional word-lev

(
        &self,
        repo: &Repository,
        change_ref: &str,
        config: &DiffOutputConfig,
    )

Source from the content-addressed store, hash-verified

402 /// Then we compute a proper diff between the two states, with optional
403 /// word-level highlighting for code review.
404 pub(super) fn show_change_diff(
405 &self,
406 repo: &Repository,
407 change_ref: &str,
408 config: &DiffOutputConfig,
409 ) -> CliResult<()> {
410 // Resolve the change reference (full hash or prefix)
411 let hash = self.resolve_change_ref(repo, change_ref)?;
412
413 // Load the change
414 let change =
415 repo.change_store()
416 .load_change(&hash)
417 .map_err(|_e| CliError::ChangeNotFound {
418 hash: change_ref.to_string(),
419 })?;
420
421 // Git-imported changes carry Git's captured +/- lines in unhashed
422 // metadata. Use that directly for review output before considering
423 // FileOps or the expensive graph reconstruction fallback. Graph-first
424 // imported changes may intentionally have no FileOps yet.
425 if let Some((file_diffs, stats)) = Self::build_git_import_file_diffs(&change) {
426 let (file_diffs, stats) = self.filter_file_diffs(file_diffs, stats);
427 return self.print_change_file_diffs(&change, &hash, config, file_diffs, stats);
428 }
429
430 // Check if change has semantic layer (file_ops)
431 if change.has_file_ops() {
432 // Use the semantic layer for human-readable diff
433 return self.show_change_diff_from_file_ops(repo, &change, &hash, config);
434 }
435
436 // Fallback: compute diff from content (legacy path)
437 self.show_change_diff_computed(repo, &change, &hash, config)
438 }
439
440 /// Show diff using the semantic layer (FileOps).
441 ///

Callers 1

runMethod · 0.80

Calls 9

resolve_change_refMethod · 0.80
filter_file_diffsMethod · 0.80
load_changeMethod · 0.45
change_storeMethod · 0.45
has_file_opsMethod · 0.45

Tested by

no test coverage detected