(
txn: &atomic_core::pristine::ReadTxn,
cached: &CachedGraphTxn<'_>,
store: &ChangeStore,
visibility: &GraphVisibilityClosure,
path: &str,
conflict: &super::name_resolution::Pr
| 5022 | |
| 5023 | #[allow(clippy::too_many_arguments)] |
| 5024 | fn 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, |
no test coverage detected