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

Method try_lock_shadow_commit

atomic-repository/src/repository/materialize.rs:55–68  ·  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

53 /// partial staging. It is a distinct lock from the deferred-tree alignment
54 /// lock and is meant to be taken **outermost**, before any DB write txn.
55 pub fn try_lock_shadow_commit(&self) -> Result<Option<std::fs::File>, RepositoryError> {
56 use fs2::FileExt;
57 let lock = std::fs::OpenOptions::new()
58 .create(true)
59 .truncate(false)
60 .read(true)
61 .write(true)
62 .open(self.dot_dir.join("shadow-commit.lock"))?;
63 match lock.try_lock_exclusive() {
64 Ok(()) => Ok(Some(lock)),
65 Err(e) if is_lock_contended(&e) => Ok(None),
66 Err(e) => Err(RepositoryError::Io(e)),
67 }
68 }
69
70 pub fn first_working_copy_conflict_marker(
71 &self,

Calls 5

truncateMethod · 0.80
is_lock_contendedFunction · 0.70
openMethod · 0.45
writeMethod · 0.45
createMethod · 0.45