Get the most recent change on the view.
(&self, repo: &Repository, view_name: &str)
| 269 | |
| 270 | /// Get the most recent change on the view. |
| 271 | fn get_latest_change(&self, repo: &Repository, view_name: &str) -> CliResult<(Hash, u64)> { |
| 272 | let txn = repo |
| 273 | .pristine() |
| 274 | .read_txn() |
| 275 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 276 | |
| 277 | let view = txn |
| 278 | .get_view(view_name) |
| 279 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))? |
| 280 | .ok_or_else(|| CliError::ViewNotFound { |
| 281 | name: view_name.to_string(), |
| 282 | })?; |
| 283 | |
| 284 | if view.change_count == 0 { |
| 285 | return Err(CliError::NothingToRecord); |
| 286 | } |
| 287 | |
| 288 | let seq = view.change_count - 1; |
| 289 | let entry = get_change_at_sequence(&txn, &view, seq) |
| 290 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 291 | |
| 292 | Ok((entry.hash, seq)) |
| 293 | } |
| 294 | |
| 295 | /// Format the change for default output. |
| 296 | fn format_default( |
no test coverage detected