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

Method show_change_diff

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

31 /// Then we compute a proper diff between the two states, with optional
32 /// word-level highlighting for code review.
33 pub(super) fn show_change_diff(
34 &self,
35 repo: &Repository,
36 change_ref: &str,
37 config: &DiffOutputConfig,
38 ) -> CliResult<()> {
39 // Resolve the change reference (full hash or prefix)
40 let hash = self.resolve_change_ref(repo, change_ref)?;
41
42 // Load the change
43 let change =
44 repo.change_store()
45 .load_change(&hash)
46 .map_err(|_e| CliError::ChangeNotFound {
47 hash: change_ref.to_string(),
48 })?;
49
50 // Git-imported changes carry Git's captured +/- lines in unhashed
51 // metadata. Use that directly for review output before considering
52 // FileOps or the expensive graph reconstruction fallback. Graph-first
53 // imported changes may intentionally have no FileOps yet.
54 if let Some((file_diffs, stats)) = Self::build_git_import_file_diffs(&change) {
55 return self.print_change_file_diffs(&change, &hash, config, file_diffs, stats);
56 }
57
58 // Check if change has semantic layer (file_ops)
59 if change.has_file_ops() {
60 // Use the semantic layer for human-readable diff
61 return self.show_change_diff_from_file_ops(&change, &hash, config);
62 }
63
64 // Fallback: compute diff from content (legacy path)
65 self.show_change_diff_computed(repo, &change, &hash, config)
66 }
67
68 /// Show diff using the semantic layer (FileOps).
69 ///

Callers 1

runMethod · 0.80

Calls 7

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

Tested by

no test coverage detected