| 4167 | } |
| 4168 | |
| 4169 | fn slow_import_record_summary(parsed: &ParsedCommit, recorded_files: &[RecordedFile]) -> String { |
| 4170 | let mut added = 0usize; |
| 4171 | let mut modified = 0usize; |
| 4172 | let mut deleted = 0usize; |
| 4173 | let mut renamed = 0usize; |
| 4174 | let mut copied = 0usize; |
| 4175 | let mut bytes = 0usize; |
| 4176 | |
| 4177 | for file in &parsed.files { |
| 4178 | match file.operation { |
| 4179 | FileOperation::Added => added += 1, |
| 4180 | FileOperation::Modified => modified += 1, |
| 4181 | FileOperation::Deleted => deleted += 1, |
| 4182 | FileOperation::Renamed => renamed += 1, |
| 4183 | FileOperation::Copied => copied += 1, |
| 4184 | } |
| 4185 | bytes += file.new_content.as_ref().map(|c| c.len()).unwrap_or(0); |
| 4186 | bytes += file.old_content.as_ref().map(|c| c.len()).unwrap_or(0); |
| 4187 | } |
| 4188 | |
| 4189 | let mut largest: Vec<(&str, usize)> = recorded_files |
| 4190 | .iter() |
| 4191 | .map(|rec| (rec.path(), rec.content().len())) |
| 4192 | .collect(); |
| 4193 | largest.sort_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(b.0))); |
| 4194 | let top_paths = largest |
| 4195 | .into_iter() |
| 4196 | .take(3) |
| 4197 | .map(|(path, size)| format!("{} ({})", path, format_byte_count(size))) |
| 4198 | .collect::<Vec<_>>(); |
| 4199 | |
| 4200 | let top = if top_paths.is_empty() { |
| 4201 | "top records: none".to_string() |
| 4202 | } else { |
| 4203 | format!("top records: {}", top_paths.join(", ")) |
| 4204 | }; |
| 4205 | |
| 4206 | format!( |
| 4207 | "records={}, files={}, bytes={}, ops=+{}/~{}/-{} renames={} copies={}; {}", |
| 4208 | recorded_files.len(), |
| 4209 | parsed.files.len(), |
| 4210 | format_byte_count(bytes), |
| 4211 | added, |
| 4212 | modified, |
| 4213 | deleted, |
| 4214 | renamed, |
| 4215 | copied, |
| 4216 | top |
| 4217 | ) |
| 4218 | } |
| 4219 | |
| 4220 | impl ParallelImporter { |
| 4221 | /// Create a new parallel importer. |