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

Function resolve_conflict_export

atomic-cli/src/commands/git/shadow.rs:1058–1104  ·  view source on GitHub ↗

Decide how a view's persisted conflict state projects. Draft views project conflict snapshots by default (RFC §8.3); Shared and remote export refuse unless `allow_conflicts` is explicit — and even the explicit flag never bypasses representability (case collisions on an incapable filesystem, unresolved attribute registers), trust, signing, or complete-pack availability.

(
    repo: &Repository,
    view: &str,
    policy: &ConversionPolicy,
    allow_conflicts: bool,
)

Source from the content-addressed store, hash-verified

1056/// incapable filesystem, unresolved attribute registers), trust, signing, or
1057/// complete-pack availability.
1058fn resolve_conflict_export(
1059 repo: &Repository,
1060 view: &str,
1061 policy: &ConversionPolicy,
1062 allow_conflicts: bool,
1063) -> CliResult<ConflictExport> {
1064 let captured = repo
1065 .capture_view_conflict_set(view)
1066 .map_err(CliError::Repository)?;
1067 let Some(object) = captured else {
1068 return Ok(ConflictExport::Clean);
1069 };
1070 let scope = repo
1071 .get_view_info(view)
1072 .map_err(CliError::Repository)?
1073 .scope;
1074 if scope.is_shared() && !allow_conflicts {
1075 return Err(CliError::Repository(
1076 atomic_repository::RepositoryError::InvalidOperation {
1077 message: format!(
1078 "view '{view}' has {} unresolved Atomic conflict(s); Shared/remote export \
1079 is refused. A Draft ref projects conflicts as an ordinary conflict-snapshot \
1080 commit; Shared export requires --allow-conflicts (which still cannot bypass \
1081 representability, trust, signing, or complete-pack checks)",
1082 object.entry_count()
1083 ),
1084 },
1085 ));
1086 }
1087 let projection = repo
1088 .prepare_conflict_snapshot_projection(view, policy)
1089 .map_err(|error| {
1090 CliError::Repository(atomic_repository::RepositoryError::InvalidOperation {
1091 message: error.to_string(),
1092 })
1093 })?;
1094 if projection.conflict_set != object {
1095 return Err(git_error(
1096 "conflict snapshot preparation disagreed with the captured conflict state",
1097 ));
1098 }
1099 Ok(ConflictExport::Snapshot {
1100 hash: projection.conflict_set_hash,
1101 project: projection.project,
1102 conflicted_paths: projection.conflicted_paths,
1103 })
1104}
1105
1106/// The projection path with conflict snapshot support (RFC §8.3, CB-8B).
1107pub(crate) fn project_view_to_git_with_conflicts(

Callers 1

Calls 6

RepositoryClass · 0.85
get_view_infoMethod · 0.80
is_sharedMethod · 0.80
git_errorFunction · 0.70

Tested by

no test coverage detected