This is an archive of the discontinued Mercurial Phabricator instance.

rhg: Initial repository locking
ClosedPublic

Authored by SimonSapin on Dec 2 2021, 11:48 AM.

Details

Summary

Initial Rust implementation of locking based on the .hg/wlock symlink (or file),
with lock breaking when the recorded pid and hostname show that a lock was
left by a local process that is not running anymore (as it might have been
killed).

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

SimonSapin created this revision.Dec 2 2021, 11:48 AM
Alphare requested changes to this revision.Dec 3 2021, 6:13 AM
Alphare added a subscriber: Alphare.

Small change, but it is different behavior, so I'll let you change that.

Otherwise the change looks good and I see no real different with the Python implementation.

rust/hg-core/src/lock.rs
125

There is not I'm afraid.

169

You can catch ENOTDIR with error.raw_os_error() == Some(20)

This revision now requires changes to proceed.Dec 3 2021, 6:13 AM
SimonSapin added inline comments.Dec 6 2021, 4:21 AM
rust/hg-core/src/lock.rs
125

Yeah it just feels weird to go through std::io::Error. I wish the libc crate exposed something to access errno, even though it might need to be more than a simple FFI binding. I’ll remove this comment.

169

Good point, I’ll change the whole match to look at errno values

SimonSapin updated this revision to Diff 31317.Dec 6 2021, 5:02 AM
Alphare accepted this revision.Dec 6 2021, 5:17 AM
This revision is now accepted and ready to land.Dec 6 2021, 5:17 AM
This revision was automatically updated to reflect the committed changes.