(path: &Path)
| 704 | } |
| 705 | |
| 706 | fn open_existing_once(path: &Path) -> Result<Self, RepositoryError> { |
| 707 | if let Some((working_root, canonical, view)) = sandbox::detect_sandbox(path) { |
| 708 | // CB-13D ::24 R1: the sandbox open runs the SAME recovery |
| 709 | // steps as the ordinary open_existing (which recovers |
| 710 | // unconditionally) — the sandbox path must not return before |
| 711 | // that gate. |
| 712 | let mut sandbox = Self::open_sandbox(working_root, canonical, &view)?; |
| 713 | let working_copy = sandbox.require_working_copy_id()?; |
| 714 | sandbox.fence_recovery_for_budget(working_copy, ReconcileEffectBudget::Command)?; |
| 715 | return Ok(sandbox); |
| 716 | } |
| 717 | let layout = working_copy::discover_layout(path)?; |
| 718 | let root = layout.working_root.clone(); |
| 719 | let dot_dir = layout.common_dot_dir.clone(); |
| 720 | |
| 721 | let pristine = Arc::new( |
| 722 | Pristine::open_existing(ensure_database(&dot_dir)?).map_err(RepositoryError::from)?, |
| 723 | ); |
| 724 | let (working_copy_id, current_view) = |
| 725 | working_copy::load_registered_identity(&pristine, &layout)?; |
| 726 | |
| 727 | let change_store = ChangeStore::new(dot_dir.join("changes"), DEFAULT_CACHE_CAPACITY) |
| 728 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 729 | |
| 730 | let mut repository = Self { |
| 731 | root, |
| 732 | dot_dir, |
| 733 | current_view, |
| 734 | pristine, |
| 735 | change_store, |
| 736 | is_sandbox: false, |
| 737 | semantic_closure_memo: Default::default(), |
| 738 | }; |
| 739 | let operation_lock = repository.try_lock_operation(working_copy_id)?; |
| 740 | repository.recover_pending_deferred_tree_alignment_locked(&operation_lock)?; |
| 741 | repository.ensure_repository_operation_safe_for(&operation_lock)?; |
| 742 | if let OperationHeadState::Diverged(heads) = |
| 743 | repository.consolidate_operation_heads_locked(&operation_lock)? |
| 744 | { |
| 745 | return Err(RepositoryError::OperationHeadsDiverged { |
| 746 | scope: atomic_core::operation::OperationScope::WorkingCopy(working_copy_id) |
| 747 | .to_string(), |
| 748 | heads: heads.iter().map(ToString::to_string).collect(), |
| 749 | }); |
| 750 | } |
| 751 | repository.recover_incomplete_operation(&operation_lock)?; |
| 752 | drop(operation_lock); |
| 753 | let (_id, authoritative_view) = |
| 754 | working_copy::load_registered_identity(&repository.pristine, &layout)?; |
| 755 | repository.current_view = authoritative_view; |
| 756 | Ok(repository) |
| 757 | } |
| 758 | |
| 759 | /// Open an existing repository for a workspace transaction preflight. |
| 760 | /// |
nothing calls this directly
no test coverage detected