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

Method format_outcome

atomic-cli/src/commands/record/format.rs:5–76  ·  view source on GitHub ↗

Format the outcome for display.

(&self, repo: &Repository, outcome: &RecordOutcome)

Source from the content-addressed store, hash-verified

3impl Record {
4 /// Format the outcome for display.
5 pub(super) fn format_outcome(&self, repo: &Repository, outcome: &RecordOutcome) -> String {
6 let mut output = String::new();
7
8 // Get the actual current view name from the repository
9 let view_name = repo.current_view();
10
11 // Get hash (shortened)
12 let hash_short = &outcome.hash().to_base32()[..DEFAULT_HASH_LENGTH.min(8)];
13
14 // Get message (first line only)
15 let message = outcome
16 .change()
17 .hashed
18 .header
19 .message
20 .lines()
21 .next()
22 .unwrap_or("No message");
23
24 // Header line: [view seq/hash] message
25 let sequence = outcome.new_state().map(|_| "1").unwrap_or("?");
26 output.push_str(&format!(
27 "[{} {}/{}] {}\n",
28 view_name, sequence, hash_short, message
29 ));
30
31 // Stats line - show graph-based stats
32 let stats = outcome.stats();
33 if stats.has_changes() {
34 output.push_str(&format!(
35 " {} changed, +{} vertices, ~{} edges, {} bytes\n",
36 format_count(stats.files_recorded, "file"),
37 stats.vertices_added,
38 stats.edges_modified,
39 stats.content_bytes
40 ));
41
42 // CRDT token-level statistics (for fine-grained diff tracking)
43 if stats.has_crdt_stats() {
44 // Line-level changes
45 let line_changes = stats.total_line_changes();
46 if line_changes > 0 {
47 output.push_str(&format!(
48 " {} (+{} -{} ~{})\n",
49 format_count(line_changes, "line"),
50 stats.lines_added,
51 stats.lines_deleted,
52 stats.lines_modified
53 ));
54 }
55
56 // Token-level changes
57 let token_ops = stats.total_token_ops();
58 if token_ops > 0 {
59 output.push_str(&format!(
60 " {} (+{} -{} ~{})\n",
61 format_count(token_ops, "token"),
62 stats.tokens_added,

Callers 1

runMethod · 0.80

Calls 13

current_viewMethod · 0.80
new_stateMethod · 0.80
has_crdt_statsMethod · 0.80
recorded_filesMethod · 0.80
to_base32Method · 0.45
hashMethod · 0.45
nextMethod · 0.45
linesMethod · 0.45
changeMethod · 0.45
statsMethod · 0.45
has_changesMethod · 0.45
total_line_changesMethod · 0.45

Tested by

no test coverage detected