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

Function hunk_display_summaries

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

Source from the content-addressed store, hash-verified

906}
907
908pub(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
935fn merge_hunk_symbols(current: &'static str, next: &'static str) -> &'static str {
936 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