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

Source from the content-addressed store, hash-verified

3079}
3080
3081fn build_graph_first_change(
3082 header: ChangeHeader,
3083 parsed: &ParsedCommit,
3084 line_index: &ImportLineIndex,
3085 graph_only: bool,
3086) -> Result<(Change, Vec<PendingLineIndexUpdate>, Vec<String>), Vec<GraphFirstSkip>> {
3087 if parsed.files.is_empty() {
3088 return Err(vec![GraphFirstSkip {
3089 path: String::new(),
3090 operation: FileOperation::Modified,
3091 reason: "empty_commit",
3092 }]);
3093 }
3094
3095 let mut contents = Vec::new();
3096 let mut hunks = Vec::new();
3097 let mut file_ops = Vec::new();
3098 let mut next_file_idx = 0u32;
3099 let mut next_branch_idx = 0u32;
3100 let mut dependencies = HashSet::new();
3101 let mut pending = Vec::new();
3102 let mut deleted_paths = Vec::new();
3103 let mut skips = Vec::new();
3104
3105 // Git trees do not contain explicit directory entries. Build the required
3106 // parent anchors first so every nested name attaches to an actual directory
3107 // inode, including directories introduced earlier in this same change.
3108 let mut directory_anchors = line_index.directories.clone();
3109 let mut required_directories = HashSet::new();
3110 for file in &parsed.files {
3111 if matches!(file.operation, FileOperation::Added | FileOperation::Copied) {
3112 required_directories.extend(ancestor_directories(&file.path));
3113 }
3114 }
3115 let mut required_directories: Vec<String> = required_directories.into_iter().collect();
3116 required_directories.sort_by_key(|path| (path.matches('/').count(), path.clone()));
3117
3118 for directory_path in required_directories {
3119 if let Some(anchor) = directory_anchors.get(&directory_path) {
3120 dependencies.extend(position_hashes(anchor));
3121 continue;
3122 }
3123
3124 let parent_path = extract_parent(&directory_path);
3125 let parent_pos = if parent_path.is_empty() {
3126 Position {
3127 change: Some(ContentHash::NONE),
3128 pos: ChangePosition::ROOT,
3129 }
3130 } else if let Some(anchor) = directory_anchors.get(parent_path).copied() {
3131 anchor
3132 } else {
3133 return Err(vec![GraphFirstSkip {
3134 path: directory_path,
3135 operation: FileOperation::Added,
3136 reason: "missing_parent_directory_anchor",
3137 }]);
3138 };

Calls 15

ancestor_directoriesFunction · 0.85
position_hashesFunction · 0.85
extract_parentFunction · 0.85
repository_pathFunction · 0.85
extract_filenameFunction · 0.85
split_graph_first_linesFunction · 0.85
InsertionClass · 0.85
EdgeUpdateClass · 0.85