Format the outcome for display.
(&self, view_name: &str, outcome: &RecordOutcome)
| 3 | impl Record { |
| 4 | /// Format the outcome for display. |
| 5 | pub(super) fn format_outcome(&self, view_name: &str, outcome: &RecordOutcome) -> String { |
| 6 | let mut output = String::new(); |
| 7 | |
| 8 | // A scoped stale-conflict cleanup records no content change; report it |
| 9 | // as such instead of a zero-file change summary. |
| 10 | if let Some(cleanup) = outcome.conflict_cleanup() { |
| 11 | return format_conflict_cleanup( |
| 12 | &cleanup.view, |
| 13 | &cleanup.paths, |
| 14 | cleanup.rows_cleared, |
| 15 | cleanup.operation, |
| 16 | ); |
| 17 | } |
| 18 | |
| 19 | // Get hash (shortened) |
| 20 | let hash_short = &outcome.hash().to_base32()[..DEFAULT_HASH_LENGTH.min(8)]; |
| 21 | |
| 22 | // Get message (first line only) |
| 23 | let message = outcome |
| 24 | .change() |
| 25 | .hashed |
| 26 | .header |
| 27 | .message |
| 28 | .lines() |
| 29 | .next() |
| 30 | .unwrap_or("No message"); |
| 31 | |
| 32 | // Header line: [view seq/hash] message |
| 33 | let sequence = outcome.new_state().map(|_| "1").unwrap_or("?"); |
| 34 | output.push_str(&format!( |
| 35 | "[{} {}/{}] {}\n", |
| 36 | view_name, sequence, hash_short, message |
| 37 | )); |
| 38 | |
| 39 | output.push_str(&format_record_stats(outcome.stats())); |
| 40 | |
| 41 | if let Ok(Some(evidence)) = outcome.move_evidence() { |
| 42 | for moved in evidence.authoritative_moves { |
| 43 | let authority = match moved.authority { |
| 44 | atomic_repository::MoveAuthority::ExplicitAtomicMove => "explicit atomic move", |
| 45 | atomic_repository::MoveAuthority::StableInodeProjection => { |
| 46 | "stable inode projection" |
| 47 | } |
| 48 | }; |
| 49 | output.push_str(&format!( |
| 50 | " move: {} → {} ({})\n", |
| 51 | moved.old_path, moved.new_path, authority |
| 52 | )); |
| 53 | } |
| 54 | for moved in evidence.probable_moves { |
| 55 | let basis = match moved.basis { |
| 56 | atomic_repository::MoveBasis::ByteIdentity => "byte identity", |
| 57 | atomic_repository::MoveBasis::ContentSimilarity => "content similarity", |
| 58 | }; |
| 59 | output.push_str(&format!( |
| 60 | " probable move: {} → {} ({}.{:02}%, {})\n", |
| 61 | moved.old_path, |
| 62 | moved.new_path, |
no test coverage detected