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

Function localize_file_ops

atomic-core/src/change/span_patch.rs:237–252  ·  view source on GitHub ↗

Resolve a span change's authored semantic IDs under a receiving transaction. The hashed change is never modified. Legacy V1 operations with external IDs cannot be localized because their owner hashes were not recorded.

(
    txn: &T,
    change: &crate::change::Change,
)

Source from the content-addressed store, hash-verified

235/// The hashed change is never modified. Legacy V1 operations with external
236/// IDs cannot be localized because their owner hashes were not recorded.
237pub fn localize_file_ops<T: crate::pristine::GraphTxnT>(
238 txn: &T,
239 change: &crate::change::Change,
240) -> anyhow::Result<Vec<crate::change::FileOps>> {
241 let Some(patch) = &change.hashed.span else {
242 return Ok(change.file_ops().to_vec());
243 };
244 patch.validate_content_ranges(change.contents.len().try_into()?)?;
245 Ok(
246 SemanticNameFrame::new(patch.semantic_owners.clone())?.localize(
247 txn,
248 change.dependencies(),
249 change.file_ops(),
250 )?,
251 )
252}
253
254#[cfg(test)]
255mod tests {

Calls 6

localizeMethod · 0.80
file_opsMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45
dependenciesMethod · 0.45

Tested by

no test coverage detected