| 2104 | } |
| 2105 | |
| 2106 | fn slow_import_record_summary(parsed: &ParsedCommit, recorded_files: &[RecordedFile]) -> String { |
| 2107 | let mut added = 0usize; |
| 2108 | let mut modified = 0usize; |
| 2109 | let mut deleted = 0usize; |
| 2110 | let mut renamed = 0usize; |
| 2111 | let mut copied = 0usize; |
| 2112 | let mut bytes = 0usize; |
| 2113 | |
| 2114 | for file in &parsed.files { |
| 2115 | match file.operation { |
| 2116 | FileOperation::Added => added += 1, |
| 2117 | FileOperation::Modified => modified += 1, |
| 2118 | FileOperation::Deleted => deleted += 1, |
| 2119 | FileOperation::Renamed => renamed += 1, |
| 2120 | FileOperation::Copied => copied += 1, |
| 2121 | } |
| 2122 | bytes += file.new_content.as_ref().map(|c| c.len()).unwrap_or(0); |
| 2123 | bytes += file.old_content.as_ref().map(|c| c.len()).unwrap_or(0); |
| 2124 | } |
| 2125 | |
| 2126 | let mut largest: Vec<(&str, usize)> = recorded_files |
| 2127 | .iter() |
| 2128 | .map(|rec| (rec.path(), rec.content().len())) |
| 2129 | .collect(); |
| 2130 | largest.sort_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(b.0))); |
| 2131 | let top_paths = largest |
| 2132 | .into_iter() |
| 2133 | .take(3) |
| 2134 | .map(|(path, size)| format!("{} ({})", path, format_byte_count(size))) |
| 2135 | .collect::<Vec<_>>(); |
| 2136 | |
| 2137 | let top = if top_paths.is_empty() { |
| 2138 | "top records: none".to_string() |
| 2139 | } else { |
| 2140 | format!("top records: {}", top_paths.join(", ")) |
| 2141 | }; |
| 2142 | |
| 2143 | format!( |
| 2144 | "records={}, files={}, bytes={}, ops=+{}/~{}/-{} renames={} copies={}; {}", |
| 2145 | recorded_files.len(), |
| 2146 | parsed.files.len(), |
| 2147 | format_byte_count(bytes), |
| 2148 | added, |
| 2149 | modified, |
| 2150 | deleted, |
| 2151 | renamed, |
| 2152 | copied, |
| 2153 | top |
| 2154 | ) |
| 2155 | } |
| 2156 | |
| 2157 | impl ParallelImporter { |
| 2158 | /// Create a new parallel importer. |