Resolve a sequence number to a hash.
(&self, repo: &Repository, view_name: &str, seq: u64)
| 267 | |
| 268 | /// Resolve a sequence number to a hash. |
| 269 | fn resolve_sequence(&self, repo: &Repository, view_name: &str, seq: u64) -> CliResult<Hash> { |
| 270 | let txn = repo |
| 271 | .pristine() |
| 272 | .read_txn() |
| 273 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 274 | |
| 275 | let view = txn |
| 276 | .get_view(view_name) |
| 277 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))? |
| 278 | .ok_or_else(|| CliError::ViewNotFound { |
| 279 | name: view_name.to_string(), |
| 280 | })?; |
| 281 | |
| 282 | let entry = get_change_at_sequence(&txn, &view, seq).map_err(|e| match e { |
| 283 | atomic_repository::history::HistoryError::SequenceOutOfRange { sequence, max } => { |
| 284 | CliError::InvalidArgument { |
| 285 | message: format!( |
| 286 | "Sequence {} out of range. View has {} changes (0-{}).", |
| 287 | sequence, |
| 288 | max + 1, |
| 289 | max |
| 290 | ), |
| 291 | } |
| 292 | } |
| 293 | other => CliError::Internal(anyhow::anyhow!("{}", other)), |
| 294 | })?; |
| 295 | |
| 296 | Ok(entry.hash) |
| 297 | } |
| 298 | |
| 299 | /// Get the most recent change on the view. |
| 300 | fn get_latest_change(&self, repo: &Repository, view_name: &str) -> CliResult<(Hash, u64)> { |
no test coverage detected