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
| 92 | /// setting or clearing each. This keeps a partial run from wrongly |
| 93 | /// discarding conflicts for files it did not re-materialize. |
| 94 | fn persist_view_conflicts( |
| 95 | &self, |
| 96 | view_id: u64, |
| 97 | path_to_inode: &std::collections::HashMap<String, u64>, |
| 98 | conflicts_by_path: &std::collections::HashMap<String, u32>, |
| 99 | only_paths: &Option<std::collections::HashSet<String>>, |
| 100 | ) -> Result<(), RepositoryError> { |
| 101 | let mut wtxn = self |
| 102 | .pristine |
| 103 | .write_txn() |
| 104 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 105 | |
| 106 | let mk = |path: &str, line: u32| StoredConflict { |
| 107 | kind: StoredConflictKind::Order, |
| 108 | path: path.to_string(), |
| 109 | line: Some(line), |
| 110 | sides: Vec::new(), |
| 111 | }; |
| 112 | |
| 113 | match only_paths { |
| 114 | None => { |
| 115 | wtxn.del_conflicts_prefix(view_id) |
| 116 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 117 | for (path, line) in conflicts_by_path { |
| 118 | if let Some(&inode) = path_to_inode.get(path) { |
| 119 | let sc = mk(path, *line); |
| 120 | wtxn.put_conflicts(view_id, inode, std::slice::from_ref(&sc)) |
| 121 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | Some(paths) => { |
| 126 | for path in paths { |
| 127 | if let Some(&inode) = path_to_inode.get(path) { |
| 128 | if let Some(line) = conflicts_by_path.get(path) { |
| 129 | let sc = mk(path, *line); |
| 130 | wtxn.put_conflicts(view_id, inode, std::slice::from_ref(&sc)) |
| 131 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 132 | } else { |
| 133 | wtxn.del_conflicts(view_id, inode) |
| 134 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | wtxn.commit() |
| 142 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 143 | Ok(()) |
| 144 | } |
| 145 | /// Compute the set of file paths visible on a view. |
| 146 | /// |
| 147 | /// Visibility includes the view's own changes AND all changes |
no test coverage detected