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

Method get_view_info

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

Get information about a view. Returns the view's metadata including its Merkle state and change count. # Arguments `name` - The name of the view to query # Returns A `ViewInfo` struct with the view's metadata, or an error if the view doesn't exist.

(&self, name: &str)

Source from the content-addressed store, hash-verified

506 /// A `ViewInfo` struct with the view's metadata, or an error if the view
507 /// doesn't exist.
508 pub fn get_view_info(&self, name: &str) -> Result<ViewInfo, RepositoryError> {
509 let txn = self
510 .pristine
511 .read_txn()
512 .map_err(|e| RepositoryError::Database(e.to_string()))?;
513
514 let view = txn
515 .get_view(name)
516 .map_err(|e| RepositoryError::Database(e.to_string()))?
517 .ok_or_else(|| RepositoryError::ViewNotFound {
518 name: name.to_string(),
519 })?;
520
521 // Resolve parent name and compute own change count.
522 let (parent_name, parent_change_count) = if let Some(parent_id) = view.parent {
523 match txn
524 .get_view_by_id(parent_id)
525 .map_err(|e| RepositoryError::Database(e.to_string()))?
526 {
527 Some(p) => (Some(p.name), p.change_count),
528 None => (None, 0),
529 }
530 } else {
531 (None, 0)
532 };
533
534 let own_change_count = if view.parent.is_some() {
535 view.change_count.saturating_sub(parent_change_count)
536 } else {
537 view.change_count
538 };
539
540 Ok(ViewInfo {
541 name: view.name.clone(),
542 state: view.state,
543 change_count: view.change_count,
544 own_change_count,
545 scope: view.kind,
546 parent_name,
547 })
548 }
549
550 /// Create a new Draft view parented on an explicit named parent.
551 ///

Callers 15

runMethod · 0.80
list_stashesMethod · 0.80
run_showMethod · 0.80
run_promote_to_parentFunction · 0.80
resolve_referenceMethod · 0.80
display_dry_runMethod · 0.80
execute_reviseMethod · 0.80
build_reportFunction · 0.80
run_asyncMethod · 0.80
runMethod · 0.80
runMethod · 0.80

Calls 4

read_txnMethod · 0.80
get_viewMethod · 0.45
get_view_by_idMethod · 0.45
cloneMethod · 0.45