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

Method resolve_sequence

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

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

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