mirror of
https://github.com/martinvonz/jj.git
synced 2024-10-26 00:19:59 +00:00
merge_tools: remove implicit conversion of io::Error
Since ExternalToolError has non-unique io::Error variants, implicit conversion can be source of bugs.
This commit is contained in:
parent
36cc1fbfdd
commit
bcbb4f215c
1 changed files with 5 additions and 14 deletions
|
@ -68,7 +68,7 @@ pub enum ExternalToolError {
|
|||
exit_status: std::process::ExitStatus,
|
||||
},
|
||||
#[error("I/O error: {0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
Io(#[source] std::io::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
@ -109,17 +109,6 @@ pub enum ConflictResolveError {
|
|||
Backend(#[from] jj_lib::backend::BackendError),
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for DiffEditError {
|
||||
fn from(err: std::io::Error) -> Self {
|
||||
DiffEditError::ExternalTool(ExternalToolError::from(err))
|
||||
}
|
||||
}
|
||||
impl From<std::io::Error> for ConflictResolveError {
|
||||
fn from(err: std::io::Error) -> Self {
|
||||
ConflictResolveError::ExternalTool(ExternalToolError::from(err))
|
||||
}
|
||||
}
|
||||
|
||||
fn check_out(
|
||||
store: Arc<Store>,
|
||||
wc_dir: PathBuf,
|
||||
|
@ -244,7 +233,8 @@ pub fn run_mergetool(
|
|||
}));
|
||||
}
|
||||
|
||||
let output_file_contents: Vec<u8> = std::fs::read(paths.get("output").unwrap())?;
|
||||
let output_file_contents: Vec<u8> =
|
||||
std::fs::read(paths.get("output").unwrap()).map_err(ExternalToolError::Io)?;
|
||||
if output_file_contents.is_empty() || output_file_contents == initial_output_content {
|
||||
return Err(ConflictResolveError::EmptyOrUnchanged);
|
||||
}
|
||||
|
@ -510,7 +500,8 @@ fn editor_args_from_settings(
|
|||
writeln!(
|
||||
ui.hint(),
|
||||
"Using default editor '{default_editor}'; you can change this by setting {key}"
|
||||
)?;
|
||||
)
|
||||
.map_err(ExternalToolError::Io)?;
|
||||
Ok(default_editor.into())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue