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

Method resurrect_commit

atomic-cli/src/commands/git/parallel.rs:5821–5911  ·  view source on GitHub ↗

Resurrect a verified binding's closure into the target view instead of synthesizing from Git (CB-9A/CB-6C). The exact path restores the original changes (hashes, bytes, dependencies, frontiers, semantic identities, order, Merkle, SetId), completing the closure through the CB-6B transport when needed, and proves the recomputed projection against the bound tree before any membership is published.

(
        &self,
        repo: &mut Repository,
        git: &GitRepository,
        parsed: &ParsedCommit,
        binding: &atomic_repository::git_binding::GitStateBinding,
    )

Source from the content-addressed store, hash-verified

5819 /// proves the recomputed projection against the bound tree before any
5820 /// membership is published.
5821 fn resurrect_commit(
5822 &self,
5823 repo: &mut Repository,
5824 git: &GitRepository,
5825 parsed: &ParsedCommit,
5826 binding: &atomic_repository::git_binding::GitStateBinding,
5827 ) -> CliResult<ImportedCommitInfo> {
5828 // An anchor may extend an existing interpretation with Atomic-only
5829 // changes (for example the imported repository's .atomicignore).
5830 // Keep the original immutable interpretation when it is contained
5831 // in the binding and still proves the same Git tree. Equal bytes
5832 // alone must not authorize replacing unrelated causal identities.
5833 let existing_closure = repo
5834 .git_commit_closure(&parsed.git_sha)
5835 .map_err(|e| CliError::Internal(e.into()))?;
5836 if let Some(existing) = &existing_closure {
5837 let bound = &binding.payload().ordered_changes;
5838 if !existing.iter().all(|hash| bound.contains(hash)) {
5839 return Err(git_error(format!(
5840 "binding for {} does not contain its persisted interpretation closure",
5841 parsed.git_sha
5842 )));
5843 }
5844 if existing.len() != bound.len() {
5845 let projection = repo
5846 .project_tree_for_change_closure(
5847 &self.options.target_view,
5848 existing,
5849 &conversion_policy(git)?,
5850 )
5851 .map_err(|e| CliError::Internal(e.into()))?;
5852 if projection.git.root.as_bytes() != parsed.tree_oid.as_bytes() {
5853 return Err(git_error(format!(
5854 "persisted interpretation closure for {} does not reproduce its Git tree",
5855 parsed.git_sha
5856 )));
5857 }
5858 }
5859 }
5860 let outcome = repo
5861 .resurrect_binding_exact(git, binding, &self.options.target_view, None)
5862 .map_err(|e| CliError::Internal(e.into()))?;
5863 // Persist the resurrected commit's interpreted closure (review R1):
5864 // every restored or already-present change with its dependency
5865 // closure, so descendants in later runs keep the exact parent
5866 // visibility even though restored changes may not carry resolvable
5867 // SHA provenance.
5868 let mut restored_hashes: Vec<ContentHash> = outcome.inserted.clone();
5869 restored_hashes.extend(outcome.already_present.iter().copied());
5870 if existing_closure.is_none() && !restored_hashes.is_empty() {
5871 repo.record_git_commit_closure(&parsed.git_sha, &restored_hashes)
5872 .map_err(|e| CliError::Internal(e.into()))?;
5873 }
5874 print_info(&format!(
5875 "Resurrected verified binding for {} ({} change(s) restored, {} already present{}), \
5876 tree proof {}",
5877 parsed.short_sha,
5878 outcome.inserted.len(),

Callers 1

phase2_writeMethod · 0.80

Calls 15

conversion_policyFunction · 0.85
print_infoFunction · 0.85
git_commit_closureMethod · 0.80
extendMethod · 0.80
is_noneMethod · 0.80
lastMethod · 0.80
full_messageMethod · 0.80
git_errorFunction · 0.70
payloadMethod · 0.45

Tested by

no test coverage detected