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

Function build_graph_first_change

atomic-cli/src/commands/git/parallel.rs:1201–1878  ·  view source on GitHub ↗
(
    header: ChangeHeader,
    parsed: &ParsedCommit,
    line_index: &ImportLineIndex,
    graph_only: bool,
)

Source from the content-addressed store, hash-verified

1199}
1200
1201fn build_graph_first_change(
1202 header: ChangeHeader,
1203 parsed: &ParsedCommit,
1204 line_index: &ImportLineIndex,
1205 graph_only: bool,
1206) -> Result<(Change, Vec<PendingLineIndexUpdate>, Vec<String>), Vec<GraphFirstSkip>> {
1207 if parsed.files.is_empty() {
1208 return Err(vec![GraphFirstSkip {
1209 path: String::new(),
1210 operation: FileOperation::Modified,
1211 reason: "empty_commit",
1212 }]);
1213 }
1214
1215 let mut contents = Vec::new();
1216 let mut hunks = Vec::new();
1217 let mut file_ops = Vec::new();
1218 let mut next_file_idx = 0u32;
1219 let mut next_branch_idx = 0u32;
1220 let mut dependencies = HashSet::new();
1221 let mut pending = Vec::new();
1222 let mut deleted_paths = Vec::new();
1223 let mut skips = Vec::new();
1224
1225 for file in &parsed.files {
1226 match file.operation {
1227 FileOperation::Added | FileOperation::Copied => {
1228 let new_content = file.new_content.as_deref().unwrap_or(&[]);
1229 let encoding = Encoding::detect(new_content);
1230
1231 let filename = extract_filename(&file.path);
1232 let name_start = ChangePosition::new(contents.len() as u64);
1233 contents.extend_from_slice(filename.as_bytes());
1234 let name_end = ChangePosition::new(contents.len() as u64);
1235 let inode_pos = Position {
1236 change: None,
1237 pos: name_end,
1238 };
1239 let name_pos = Position {
1240 change: None,
1241 pos: name_end,
1242 };
1243 let parent_pos = Position {
1244 change: Some(ContentHash::NONE),
1245 pos: ChangePosition::ROOT,
1246 };
1247
1248 let new_line_contents: Vec<Vec<u8>> =
1249 if encoding == Encoding::Binary || is_generated_diff_skip_path(&file.path) {
1250 if new_content.is_empty() {
1251 Vec::new()
1252 } else {
1253 vec![new_content.to_vec()]
1254 }
1255 } else {
1256 split_graph_first_lines(new_content)
1257 .into_iter()
1258 .map(|line| line.to_vec())

Callers 1

write_commitMethod · 0.85

Calls 15

extract_filenameFunction · 0.85
split_graph_first_linesFunction · 0.85
InsertionClass · 0.85
position_hashesFunction · 0.85
EdgeUpdateClass · 0.85
skipMethod · 0.80
extendMethod · 0.80

Tested by

no test coverage detected