Get the most recent change on the view.
(&self, repo: &Repository, view_name: &str)
| 298 | |
| 299 | /// Get the most recent change on the view. |
| 300 | fn get_latest_change(&self, repo: &Repository, view_name: &str) -> CliResult<(Hash, u64)> { |
| 301 | let txn = repo |
| 302 | .pristine() |
| 303 | .read_txn() |
| 304 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 305 | |
| 306 | let view = txn |
| 307 | .get_view(view_name) |
| 308 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))? |
| 309 | .ok_or_else(|| CliError::ViewNotFound { |
| 310 | name: view_name.to_string(), |
| 311 | })?; |
| 312 | |
| 313 | if view.change_count == 0 { |
| 314 | return Err(CliError::NothingToRecord); |
| 315 | } |
| 316 | |
| 317 | let seq = view.change_count - 1; |
| 318 | let entry = get_change_at_sequence(&txn, &view, seq) |
| 319 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 320 | |
| 321 | Ok((entry.hash, seq)) |
| 322 | } |
| 323 | |
| 324 | /// Format the change for default output. |
| 325 | fn format_default( |
no test coverage detected