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

Method resolve_sequence

atomic-cli/src/commands/change/command.rs:233–261  ·  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

231
232 /// Resolve a sequence number to a hash.
233 fn resolve_sequence(&self, repo: &Repository, view_name: &str, seq: u64) -> CliResult<Hash> {
234 let txn = repo
235 .pristine()
236 .read_txn()
237 .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?;
238
239 let view = txn
240 .get_view(view_name)
241 .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?
242 .ok_or_else(|| CliError::ViewNotFound {
243 name: view_name.to_string(),
244 })?;
245
246 let entry = get_change_at_sequence(&txn, &view, seq).map_err(|e| match e {
247 atomic_repository::history::HistoryError::SequenceOutOfRange { sequence, max } => {
248 CliError::InvalidArgument {
249 message: format!(
250 "Sequence {} out of range. View has {} changes (0-{}).",
251 sequence,
252 max + 1,
253 max
254 ),
255 }
256 }
257 other => CliError::Internal(anyhow::anyhow!("{}", other)),
258 })?;
259
260 Ok(entry.hash)
261 }
262
263 /// Get the most recent change on the view.
264 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