| 2148 | } |
| 2149 | |
| 2150 | fn slow_import_record_summary(parsed: &ParsedCommit, recorded_files: &[RecordedFile]) -> String { |
| 2151 | let mut added = 0usize; |
| 2152 | let mut modified = 0usize; |
| 2153 | let mut deleted = 0usize; |
| 2154 | let mut renamed = 0usize; |
| 2155 | let mut copied = 0usize; |
| 2156 | let mut bytes = 0usize; |
| 2157 | |
| 2158 | for file in &parsed.files { |
| 2159 | match file.operation { |
| 2160 | FileOperation::Added => added += 1, |
| 2161 | FileOperation::Modified => modified += 1, |
| 2162 | FileOperation::Deleted => deleted += 1, |
| 2163 | FileOperation::Renamed => renamed += 1, |
| 2164 | FileOperation::Copied => copied += 1, |
| 2165 | } |
| 2166 | bytes += file.new_content.as_ref().map(|c| c.len()).unwrap_or(0); |
| 2167 | bytes += file.old_content.as_ref().map(|c| c.len()).unwrap_or(0); |
| 2168 | } |
| 2169 | |
| 2170 | let mut largest: Vec<(&str, usize)> = recorded_files |
| 2171 | .iter() |
| 2172 | .map(|rec| (rec.path(), rec.content().len())) |
| 2173 | .collect(); |
| 2174 | largest.sort_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(b.0))); |
| 2175 | let top_paths = largest |
| 2176 | .into_iter() |
| 2177 | .take(3) |
| 2178 | .map(|(path, size)| format!("{} ({})", path, format_byte_count(size))) |
| 2179 | .collect::<Vec<_>>(); |
| 2180 | |
| 2181 | let top = if top_paths.is_empty() { |
| 2182 | "top records: none".to_string() |
| 2183 | } else { |
| 2184 | format!("top records: {}", top_paths.join(", ")) |
| 2185 | }; |
| 2186 | |
| 2187 | format!( |
| 2188 | "records={}, files={}, bytes={}, ops=+{}/~{}/-{} renames={} copies={}; {}", |
| 2189 | recorded_files.len(), |
| 2190 | parsed.files.len(), |
| 2191 | format_byte_count(bytes), |
| 2192 | added, |
| 2193 | modified, |
| 2194 | deleted, |
| 2195 | renamed, |
| 2196 | copied, |
| 2197 | top |
| 2198 | ) |
| 2199 | } |
| 2200 | |
| 2201 | impl ParallelImporter { |
| 2202 | /// Create a new parallel importer. |