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

Method resolve_sequence

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

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