Resolve a sequence number to a hash.
(&self, repo: &Repository, view_name: &str, seq: u64)
| 251 | |
| 252 | /// Resolve a sequence number to a hash. |
| 253 | fn resolve_sequence(&self, repo: &Repository, view_name: &str, seq: u64) -> CliResult<Hash> { |
| 254 | let txn = repo |
| 255 | .pristine() |
| 256 | .read_txn() |
| 257 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 258 | |
| 259 | let view = txn |
| 260 | .get_view(view_name) |
| 261 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))? |
| 262 | .ok_or_else(|| CliError::ViewNotFound { |
| 263 | name: view_name.to_string(), |
| 264 | })?; |
| 265 | |
| 266 | let entry = get_change_at_sequence(&txn, &view, seq).map_err(|e| match e { |
| 267 | atomic_repository::history::HistoryError::SequenceOutOfRange { sequence, max } => { |
| 268 | CliError::InvalidArgument { |
| 269 | message: format!( |
| 270 | "Sequence {} out of range. View has {} changes (0-{}).", |
| 271 | sequence, |
| 272 | max + 1, |
| 273 | max |
| 274 | ), |
| 275 | } |
| 276 | } |
| 277 | other => CliError::Internal(anyhow::anyhow!("{}", other)), |
| 278 | })?; |
| 279 | |
| 280 | Ok(entry.hash) |
| 281 | } |
| 282 | |
| 283 | /// Get the most recent change on the view. |
| 284 | fn get_latest_change(&self, repo: &Repository, view_name: &str) -> CliResult<(Hash, u64)> { |
no test coverage detected