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

Method persist_view_conflicts

atomic-repository/src/repository/materialize.rs:895–997  ·  view source on GitHub ↗

Persist the conflict state discovered by a materialize into the `CONFLICTS` table for `view_id`. A full materialize (`only_paths` is `None`) replaces the view's entire conflict set: every prior entry is dropped and the current conflicts re-written. A partial materialize updates only the touched files, setting or clearing each. This keeps a partial run from wrongly discarding conflicts for files i

(
        &self,
        view_id: u64,
        path_to_inode: &std::collections::HashMap<String, u64>,
        conflicts_by_path: &std::collections::HashMap<String, u32>,
        name_conflicts: &std:

Source from the content-addressed store, hash-verified

893 /// setting or clearing each. This keeps a partial run from wrongly
894 /// discarding conflicts for files it did not re-materialize.
895 fn persist_view_conflicts(
896 &self,
897 view_id: u64,
898 path_to_inode: &std::collections::HashMap<String, u64>,
899 conflicts_by_path: &std::collections::HashMap<String, u32>,
900 name_conflicts: &std::collections::HashMap<
901 String,
902 super::name_resolution::ProjectedNameConflict,
903 >,
904 only_paths: &Option<std::collections::HashSet<String>>,
905 ) -> Result<(), RepositoryError> {
906 let mut wtxn = self
907 .pristine
908 .write_txn()
909 .map_err(|e| RepositoryError::Database(e.to_string()))?;
910 let mut records_by_inode = std::collections::HashMap::<u64, Vec<StoredConflict>>::new();
911
912 if let Some(paths) = only_paths {
913 for (inode, records) in wtxn
914 .iter_conflicts(view_id)
915 .map_err(|e| RepositoryError::Database(e.to_string()))?
916 {
917 let retained: Vec<_> = records
918 .into_iter()
919 .filter(|record| !paths.contains(&record.path))
920 .collect();
921 if !retained.is_empty() {
922 records_by_inode.insert(inode, retained);
923 }
924 }
925 }
926
927 for (path, line) in conflicts_by_path {
928 if name_conflicts.contains_key(path) {
929 continue;
930 }
931 if let Some(&inode) = path_to_inode.get(path) {
932 records_by_inode
933 .entry(inode)
934 .or_default()
935 .push(StoredConflict {
936 kind: StoredConflictKind::Order,
937 path: path.clone(),
938 line: Some(*line),
939 sides: Vec::new(),
940 });
941 }
942 }
943
944 for (path, conflict) in name_conflicts {
945 if only_paths
946 .as_ref()
947 .is_some_and(|paths| !paths.contains(path))
948 {
949 continue;
950 }
951 let mut side_hashes = Vec::new();
952 for change_id in conflict

Calls 15

write_txnMethod · 0.80
contains_keyMethod · 0.80
as_refMethod · 0.80
sortMethod · 0.80
sides_at_pathMethod · 0.80
del_conflicts_prefixMethod · 0.80
put_conflictsMethod · 0.80
getMethod · 0.65
iter_conflictsMethod · 0.45
collectMethod · 0.45
into_iterMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected