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:1149–1826  ·  view source on GitHub ↗
(
    header: ChangeHeader,
    parsed: &ParsedCommit,
    line_index: &ImportLineIndex,
    graph_only: bool,
)

Source from the content-addressed store, hash-verified

1147}
1148
1149fn build_graph_first_change(
1150 header: ChangeHeader,
1151 parsed: &ParsedCommit,
1152 line_index: &ImportLineIndex,
1153 graph_only: bool,
1154) -> Result<(Change, Vec<PendingLineIndexUpdate>, Vec<String>), Vec<GraphFirstSkip>> {
1155 if parsed.files.is_empty() {
1156 return Err(vec![GraphFirstSkip {
1157 path: String::new(),
1158 operation: FileOperation::Modified,
1159 reason: "empty_commit",
1160 }]);
1161 }
1162
1163 let mut contents = Vec::new();
1164 let mut hunks = Vec::new();
1165 let mut file_ops = Vec::new();
1166 let mut next_file_idx = 0u32;
1167 let mut next_branch_idx = 0u32;
1168 let mut dependencies = HashSet::new();
1169 let mut pending = Vec::new();
1170 let mut deleted_paths = Vec::new();
1171 let mut skips = Vec::new();
1172
1173 for file in &parsed.files {
1174 match file.operation {
1175 FileOperation::Added | FileOperation::Copied => {
1176 let new_content = file.new_content.as_deref().unwrap_or(&[]);
1177 let encoding = Encoding::detect(new_content);
1178
1179 let filename = extract_filename(&file.path);
1180 let name_start = ChangePosition::new(contents.len() as u64);
1181 contents.extend_from_slice(filename.as_bytes());
1182 let name_end = ChangePosition::new(contents.len() as u64);
1183 let inode_pos = Position {
1184 change: None,
1185 pos: name_end,
1186 };
1187 let name_pos = Position {
1188 change: None,
1189 pos: name_end,
1190 };
1191 let parent_pos = Position {
1192 change: Some(ContentHash::NONE),
1193 pos: ChangePosition::ROOT,
1194 };
1195
1196 let new_line_contents: Vec<Vec<u8>> =
1197 if encoding == Encoding::Binary || is_generated_diff_skip_path(&file.path) {
1198 if new_content.is_empty() {
1199 Vec::new()
1200 } else {
1201 vec![new_content.to_vec()]
1202 }
1203 } else {
1204 split_graph_first_lines(new_content)
1205 .into_iter()
1206 .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