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

Function resolve_conflict_export

atomic-cli/src/commands/git/shadow.rs:1043–1089  ·  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

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