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

Method try_lock_shadow_commit

atomic-repository/src/repository/materialize.rs:146–169  ·  view source on GitHub ↗

Return the first working-copy file that still contains an unresolved conflict marker, as `(path, 1-based line)`, or `None` if the working copy is clean. This scans the same status entries `record` guards on (Added / Modified / Conflicted) with the same detector (`first_conflict_marker_line`), so `atomic record` and `atomic git push` agree on what counts as a conflicted working copy (SPEC §5.4). I

(
        &self,
    )

Source from the content-addressed store, hash-verified

144 /// rather than an independent mutex, so it cannot interleave with a
145 /// working-copy operation that will later acquire pristine or shelf locks.
146 pub fn try_lock_shadow_commit(
147 &self,
148 ) -> Result<Option<RepositoryCommonLockGuard>, RepositoryError> {
149 // CB-13B: once the `git-bridge-cutover` requirement is durable, the
150 // colocated shim owns writes. The legacy shadow writer refuses
151 // before taking its lock or touching any state (fast path).
152 self.require_legacy_shadow_write_allowed()?;
153 #[cfg(test)]
154 shadow_fence_interleave_window();
155 match self.try_lock_common_operation() {
156 Ok(guard) => {
157 // CB-13B R5: re-observe the fence under the held common
158 // lock. A cutover that fenced between the fast-path
159 // observation and this acquisition must fail closed, and
160 // because a cutover itself must take this same lock to
161 // fence, no fence can land after this observation while
162 // the writer path keeps the guard.
163 self.require_legacy_shadow_write_allowed_under_lock(&guard)?;
164 Ok(Some(guard))
165 }
166 Err(error) if error.is_lock_contended() => Ok(None),
167 Err(error) => Err(error),
168 }
169 }
170
171 pub fn first_working_copy_conflict_marker(
172 &self,