pub fn with_state<F>(
repo_root: &Path,
home_override: Option<&Path>,
f: F,
) -> Result<StateV2, WorktreeError>Expand description
Read-modify-write helper: acquires state.lock, reads state, applies the closure, then writes back. The lock is released as soon as this function returns — callers must not perform long-running work inside the closure.
Uses DEFAULT_LOCK_TIMEOUT_MS. Prefer with_state_timeout from inside a
Manager so Config.lock_timeout_ms is honored.