Skip to content

Commit 1892f36

Browse files
quark-zjumeta-codesync[bot]
authored andcommitted
codemod: drop usage of fs2
Summary: `fs2` was used for locking. Rust 1.89 introduced `File::lock` in stdlib. So we can replace `fs2` with stdlib. - fs2::FileExt::lock_exclusive(&f) → f.lock() - fs2::FileExt::lock_shared(&f) → f.lock_shared() - fs2::FileExt::try_lock_exclusive(&f) → f.try_lock() - fs2::FileExt::try_lock_shared(&f) → f.try_lock_shared() - fs2::FileExt::unlock(&f) → f.unlock() - fs2::FileExt::allocate(&f, n) → f.set_len(n) - fs2::lock_contended_error().kind() → io::ErrorKind::WouldBlock - f.duplicate() → f.try_clone() Mostly updated by claude. Reviewed By: zzl0 Differential Revision: D91255666 fbshipit-source-id: 6fa13b90cf489f6842ef4165d293ad46422c704e
1 parent 199294d commit 1892f36

File tree

21 files changed

+33
-46
lines changed

21 files changed

+33
-46
lines changed

eden/scm/lib/commandserver/BUCK

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ rust_library(
4141
"fbsource//third-party/rust:anyhow",
4242
"fbsource//third-party/rust:dirs",
4343
"fbsource//third-party/rust:fn-error-context",
44-
"fbsource//third-party/rust:fs2",
4544
"fbsource//third-party/rust:once_cell",
4645
"fbsource//third-party/rust:serde",
4746
"fbsource//third-party/rust:tracing",

eden/scm/lib/commandserver/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ name = "commandserver"
1616
anyhow = "1.0.98"
1717
dirs = "6.0"
1818
fn-error-context = "0.2"
19-
fs2 = "0.4"
2019
once_cell = "1.21"
2120
sapling-configmodel = { version = "0.1.0", path = "../config/model" }
2221
sapling-identity = { version = "0.1.0", path = "../identity" }

eden/scm/lib/commandserver/src/spawn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn spawn_pool(pool_size: usize) -> anyhow::Result<()> {
2323
.create(true)
2424
.write(true)
2525
.open(dir.join("spawn.lock"))?;
26-
fs2::FileExt::lock_exclusive(&spawn_lock)?;
26+
spawn_lock.lock()?;
2727

2828
let existing = udsipc::pool::list_uds_paths(&dir, prefix)
2929
.take(pool_size)

eden/scm/lib/dag/BUCK

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ rust_library(
1717
},
1818
}},
1919
"extra_buck_dependencies": {"dev-dependencies": [
20-
"fbsource//third-party/rust:fs2",
2120
"fbsource//third-party/rust:tokio",
2221
"//eden/scm/lib/dag/dag-types:dag-types",
2322
"//eden/scm/lib/indexedlog:indexedlog",
@@ -28,7 +27,6 @@ rust_library(
2827
"render",
2928
],
3029
"indexedlog-backend": [
31-
"fs2",
3230
"sapling-indexedlog",
3331
"tempfile",
3432
],
@@ -63,7 +61,6 @@ rust_library(
6361
"fbsource//third-party/rust:bitflags",
6462
"fbsource//third-party/rust:byteorder",
6563
"fbsource//third-party/rust:fail",
66-
"fbsource//third-party/rust:fs2",
6764
"fbsource//third-party/rust:futures",
6865
"fbsource//third-party/rust:indexmap",
6966
"fbsource//third-party/rust:rand",

eden/scm/lib/dag/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ async-trait = "0.1.86"
1919
bitflags = { version = "2.9", features = ["serde", "std"], default-features = false }
2020
byteorder = "1.5"
2121
fail = { version = "0.4", features = ["failpoints"] }
22-
fs2 = { version = "0.4", optional = true }
2322
futures = { version = "0.3.31", features = ["async-await", "compat"] }
2423
indexmap = { version = "2.9.0", features = ["arbitrary", "rayon", "serde"] }
2524
rand = { version = "0.9", features = ["small_rng"] }
@@ -37,7 +36,6 @@ thiserror = "2.0.12"
3736
tracing = { version = "0.1.41", features = ["attributes", "valuable"] }
3837

3938
[dev-dependencies]
40-
fs2 = "0.4"
4139
once_cell = "1.21"
4240
quickcheck = "1.0"
4341
sapling-dag-types = { version = "0.1.0", path = "dag-types" }
@@ -49,5 +47,5 @@ tokio = { version = "1.47.1", features = ["full", "test-util", "tracing"] }
4947

5048
[features]
5149
default = ["indexedlog-backend", "render"]
52-
indexedlog-backend = ["fs2", "sapling-indexedlog", "tempfile"]
50+
indexedlog-backend = ["sapling-indexedlog", "tempfile"]
5351
render = ["sapling-renderdag"]

eden/scm/lib/dag/src/iddagstore/indexedlog_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ impl Persist for IndexedLogStore {
499499
.create(true)
500500
.open(&path)?
501501
};
502-
fs2::FileExt::lock_exclusive(&lock_file)?;
502+
lock_file.lock()?;
503503
Ok(lock_file)
504504
}
505505

eden/scm/lib/dag/src/idmap/indexedlog_idmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ impl Persist for IdMap {
519519
.create(true)
520520
.open(&path)?
521521
};
522-
fs2::FileExt::lock_exclusive(&lock_file)?;
522+
lock_file.lock()?;
523523
Ok(lock_file)
524524
}
525525

eden/scm/lib/indexedlog/BUCK

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ rust_library(
8181
test_labels = ["tpx-rust-no-backtrace-workaround"],
8282
deps = [
8383
"fbsource//third-party/rust:byteorder",
84-
"fbsource//third-party/rust:fs2",
8584
"fbsource//third-party/rust:memmap2",
8685
"fbsource//third-party/rust:once_cell",
8786
"fbsource//third-party/rust:rand",

eden/scm/lib/indexedlog/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ harness = false
3131

3232
[dependencies]
3333
byteorder = "1.5"
34-
fs2 = "0.4"
3534
memmap2 = "0.9.5"
3635
once_cell = "1.21"
3736
rand = { version = "0.9", features = ["small_rng"] }

eden/scm/lib/indexedlog/src/index.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ use byteorder::ByteOrder;
8989
use byteorder::LittleEndian;
9090
use byteorder::ReadBytesExt;
9191
use byteorder::WriteBytesExt;
92-
use fs2::FileExt as _;
9392
use minibytes::Bytes;
9493
use tracing::debug_span;
9594
use twox_hash::XxHash;
@@ -2469,7 +2468,7 @@ impl Index {
24692468

24702469
pub(crate) fn try_clone_internal(&self, copy_dirty: bool) -> crate::Result<Index> {
24712470
let file = match &self.file {
2472-
Some(f) => Some(f.duplicate().context(self.path(), "cannot duplicate")?),
2471+
Some(f) => Some(f.try_clone().context(self.path(), "cannot duplicate")?),
24732472
None => None,
24742473
};
24752474

0 commit comments

Comments
 (0)