MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / resolve_sequence

Method resolve_sequence

atomic-cli/src/commands/change/command.rs:269–297  ·  view source on GitHub ↗

Resolve a sequence number to a hash.

(&self, repo: &Repository, view_name: &str, seq: u64)

Source from the content-addressed store, hash-verified

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)> {

Callers 1

resolve_identifierMethod · 0.80

Calls 4

read_txnMethod · 0.80
pristineMethod · 0.80
get_change_at_sequenceFunction · 0.50
get_viewMethod · 0.45

Tested by

no test coverage detected