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,
)
| 510 | /// draft view, while those below were inherited when the view was |
| 511 | /// created. |
| 512 | pub fn parent_change_count( |
| 513 | &self, |
| 514 | view_name: &str, |
| 515 | ) -> Result<Option<(String, u64)>, RepositoryError> { |
| 516 | let txn = self |
| 517 | .pristine |
| 518 | .read_txn() |
| 519 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 520 | |
| 521 | let view = txn |
| 522 | .get_view(view_name) |
| 523 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 524 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 525 | name: view_name.to_string(), |
| 526 | })?; |
| 527 | |
| 528 | match view.parent { |
| 529 | Some(parent_id) => { |
| 530 | let parent = txn |
| 531 | .get_view_by_id(parent_id) |
| 532 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 533 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 534 | name: format!("<parent id {}>", parent_id), |
| 535 | })?; |
| 536 | Ok(Some((parent.name.clone(), parent.change_count))) |
| 537 | } |
| 538 | None => Ok(None), |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | /// Get information about a view. |
| 543 | /// |
nothing calls this directly
no test coverage detected