Get the most recent change on the view.
(&self, repo: &Repository, view_name: &str)
| 282 | |
| 283 | /// Get the most recent change on the view. |
| 284 | fn get_latest_change(&self, repo: &Repository, view_name: &str) -> CliResult<(Hash, u64)> { |
| 285 | let txn = repo |
| 286 | .pristine() |
| 287 | .read_txn() |
| 288 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 289 | |
| 290 | let view = txn |
| 291 | .get_view(view_name) |
| 292 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))? |
| 293 | .ok_or_else(|| CliError::ViewNotFound { |
| 294 | name: view_name.to_string(), |
| 295 | })?; |
| 296 | |
| 297 | if view.change_count == 0 { |
| 298 | return Err(CliError::NothingToRecord); |
| 299 | } |
| 300 | |
| 301 | let seq = view.change_count - 1; |
| 302 | let entry = get_change_at_sequence(&txn, &view, seq) |
| 303 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 304 | |
| 305 | Ok((entry.hash, seq)) |
| 306 | } |
| 307 | |
| 308 | /// Format the change for default output. |
| 309 | fn format_default( |
no test coverage detected