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

Method diff_views

atomic-repository/src/repository/content.rs:265–346  ·  view source on GitHub ↗
(
        &self,
        view_a: &str,
        view_b: &str,
    )

Source from the content-addressed store, hash-verified

263 /// ```
264 #[allow(clippy::type_complexity)]
265 pub fn diff_views(
266 &self,
267 view_a: &str,
268 view_b: &str,
269 ) -> Result<(Vec<Hash>, Vec<Hash>, Vec<Hash>), RepositoryError> {
270 let txn = self
271 .pristine
272 .read_txn()
273 .map_err(|e| RepositoryError::Database(e.to_string()))?;
274
275 let a = txn
276 .get_view(view_a)
277 .map_err(|e| RepositoryError::Database(e.to_string()))?
278 .ok_or_else(|| RepositoryError::ViewNotFound {
279 name: view_a.to_string(),
280 })?;
281
282 let b = txn
283 .get_view(view_b)
284 .map_err(|e| RepositoryError::Database(e.to_string()))?
285 .ok_or_else(|| RepositoryError::ViewNotFound {
286 name: view_b.to_string(),
287 })?;
288
289 // Collect hashes from each view
290 let a_changes: Vec<Hash> = {
291 let iter = txn
292 .iter_changes(&a, 0)
293 .map_err(|e| RepositoryError::Database(e.to_string()))?;
294 let mut hashes = Vec::new();
295 for result in iter {
296 let (_seq, node_id, _merkle) =
297 result.map_err(|e| RepositoryError::Database(e.to_string()))?;
298 if let Some(hash) = txn
299 .get_external(node_id)
300 .map_err(|e| RepositoryError::Database(e.to_string()))?
301 {
302 hashes.push(hash);
303 }
304 }
305 hashes
306 };
307
308 let b_changes: Vec<Hash> = {
309 let iter = txn
310 .iter_changes(&b, 0)
311 .map_err(|e| RepositoryError::Database(e.to_string()))?;
312 let mut hashes = Vec::new();
313 for result in iter {
314 let (_seq, node_id, _merkle) =
315 result.map_err(|e| RepositoryError::Database(e.to_string()))?;
316 if let Some(hash) = txn
317 .get_external(node_id)
318 .map_err(|e| RepositoryError::Database(e.to_string()))?
319 {
320 hashes.push(hash);
321 }
322 }

Callers

nothing calls this directly

Calls 7

read_txnMethod · 0.80
get_viewMethod · 0.45
iter_changesMethod · 0.45
get_externalMethod · 0.45
pushMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected