local_working_copy: import std::io for short
Some checks are pending
binaries / Build binary artifacts (linux-aarch64-gnu, ubuntu-24.04, aarch64-unknown-linux-gnu) (push) Waiting to run
binaries / Build binary artifacts (linux-aarch64-musl, ubuntu-24.04, aarch64-unknown-linux-musl) (push) Waiting to run
binaries / Build binary artifacts (linux-x86_64-gnu, ubuntu-24.04, x86_64-unknown-linux-gnu) (push) Waiting to run
binaries / Build binary artifacts (linux-x86_64-musl, ubuntu-24.04, x86_64-unknown-linux-musl) (push) Waiting to run
binaries / Build binary artifacts (macos-aarch64, macos-14, aarch64-apple-darwin) (push) Waiting to run
binaries / Build binary artifacts (macos-x86_64, macos-13, x86_64-apple-darwin) (push) Waiting to run
binaries / Build binary artifacts (win-x86_64, windows-2022, x86_64-pc-windows-msvc) (push) Waiting to run
nix / flake check (macos-14) (push) Waiting to run
nix / flake check (ubuntu-latest) (push) Waiting to run
build / build (, macos-13) (push) Waiting to run
build / build (, macos-14) (push) Waiting to run
build / build (, ubuntu-latest) (push) Waiting to run
build / build (, windows-latest) (push) Waiting to run
build / build (--all-features, ubuntu-latest) (push) Waiting to run
build / Build jj-lib without Git support (push) Waiting to run
build / Check protos (push) Waiting to run
build / Check formatting (push) Waiting to run
build / Check that MkDocs can build the docs (push) Waiting to run
build / Check that MkDocs can build the docs with Poetry 1.8 (push) Waiting to run
build / cargo-deny (advisories) (push) Waiting to run
build / cargo-deny (bans licenses sources) (push) Waiting to run
build / Clippy check (push) Waiting to run
Codespell / Codespell (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-latest) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run

This commit is contained in:
Yuya Nishihara 2024-10-22 20:34:40 +09:00
parent 153873a093
commit 8c0ab6af7a

View file

@ -22,6 +22,7 @@ use std::fs;
use std::fs::File;
use std::fs::Metadata;
use std::fs::OpenOptions;
use std::io;
use std::io::Read;
use std::io::Write;
use std::iter;
@ -523,25 +524,16 @@ struct DirectoryToVisit<'a> {
#[derive(Debug, Error)]
pub enum TreeStateError {
#[error("Reading tree state from {path}")]
ReadTreeState {
path: PathBuf,
source: std::io::Error,
},
ReadTreeState { path: PathBuf, source: io::Error },
#[error("Decoding tree state from {path}")]
DecodeTreeState {
path: PathBuf,
source: prost::DecodeError,
},
#[error("Writing tree state to temporary file {path}")]
WriteTreeState {
path: PathBuf,
source: std::io::Error,
},
WriteTreeState { path: PathBuf, source: io::Error },
#[error("Persisting tree state to file {path}")]
PersistTreeState {
path: PathBuf,
source: std::io::Error,
},
PersistTreeState { path: PathBuf, source: io::Error },
#[error("Filesystem monitor error")]
Fsmonitor(#[source] Box<dyn Error + Send + Sync>),
}
@ -599,7 +591,7 @@ impl TreeState {
) -> Result<TreeState, TreeStateError> {
let tree_state_path = state_path.join("tree_state");
let file = match File::open(&tree_state_path) {
Err(ref err) if err.kind() == std::io::ErrorKind::NotFound => {
Err(ref err) if err.kind() == io::ErrorKind::NotFound => {
return TreeState::init(store, working_copy_path, state_path);
}
Err(err) => {
@ -981,7 +973,7 @@ impl TreeState {
let disk_path = tracked_path.to_fs_path(&self.working_copy_path);
let metadata = match disk_path.symlink_metadata() {
Ok(metadata) => metadata,
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
Err(err) if err.kind() == io::ErrorKind::NotFound => {
continue;
}
Err(err) => {
@ -1265,7 +1257,7 @@ impl TreeState {
message: format!("Failed to open file {} for writing", disk_path.display()),
err: err.into(),
})?;
let size = std::io::copy(contents, &mut file).map_err(|err| CheckoutError::Other {
let size = io::copy(contents, &mut file).map_err(|err| CheckoutError::Other {
message: format!("Failed to write file {}", disk_path.display()),
err: err.into(),
})?;
@ -1557,7 +1549,7 @@ impl TreeState {
}
}
fn checkout_error_for_stat_error(err: std::io::Error, path: &Path) -> CheckoutError {
fn checkout_error_for_stat_error(err: io::Error, path: &Path) -> CheckoutError {
CheckoutError::Other {
message: format!("Failed to stat file {}", path.display()),
err: err.into(),