Format the outcome for display.
(&self, repo: &Repository, outcome: &RecordOutcome)
| 3 | impl 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, |
no test coverage detected