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

Method get_view_info

atomic-repository/src/repository/views.rs:602–646  ·  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

600 /// A `ViewInfo` struct with the view's metadata, or an error if the view
601 /// doesn't exist.
602 pub fn get_view_info(&self, name: &str) -> Result<ViewInfo, RepositoryError> {
603 let txn = self
604 .pristine
605 .read_txn()
606 .map_err(|e| RepositoryError::Database(e.to_string()))?;
607
608 let view = txn
609 .get_view(name)
610 .map_err(|e| RepositoryError::Database(e.to_string()))?
611 .ok_or_else(|| RepositoryError::ViewNotFound {
612 name: name.to_string(),
613 })?;
614
615 // Resolve parent name and compute own/inherited change counts by
616 // actual graph membership rather than by assuming the own log is a
617 // superset of the parent (which only holds for `create_view_from`
618 // drafts, not for record- or split-created drafts).
619 let (parent_name, own_change_count, inherited_change_count) = match view.parent {
620 Some(parent_id) => {
621 match txn
622 .get_view_by_id(parent_id)
623 .map_err(|e| RepositoryError::Database(e.to_string()))?
624 {
625 Some(parent) => {
626 let parent_visible = collect_visible_change_ids(&txn, &parent)?;
627 let own_ids = collect_view_change_ids(&txn, &view)?;
628 let own = own_ids.difference(&parent_visible).count() as u64;
629 (Some(parent.name), own, parent_visible.len() as u64)
630 }
631 None => (None, view.change_count, 0),
632 }
633 }
634 None => (None, view.change_count, 0),
635 };
636
637 Ok(ViewInfo {
638 name: view.name.clone(),
639 state: view.state,
640 change_count: view.change_count,
641 own_change_count,
642 inherited_change_count,
643 scope: view.kind,
644 parent_name,
645 })
646 }
647
648 /// Create a new Draft view parented on an explicit named parent.
649 ///

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
runMethod · 0.80
run_asyncMethod · 0.80
runMethod · 0.80

Calls 8

collect_view_change_idsFunction · 0.85
read_txnMethod · 0.80
get_viewMethod · 0.45
get_view_by_idMethod · 0.45
countMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45