MCPcopy Create free account
hub / github.com/EpicGames/lore / finalize_commit

Function finalize_commit

lore-revision/src/commit.rs:984–1040  ·  view source on GitHub ↗

Stores branch latest, deletes staged anchor, updates last sync if merge, and emits the revision commit event.

(
    repository: Arc<RepositoryContext>,
    state_current: &Arc<State>,
    state_staged: &Arc<State>,
    signature: Hash,
    branch: BranchId,
    token: &RepositoryWriteToken,
)

Source from the content-addressed store, hash-verified

982/// Stores branch latest, deletes staged anchor, updates last sync if merge,
983/// and emits the revision commit event.
984async fn finalize_commit(
985 repository: Arc<RepositoryContext>,
986 state_current: &Arc<State>,
987 state_staged: &Arc<State>,
988 signature: Hash,
989 branch: BranchId,
990 token: &RepositoryWriteToken,
991) -> Result<(), CommitError> {
992 let dry_run = execution_context().globals().dry_run();
993
994 if !dry_run {
995 store_branch_latest_and_make_current(repository.clone(), signature, branch).await?;
996
997 // Check if any dirty-only nodes remain in the staged state.
998 // If so, preserve them in a new staged anchor re-parented to the new revision.
999 let has_dirty = state_staged
1000 .node_has_dirty_children(repository.clone(), crate::node::ROOT_NODE)
1001 .await
1002 .forward::<CommitError>("Failed deserializing state node block")?;
1003
1004 if has_dirty {
1005 lore_debug!("Dirty nodes remain after commit, preserving in new staged anchor");
1006 state_staged.set_parent_self(signature);
1007 state_staged.set_revision_number(0);
1008 state_staged.set_parent_other(Hash::default());
1009 state_staged.set_metadata_hash(Hash::default());
1010 state_staged.mark_dirty();
1011
1012 let staged_signature =
1013 state_staged
1014 .serialize(repository.clone(), token)
1015 .await
1016 .forward::<CommitError>("Failed to serialize staged revision state")?;
1017 crate::instance::store_staged_anchor(&repository, staged_signature)
1018 .await
1019 .forward::<CommitError>("Failed to serialize staged anchor")?;
1020 } else {
1021 let _ = crate::instance::delete_staged_anchor(&repository).await;
1022 }
1023
1024 if state_staged.parent_other() == state_current.revision() && state_staged.is_merge() {
1025 branch::store_last_sync(repository.clone(), branch, state_staged.parent_self()).await;
1026 }
1027 }
1028
1029 event::LoreEvent::RevisionCommitRevision(LoreRevisionCommitRevisionEventData {
1030 repository: repository.id,
1031 branch,
1032 revision: signature,
1033 revision_number: state_staged.revision_number(),
1034 parent: state_staged.parent_self(),
1035 parent_other: state_staged.parent_other(),
1036 })
1037 .send();
1038
1039 Ok(())
1040}
1041

Callers 2

commit_implFunction · 0.85
commit_link_onlyFunction · 0.85

Calls 15

execution_contextFunction · 0.85
store_staged_anchorFunction · 0.85
delete_staged_anchorFunction · 0.85
store_last_syncFunction · 0.85
dry_runMethod · 0.80
globalsMethod · 0.80
set_parent_selfMethod · 0.80
set_parent_otherMethod · 0.80
set_metadata_hashMethod · 0.80
parent_otherMethod · 0.80

Tested by

no test coverage detected