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

Method get_view_info

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

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

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