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

Method parent_change_count

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

Get the parent view's change count for a given view. Returns `Some((parent_name, parent_change_count))` if the view has a parent, or `None` if it is a root view. This is used by `atomic log` to determine the fork point: changes with sequence numbers `>= parent_change_count` are local to the draft view, while those below were inherited when the view was created.

(
        &self,
        view_name: &str,
    )

Source from the content-addressed store, hash-verified

670 /// draft view, while those below were inherited when the view was
671 /// created.
672 pub fn parent_change_count(
673 &self,
674 view_name: &str,
675 ) -> Result<Option<(String, u64)>, RepositoryError> {
676 let txn = self
677 .pristine
678 .read_txn()
679 .map_err(|e| RepositoryError::Database(e.to_string()))?;
680
681 let view = txn
682 .get_view(view_name)
683 .map_err(|e| RepositoryError::Database(e.to_string()))?
684 .ok_or_else(|| RepositoryError::ViewNotFound {
685 name: view_name.to_string(),
686 })?;
687
688 match view.parent {
689 Some(parent_id) => {
690 let parent = txn
691 .get_view_by_id(parent_id)
692 .map_err(|e| RepositoryError::Database(e.to_string()))?
693 .ok_or_else(|| RepositoryError::ViewNotFound {
694 name: format!("<parent id {}>", parent_id),
695 })?;
696 Ok(Some((parent.name.clone(), parent.change_count)))
697 }
698 None => Ok(None),
699 }
700 }
701
702 /// Get information about a view.
703 ///

Callers 2

resolve_viewsFunction · 0.80
resolve_triage_viewsFunction · 0.80

Calls 4

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

Tested by

no test coverage detected