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

Method resolve_sequence

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

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