Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/revlog/file_io.rs @ 52294:645d247d4c75
rust-vfs: rename `open` to `open_write` and `open_read` to `open`
`open` being read *and* write is surprising because it differs from the
Rust stdlib where `std::fs::File::open` is read-only by default.
More importantly, writing is more dangerous than reading, so let's make it
more explicit.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Tue, 29 Oct 2024 12:03:55 +0100 |
parents | 8d35941689af |
children | 162f4801ad39 |
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/file_io.rs Tue Oct 29 11:41:27 2024 +0100 +++ b/rust/hg-core/src/revlog/file_io.rs Tue Oct 29 12:03:55 2024 +0100 @@ -172,9 +172,9 @@ let file = if create { vfs.create(filename.as_ref(), false)? } else if write { - vfs.open(filename.as_ref())? + vfs.open_write(filename.as_ref())? } else { - vfs.open_read(filename.as_ref())? + vfs.open(filename.as_ref())? }; Ok(Self { vfs, @@ -194,7 +194,7 @@ let mut file = if create { vfs.create(filename.as_ref(), false)? } else { - vfs.open(filename.as_ref())? + vfs.open_write(filename.as_ref())? }; let size = vfs.file_size(&file)?; let offset = file