| 883 | } |
| 884 | |
| 885 | pub(crate) fn hunk_display_summaries<H>(hunks: &[GraphOp<H>]) -> Vec<HunkDisplaySummary> { |
| 886 | let mut by_path: std::collections::BTreeMap<String, HunkDisplayAggregate> = |
| 887 | std::collections::BTreeMap::new(); |
| 888 | |
| 889 | for graph_op in hunks { |
| 890 | let (symbol, path) = hunk_symbol_and_path(graph_op); |
| 891 | let info = hunk_atom_info(graph_op); |
| 892 | let aggregate = by_path.entry(path).or_insert_with(|| HunkDisplayAggregate { |
| 893 | symbol, |
| 894 | total: 0, |
| 895 | infos: std::collections::BTreeMap::new(), |
| 896 | }); |
| 897 | aggregate.symbol = merge_hunk_symbols(aggregate.symbol, symbol); |
| 898 | aggregate.total += 1; |
| 899 | *aggregate.infos.entry(info).or_insert(0) += 1; |
| 900 | } |
| 901 | |
| 902 | by_path |
| 903 | .into_iter() |
| 904 | .map(|(path, aggregate)| HunkDisplaySummary { |
| 905 | symbol: aggregate.symbol, |
| 906 | path, |
| 907 | info: format_hunk_aggregate_info(aggregate.total, &aggregate.infos), |
| 908 | }) |
| 909 | .collect() |
| 910 | } |
| 911 | |
| 912 | fn merge_hunk_symbols(current: &'static str, next: &'static str) -> &'static str { |
| 913 | if current == next { |