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

Method show_change_diff

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

290 /// Then we compute a proper diff between the two states, with optional
291 /// word-level highlighting for code review.
292 pub(super) fn show_change_diff(
293 &self,
294 repo: &Repository,
295 change_ref: &str,
296 config: &DiffOutputConfig,
297 ) -> CliResult<()> {
298 // Resolve the change reference (full hash or prefix)
299 let hash = self.resolve_change_ref(repo, change_ref)?;
300
301 // Load the change
302 let change =
303 repo.change_store()
304 .load_change(&hash)
305 .map_err(|_e| CliError::ChangeNotFound {
306 hash: change_ref.to_string(),
307 })?;
308
309 // Git-imported changes carry Git's captured +/- lines in unhashed
310 // metadata. Use that directly for review output before considering
311 // FileOps or the expensive graph reconstruction fallback. Graph-first
312 // imported changes may intentionally have no FileOps yet.
313 if let Some((file_diffs, stats)) = Self::build_git_import_file_diffs(&change) {
314 let (file_diffs, stats) = self.filter_file_diffs(file_diffs, stats);
315 return self.print_change_file_diffs(&change, &hash, config, file_diffs, stats);
316 }
317
318 // Check if change has semantic layer (file_ops)
319 if change.has_file_ops() {
320 // Use the semantic layer for human-readable diff
321 return self.show_change_diff_from_file_ops(repo, &change, &hash, config);
322 }
323
324 // Fallback: compute diff from content (legacy path)
325 self.show_change_diff_computed(repo, &change, &hash, config)
326 }
327
328 /// Show diff using the semantic layer (FileOps).
329 ///

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