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,
)
| 472 | /// draft view, while those below were inherited when the view was |
| 473 | /// created. |
| 474 | pub fn parent_change_count( |
| 475 | &self, |
| 476 | view_name: &str, |
| 477 | ) -> Result<Option<(String, u64)>, RepositoryError> { |
| 478 | let txn = self |
| 479 | .pristine |
| 480 | .read_txn() |
| 481 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 482 | |
| 483 | let view = txn |
| 484 | .get_view(view_name) |
| 485 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 486 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 487 | name: view_name.to_string(), |
| 488 | })?; |
| 489 | |
| 490 | match view.parent { |
| 491 | Some(parent_id) => { |
| 492 | let parent = txn |
| 493 | .get_view_by_id(parent_id) |
| 494 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 495 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 496 | name: format!("<parent id {}>", parent_id), |
| 497 | })?; |
| 498 | Ok(Some((parent.name.clone(), parent.change_count))) |
| 499 | } |
| 500 | None => Ok(None), |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | /// Get information about a view. |
| 505 | /// |
nothing calls this directly
no test coverage detected