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

Method parent_change_count

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

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

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