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

Method parent_change_count

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

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

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