| 2035 | } |
| 2036 | |
| 2037 | fn slow_import_record_summary(parsed: &ParsedCommit, recorded_files: &[RecordedFile]) -> String { |
| 2038 | let mut added = 0usize; |
| 2039 | let mut modified = 0usize; |
| 2040 | let mut deleted = 0usize; |
| 2041 | let mut renamed = 0usize; |
| 2042 | let mut copied = 0usize; |
| 2043 | let mut bytes = 0usize; |
| 2044 | |
| 2045 | for file in &parsed.files { |
| 2046 | match file.operation { |
| 2047 | FileOperation::Added => added += 1, |
| 2048 | FileOperation::Modified => modified += 1, |
| 2049 | FileOperation::Deleted => deleted += 1, |
| 2050 | FileOperation::Renamed => renamed += 1, |
| 2051 | FileOperation::Copied => copied += 1, |
| 2052 | } |
| 2053 | bytes += file.new_content.as_ref().map(|c| c.len()).unwrap_or(0); |
| 2054 | bytes += file.old_content.as_ref().map(|c| c.len()).unwrap_or(0); |
| 2055 | } |
| 2056 | |
| 2057 | let mut largest: Vec<(&str, usize)> = recorded_files |
| 2058 | .iter() |
| 2059 | .map(|rec| (rec.path(), rec.content().len())) |
| 2060 | .collect(); |
| 2061 | largest.sort_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(b.0))); |
| 2062 | let top_paths = largest |
| 2063 | .into_iter() |
| 2064 | .take(3) |
| 2065 | .map(|(path, size)| format!("{} ({})", path, format_byte_count(size))) |
| 2066 | .collect::<Vec<_>>(); |
| 2067 | |
| 2068 | let top = if top_paths.is_empty() { |
| 2069 | "top records: none".to_string() |
| 2070 | } else { |
| 2071 | format!("top records: {}", top_paths.join(", ")) |
| 2072 | }; |
| 2073 | |
| 2074 | format!( |
| 2075 | "records={}, files={}, bytes={}, ops=+{}/~{}/-{} renames={} copies={}; {}", |
| 2076 | recorded_files.len(), |
| 2077 | parsed.files.len(), |
| 2078 | format_byte_count(bytes), |
| 2079 | added, |
| 2080 | modified, |
| 2081 | deleted, |
| 2082 | renamed, |
| 2083 | copied, |
| 2084 | top |
| 2085 | ) |
| 2086 | } |
| 2087 | |
| 2088 | impl ParallelImporter { |
| 2089 | /// Create a new parallel importer. |