lock: use std File::lock() on Windows 33cde740 parent 70f07cee

The previous implementation used file creation (`create_new`) as a lock mechanism with polling and a 10-second timeout. This caused issues on Windows where "pending delete" semantics could leave lock files stuck. The new implementation uses std's `File::lock()` which maps to `LockFileEx` on Windows, providing proper OS-level blocking locks that are automatically released if the process crashes. The lock file is deleted in `Drop`. On Windows, all openers use `share_mode` without `FILE_SHARE_DELETE`, so `DeleteFileW` only succeeds when no other process has the file open, avoiding any race condition.

authored by Fedor Sheremetyev

1
/target/
2
/rendered-docs
3
.direnv
4
.envrc
5
# Generated by nix build, nix-build
6
result
7
# Generated by the insta crate
8
*.pending-snap
9
*.snap*
10
!cli/tests/cli-reference@.md.snap
11
# Per user insta settings.
12
# See https://insta.rs/docs/settings/#tool-config-file for details.
13
.config/insta.yaml
14
# Per user mise config
15
mise.local.toml
16
17
# mkdocs
18
/.venv
19
/.python-version
20
21
# Editor specific ignores
22
.idea
23
.vscode
24
.zed
25
26
# Generated by setting `JJ_TRACE` environment variable.
27
jj-trace-*.json
28
29
# To make working on buck2 easier (#1997, #4413)
30
/buck-out/
31