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

Function hunk_display_summaries

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

Source from the content-addressed store, hash-verified

848}
849
850pub(crate) fn hunk_display_summaries<H>(hunks: &[GraphOp<H>]) -> Vec<HunkDisplaySummary> {
851 let mut by_path: std::collections::BTreeMap<String, HunkDisplayAggregate> =
852 std::collections::BTreeMap::new();
853
854 for graph_op in hunks {
855 let (symbol, path) = hunk_symbol_and_path(graph_op);
856 let info = hunk_atom_info(graph_op);
857 let aggregate = by_path.entry(path).or_insert_with(|| HunkDisplayAggregate {
858 symbol,
859 total: 0,
860 infos: std::collections::BTreeMap::new(),
861 });
862 aggregate.symbol = merge_hunk_symbols(aggregate.symbol, symbol);
863 aggregate.total += 1;
864 *aggregate.infos.entry(info).or_insert(0) += 1;
865 }
866
867 by_path
868 .into_iter()
869 .map(|(path, aggregate)| HunkDisplaySummary {
870 symbol: aggregate.symbol,
871 path,
872 info: format_hunk_aggregate_info(aggregate.total, &aggregate.infos),
873 })
874 .collect()
875}
876
877fn merge_hunk_symbols(current: &'static str, next: &'static str) -> &'static str {
878 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