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

Function prepare_name_resolution

atomic-repository/src/repository/record.rs:5024–5221  ·  view source on GitHub ↗
(
    txn: &atomic_core::pristine::ReadTxn,
    cached: &CachedGraphTxn<'_>,
    store: &ChangeStore,
    visibility: &GraphVisibilityClosure,
    path: &str,
    conflict: &super::name_resolution::Pr

Source from the content-addressed store, hash-verified

5022
5023#[allow(clippy::too_many_arguments)]
5024fn prepare_name_resolution(
5025 txn: &atomic_core::pristine::ReadTxn,
5026 cached: &CachedGraphTxn<'_>,
5027 store: &ChangeStore,
5028 visibility: &GraphVisibilityClosure,
5029 path: &str,
5030 conflict: &super::name_resolution::ProjectedNameConflict,
5031 working: &[u8],
5032 policy: NameResolutionPolicy,
5033) -> Result<PreparedNameResolution, RecordError> {
5034 use atomic_core::record::workflow::globalize::{
5035 globalize_solve_name_conflict, GlobalizeContext, NameConflictClaim,
5036 };
5037 let preserve_mode = policy == NameResolutionPolicy::PreserveWorkingIdentity;
5038
5039 if conflict.is_rename_conflict() {
5040 return Err(RecordError::Database(format!(
5041 "rename conflict at '{}' must be resolved by recording a surviving path, not by choosing file content",
5042 path
5043 )));
5044 }
5045 let sides = conflict.sides_at_path(path);
5046 if sides.len() < 2 || sides.iter().any(|side| side.is_directory()) {
5047 return Err(RecordError::Database(format!(
5048 "name conflict at '{}' cannot infer a unique file claimant",
5049 path
5050 )));
5051 }
5052
5053 let mut external_hashes = std::collections::HashMap::new();
5054 for change_id in visibility.iter_dependency_first().copied() {
5055 if change_id.is_root() {
5056 continue;
5057 }
5058 let hash = txn
5059 .get_external(change_id)
5060 .map_err(|error| RecordError::Database(error.to_string()))?
5061 .ok_or_else(|| {
5062 RecordError::Database(format!(
5063 "visible change {} has no external hash",
5064 change_id.get()
5065 ))
5066 })?;
5067 external_hashes.insert(change_id, hash);
5068 }
5069 let inode_graph_table = txn
5070 .open_inode_graph_table()
5071 .map_err(|error| RecordError::Database(error.to_string()))?;
5072 let mut matching = Vec::new();
5073 for side in &sides {
5074 let content = super::materialize::render_name_conflict_side(
5075 txn,
5076 store,
5077 &inode_graph_table,
5078 visibility,
5079 &external_hashes,
5080 None,
5081 path,

Calls 15

is_rename_conflictMethod · 0.80
sides_at_pathMethod · 0.80
iter_dependency_firstMethod · 0.80
truncateMethod · 0.80
dependencies_sortedMethod · 0.80
getMethod · 0.65
removeMethod · 0.65
clearMethod · 0.65
lenMethod · 0.45

Tested by

no test coverage detected