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

Method show_change_diff

atomic-cli/src/commands/diff/helpers.rs:400–434  ·  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

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

Callers 1

runMethod · 0.80

Calls 8

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