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

Method list_conflicts

atomic-repository/src/repository/status.rs:1076–1150  ·  view source on GitHub ↗
(
        &self,
        working_copy: WorkingCopyId,
    )

Source from the content-addressed store, hash-verified

1074 /// omitted. Read-only.
1075 #[allow(clippy::type_complexity)]
1076 pub fn list_conflicts(
1077 &self,
1078 working_copy: WorkingCopyId,
1079 ) -> Result<Vec<(String, Vec<atomic_core::pristine::StoredConflict>)>, RepositoryError> {
1080 let view_name = self.desired_view_name(working_copy)?;
1081 let txn = self
1082 .pristine
1083 .read_txn()
1084 .map_err(|e| RepositoryError::Database(e.to_string()))?;
1085 let view = match txn
1086 .get_view(&view_name)
1087 .map_err(|e| RepositoryError::Database(e.to_string()))?
1088 {
1089 Some(v) => v,
1090 None => return Ok(Vec::new()),
1091 };
1092 let visibility = graph_visibility_closure(&txn, &view)?;
1093 let projection = self.project_tree_for_visibility(&txn, &visibility)?;
1094 let active_name_paths: HashSet<String> = projection
1095 .name_conflicts
1096 .iter()
1097 .filter_map(|(path, conflict)| {
1098 let sides = conflict.sides_at_path(path);
1099 let requires_marker =
1100 !conflict.is_rename_conflict() && sides.iter().all(|side| !side.is_directory());
1101 let has_marker = std::fs::read(self.root.join(path))
1102 .ok()
1103 .and_then(|bytes| super::materialize::first_conflict_marker_line(&bytes))
1104 .is_some();
1105 (!requires_marker || has_marker).then(|| path.clone())
1106 })
1107 .collect();
1108 let mut by_path = HashMap::<String, Vec<atomic_core::pristine::StoredConflict>>::new();
1109 for (_inode, records) in txn
1110 .iter_conflicts(view.id)
1111 .map_err(|e| RepositoryError::Database(e.to_string()))?
1112 {
1113 for record in records {
1114 let still_conflicted = if record.kind
1115 == atomic_core::pristine::StoredConflictKind::Name
1116 {
1117 active_name_paths.contains(&record.path)
1118 } else {
1119 std::fs::read(self.root.join(&record.path))
1120 .ok()
1121 .and_then(|bytes| super::materialize::first_conflict_marker_line(&bytes))
1122 .is_some()
1123 };
1124 if still_conflicted {
1125 by_path.entry(record.path.clone()).or_default().push(record);
1126 }
1127 }
1128 }
1129 for (path, conflict) in projection.name_conflicts {
1130 if !active_name_paths.contains(&path) {
1131 continue;
1132 }
1133 by_path.entry(path.clone()).or_insert_with(|| {

Callers 2

verify_working_copyMethod · 0.45
listed_conflict_pathsFunction · 0.45

Calls 15

graph_visibility_closureFunction · 0.85
desired_view_nameMethod · 0.80
read_txnMethod · 0.80
sides_at_pathMethod · 0.80
is_rename_conflictMethod · 0.80
readFunction · 0.50
get_viewMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
allMethod · 0.45

Tested by 1

listed_conflict_pathsFunction · 0.36