Get file content, excluding a specific change. This is identical to [`Self::get_file_content`] but removes `exclude_hash` from the change filter. Use this to get the file content as it was **before** a specific change was applied — pass the change's hash as `exclude_hash` and you get the prior state.
(
&self,
path: P,
exclude_hash: &Hash,
)
| 172 | /// content as it was **before** a specific change was applied — pass |
| 173 | /// the change's hash as `exclude_hash` and you get the prior state. |
| 174 | pub fn get_file_content_excluding<P: AsRef<Path>>( |
| 175 | &self, |
| 176 | path: P, |
| 177 | exclude_hash: &Hash, |
| 178 | ) -> Result<Option<Vec<u8>>, RepositoryError> { |
| 179 | use atomic_core::output::alive::RetrieveOptions; |
| 180 | let path = path.as_ref(); |
| 181 | let normalized = normalize_path(path); |
| 182 | |
| 183 | let txn = self |
| 184 | .pristine |
| 185 | .read_txn() |
| 186 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 187 | |
| 188 | let view = txn |
| 189 | .get_view(&self.current_view) |
| 190 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 191 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 192 | name: self.current_view.clone(), |
| 193 | })?; |
| 194 | |
| 195 | if !is_tracked(&txn, &normalized).map_err(|e| RepositoryError::Database(e.to_string()))? { |
| 196 | return Ok(None); |
| 197 | } |
| 198 | |
| 199 | let inode = match get_inode(&txn, &normalized) { |
| 200 | Ok(Some(inode)) => inode, |
| 201 | Ok(None) => return Ok(None), |
| 202 | Err(e) => return Err(RepositoryError::Database(e.to_string())), |
| 203 | }; |
| 204 | |
| 205 | let position = match txn.inode_position(inode) { |
| 206 | Ok(Some(pos)) => pos, |
| 207 | Ok(None) => return Ok(None), |
| 208 | Err(e) => return Err(RepositoryError::Database(e.to_string())), |
| 209 | }; |
| 210 | |
| 211 | let mut change_filter = if view.kind.is_shared() && view.parent.is_none() { |
| 212 | collect_view_change_ids(&txn, &view)? |
| 213 | } else { |
| 214 | collect_visible_change_ids_with_deps(&txn, &view)? |
| 215 | }; |
| 216 | |
| 217 | // Remove the excluded change from the filter |
| 218 | if let Ok(Some(exclude_id)) = txn.get_internal(exclude_hash) { |
| 219 | change_filter.remove(&exclude_id); |
| 220 | } |
| 221 | |
| 222 | let options = RetrieveOptions::new().with_change_filter(change_filter); |
| 223 | |
| 224 | let cached_txn = |
| 225 | CachedGraphTxn::new(&txn).map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 226 | let content = retrieve_content_with_filter_fast( |
| 227 | &cached_txn, |
| 228 | &self.change_store, |
| 229 | inode, |
| 230 | position, |
| 231 | options, |
nothing calls this directly
no test coverage detected