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

Method journal_import_git_head

atomic-repository/src/repository/anchor.rs:1426–1525  ·  view source on GitHub ↗
(
        &mut self,
        operation_lock: &WorkingCopyOperationLockGuard,
        working_copy: WorkingCopyId,
        view: &str,
        state: Merkle,
        before_record: atomic_core::pristin

Source from the content-addressed store, hash-verified

1424 /// changes, with the adopted binding as evidence.
1425 #[allow(clippy::too_many_arguments)]
1426 fn journal_import_git_head(
1427 &mut self,
1428 operation_lock: &WorkingCopyOperationLockGuard,
1429 working_copy: WorkingCopyId,
1430 view: &str,
1431 state: Merkle,
1432 before_record: atomic_core::pristine::WorkingCopyRecord,
1433 after_record: atomic_core::pristine::WorkingCopyRecord,
1434 evidence: atomic_core::Hash,
1435 shelf_effects: Vec<EffectPlan>,
1436 shelf: super::adoption::AdoptionShelfPlan,
1437 ) -> Result<atomic_core::types::OperationId, RepositoryError> {
1438 let before_wc = working_copy_state_ref(before_record);
1439 let after_wc = working_copy_state_ref(after_record);
1440 let state_ref = RepoStateRef {
1441 view: Some(ViewStateRef {
1442 name: view.to_string(),
1443 state,
1444 set_id: None,
1445 }),
1446 working_copy: Some(before_wc.clone()),
1447 git: None,
1448 };
1449 let after_state = RepoStateRef {
1450 view: state_ref.view.clone(),
1451 working_copy: Some(after_wc.clone()),
1452 git: None,
1453 };
1454 // R4: a clean adoption is still a view transition — its ignored
1455 // artifacts swap shelves through the same collision-safe planner and
1456 // executor as the dirty branches. The planned shelf effects keep
1457 // their ordinals; the record advance is the last effect.
1458 let mut effects = shelf_effects;
1459 effects.push(EffectPlan {
1460 ordinal: effects.len() as u32,
1461 target: EffectTarget::WorkingCopy { working_copy },
1462 expected_old: EffectValue::WorkingCopy(before_wc),
1463 expected_new: EffectValue::WorkingCopy(after_wc.clone()),
1464 });
1465 let prepared = self.prepare_working_copy_transition(
1466 operation_lock,
1467 OperationKind::ImportGitHead,
1468 None,
1469 state_ref,
1470 after_state,
1471 effects,
1472 vec![evidence],
1473 ActorRef::System {
1474 name: "git-head-adoption".to_string(),
1475 },
1476 current_operation_timestamp_ms(),
1477 )?;
1478 let operation_id = prepared.operation().id();
1479
1480 // R4: execute the shelf transitions under their leases before the
1481 // record advance (third values fail closed).
1482 let execute_result = (|| -> Result<(), RepositoryError> {
1483 for path in &shelf.ignored {

Callers 1

Calls 15

working_copy_state_refFunction · 0.85
WorkingCopyInterface · 0.85
execute_shelve_pathMethod · 0.80
execute_restore_pathMethod · 0.80
record_effect_outcomeMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected