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

Method parent_change_count

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

565 /// draft view, while those below were inherited when the view was
566 /// created.
567 pub fn parent_change_count(
568 &self,
569 view_name: &str,
570 ) -> Result<Option<(String, u64)>, RepositoryError> {
571 let txn = self
572 .pristine
573 .read_txn()
574 .map_err(|e| RepositoryError::Database(e.to_string()))?;
575
576 let view = txn
577 .get_view(view_name)
578 .map_err(|e| RepositoryError::Database(e.to_string()))?
579 .ok_or_else(|| RepositoryError::ViewNotFound {
580 name: view_name.to_string(),
581 })?;
582
583 match view.parent {
584 Some(parent_id) => {
585 let parent = txn
586 .get_view_by_id(parent_id)
587 .map_err(|e| RepositoryError::Database(e.to_string()))?
588 .ok_or_else(|| RepositoryError::ViewNotFound {
589 name: format!("<parent id {}>", parent_id),
590 })?;
591 Ok(Some((parent.name.clone(), parent.change_count)))
592 }
593 None => Ok(None),
594 }
595 }
596
597 /// Get information about a view.
598 ///

Callers

nothing calls this directly

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