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

Method get_file_content_excluding

atomic-repository/src/repository/content.rs:151–180  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

149 /// content as it was **before** a specific change was applied — pass
150 /// the change's hash as `exclude_hash` and you get the prior state.
151 pub fn get_file_content_excluding<P: AsRef<Path>>(
152 &self,
153 path: P,
154 exclude_hash: &Hash,
155 ) -> Result<Option<Vec<u8>>, RepositoryError> {
156 let normalized = normalize_path(path.as_ref());
157
158 let txn = self
159 .pristine
160 .read_txn()
161 .map_err(|e| RepositoryError::Database(e.to_string()))?;
162
163 let view = txn
164 .get_view(&self.current_view)
165 .map_err(|e| RepositoryError::Database(e.to_string()))?
166 .ok_or_else(|| RepositoryError::ViewNotFound {
167 name: self.current_view.clone(),
168 })?;
169
170 let Some(visibility) = graph_visibility_at_change(&txn, &view, exclude_hash, false)? else {
171 return Ok(None);
172 };
173
174 let cached_txn =
175 CachedGraphTxn::new(&txn).map_err(|e| RepositoryError::Database(e.to_string()))?;
176 match self.get_materialized_entry_with_visibility(&cached_txn, &normalized, visibility)? {
177 MaterializedEntry::Absent { .. } => Ok(None),
178 MaterializedEntry::Present { bytes, .. } => Ok(Some(bytes)),
179 }
180 }
181
182 /// Diff two views: returns (changes only in A, changes only in B, common changes).
183 ///

Callers

nothing calls this directly

Calls 7

as_refMethod · 0.80
read_txnMethod · 0.80
normalize_pathFunction · 0.50
get_viewMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected