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

Method views_containing_change

atomic-repository/src/repository/views.rs:369–404  ·  view source on GitHub ↗

Return the names of all views whose change-set references `hash`.

(&self, hash: &Hash)

Source from the content-addressed store, hash-verified

367
368 /// Return the names of all views whose change-set references `hash`.
369 pub fn views_containing_change(&self, hash: &Hash) -> Result<Vec<String>, RepositoryError> {
370 let txn = self
371 .pristine
372 .read_txn()
373 .map_err(|e| RepositoryError::Database(e.to_string()))?;
374
375 let change_id = match txn
376 .get_internal(hash)
377 .map_err(|e| RepositoryError::Database(e.to_string()))?
378 {
379 Some(id) => id,
380 None => return Ok(vec![]),
381 };
382
383 let mut names = Vec::new();
384 for name in txn
385 .list_views()
386 .map_err(|e| RepositoryError::Database(e.to_string()))?
387 {
388 let view = match txn
389 .get_view(&name)
390 .map_err(|e| RepositoryError::Database(e.to_string()))?
391 {
392 Some(view) => view,
393 None => continue,
394 };
395 if txn
396 .get_change_seq(&view, change_id)
397 .map_err(|e| RepositoryError::Database(e.to_string()))?
398 .is_some()
399 {
400 names.push(name);
401 }
402 }
403 Ok(names)
404 }
405
406 /// Check if a view exists.
407 ///

Callers 1

Calls 6

read_txnMethod · 0.80
get_internalMethod · 0.45
list_viewsMethod · 0.45
get_viewMethod · 0.45
get_change_seqMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected