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

Method persist_view_conflicts

atomic-repository/src/repository/materialize.rs:168–218  ·  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>,
        only_paths: &Option<s

Source from the content-addressed store, hash-verified

166 /// setting or clearing each. This keeps a partial run from wrongly
167 /// discarding conflicts for files it did not re-materialize.
168 fn persist_view_conflicts(
169 &self,
170 view_id: u64,
171 path_to_inode: &std::collections::HashMap<String, u64>,
172 conflicts_by_path: &std::collections::HashMap<String, u32>,
173 only_paths: &Option<std::collections::HashSet<String>>,
174 ) -> Result<(), RepositoryError> {
175 let mut wtxn = self
176 .pristine
177 .write_txn()
178 .map_err(|e| RepositoryError::Database(e.to_string()))?;
179
180 let mk = |path: &str, line: u32| StoredConflict {
181 kind: StoredConflictKind::Order,
182 path: path.to_string(),
183 line: Some(line),
184 sides: Vec::new(),
185 };
186
187 match only_paths {
188 None => {
189 wtxn.del_conflicts_prefix(view_id)
190 .map_err(|e| RepositoryError::Database(e.to_string()))?;
191 for (path, line) in conflicts_by_path {
192 if let Some(&inode) = path_to_inode.get(path) {
193 let sc = mk(path, *line);
194 wtxn.put_conflicts(view_id, inode, std::slice::from_ref(&sc))
195 .map_err(|e| RepositoryError::Database(e.to_string()))?;
196 }
197 }
198 }
199 Some(paths) => {
200 for path in paths {
201 if let Some(&inode) = path_to_inode.get(path) {
202 if let Some(line) = conflicts_by_path.get(path) {
203 let sc = mk(path, *line);
204 wtxn.put_conflicts(view_id, inode, std::slice::from_ref(&sc))
205 .map_err(|e| RepositoryError::Database(e.to_string()))?;
206 } else {
207 wtxn.del_conflicts(view_id, inode)
208 .map_err(|e| RepositoryError::Database(e.to_string()))?;
209 }
210 }
211 }
212 }
213 }
214
215 wtxn.commit()
216 .map_err(|e| RepositoryError::Database(e.to_string()))?;
217 Ok(())
218 }
219 /// Compute the set of file paths visible on a view.
220 ///
221 /// Visibility includes the view's own changes AND all changes

Callers 1

materialize_parallelMethod · 0.80

Calls 6

write_txnMethod · 0.80
del_conflicts_prefixMethod · 0.80
put_conflictsMethod · 0.80
del_conflictsMethod · 0.80
commitMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected