MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / hunk_display_summaries

Function hunk_display_summaries

atomic-cli/src/commands/change/command.rs:864–889  ·  view source on GitHub ↗
(hunks: &[GraphOp<H>])

Source from the content-addressed store, hash-verified

862}
863
864pub(crate) fn hunk_display_summaries<H>(hunks: &[GraphOp<H>]) -> Vec<HunkDisplaySummary> {
865 let mut by_path: std::collections::BTreeMap<String, HunkDisplayAggregate> =
866 std::collections::BTreeMap::new();
867
868 for graph_op in hunks {
869 let (symbol, path) = hunk_symbol_and_path(graph_op);
870 let info = hunk_atom_info(graph_op);
871 let aggregate = by_path.entry(path).or_insert_with(|| HunkDisplayAggregate {
872 symbol,
873 total: 0,
874 infos: std::collections::BTreeMap::new(),
875 });
876 aggregate.symbol = merge_hunk_symbols(aggregate.symbol, symbol);
877 aggregate.total += 1;
878 *aggregate.infos.entry(info).or_insert(0) += 1;
879 }
880
881 by_path
882 .into_iter()
883 .map(|(path, aggregate)| HunkDisplaySummary {
884 symbol: aggregate.symbol,
885 path,
886 info: format_hunk_aggregate_info(aggregate.total, &aggregate.infos),
887 })
888 .collect()
889}
890
891fn merge_hunk_symbols(current: &'static str, next: &'static str) -> &'static str {
892 if current == next {

Calls 5

hunk_symbol_and_pathFunction · 0.85
hunk_atom_infoFunction · 0.85
merge_hunk_symbolsFunction · 0.85
into_iterMethod · 0.45