| 906 | } |
| 907 | |
| 908 | pub(crate) fn hunk_display_summaries<H>(hunks: &[GraphOp<H>]) -> Vec<HunkDisplaySummary> { |
| 909 | let mut by_path: std::collections::BTreeMap<String, HunkDisplayAggregate> = |
| 910 | std::collections::BTreeMap::new(); |
| 911 | |
| 912 | for graph_op in hunks { |
| 913 | let (symbol, path) = hunk_symbol_and_path(graph_op); |
| 914 | let info = hunk_atom_info(graph_op); |
| 915 | let aggregate = by_path.entry(path).or_insert_with(|| HunkDisplayAggregate { |
| 916 | symbol, |
| 917 | total: 0, |
| 918 | infos: std::collections::BTreeMap::new(), |
| 919 | }); |
| 920 | aggregate.symbol = merge_hunk_symbols(aggregate.symbol, symbol); |
| 921 | aggregate.total += 1; |
| 922 | *aggregate.infos.entry(info).or_insert(0) += 1; |
| 923 | } |
| 924 | |
| 925 | by_path |
| 926 | .into_iter() |
| 927 | .map(|(path, aggregate)| HunkDisplaySummary { |
| 928 | symbol: aggregate.symbol, |
| 929 | path, |
| 930 | info: format_hunk_aggregate_info(aggregate.total, &aggregate.infos), |
| 931 | }) |
| 932 | .collect() |
| 933 | } |
| 934 | |
| 935 | fn merge_hunk_symbols(current: &'static str, next: &'static str) -> &'static str { |
| 936 | if current == next { |