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

Method parent_change_count

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

464 /// draft view, while those below were inherited when the view was
465 /// created.
466 pub fn parent_change_count(
467 &self,
468 view_name: &str,
469 ) -> Result<Option<(String, u64)>, RepositoryError> {
470 let txn = self
471 .pristine
472 .read_txn()
473 .map_err(|e| RepositoryError::Database(e.to_string()))?;
474
475 let view = txn
476 .get_view(view_name)
477 .map_err(|e| RepositoryError::Database(e.to_string()))?
478 .ok_or_else(|| RepositoryError::ViewNotFound {
479 name: view_name.to_string(),
480 })?;
481
482 match view.parent {
483 Some(parent_id) => {
484 let parent = txn
485 .get_view_by_id(parent_id)
486 .map_err(|e| RepositoryError::Database(e.to_string()))?
487 .ok_or_else(|| RepositoryError::ViewNotFound {
488 name: format!("<parent id {}>", parent_id),
489 })?;
490 Ok(Some((parent.name.clone(), parent.change_count)))
491 }
492 None => Ok(None),
493 }
494 }
495
496 /// Get information about a view.
497 ///

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