|
|
|
|
@ -3,7 +3,6 @@
|
|
|
|
|
use std::io::Read;
|
|
|
|
|
use std::{
|
|
|
|
|
fs,
|
|
|
|
|
io::ErrorKind::*,
|
|
|
|
|
path::{Path, PathBuf},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -13,11 +12,7 @@ use walkdir::WalkDir;
|
|
|
|
|
use crate::exit_codes::EXIT_BAD_ARGUMENTS;
|
|
|
|
|
use crate::options::FileArgument;
|
|
|
|
|
|
|
|
|
|
pub fn read_files_or_die(
|
|
|
|
|
lhs_path: &FileArgument,
|
|
|
|
|
rhs_path: &FileArgument,
|
|
|
|
|
missing_as_empty: bool,
|
|
|
|
|
) -> (Vec<u8>, Vec<u8>) {
|
|
|
|
|
pub fn read_files_or_die(lhs_path: &FileArgument, rhs_path: &FileArgument) -> (Vec<u8>, Vec<u8>) {
|
|
|
|
|
let lhs_res = read_file_arg(lhs_path);
|
|
|
|
|
let rhs_res = read_file_arg(rhs_path);
|
|
|
|
|
|
|
|
|
|
@ -25,12 +20,6 @@ pub fn read_files_or_die(
|
|
|
|
|
// Both files exist, the happy case.
|
|
|
|
|
(Ok(lhs_src), Ok(rhs_src)) => (lhs_src, rhs_src),
|
|
|
|
|
|
|
|
|
|
// Proceed if we've been given two paths and only one
|
|
|
|
|
// exists. This is important for mercurial diffs when a file
|
|
|
|
|
// has been removed.
|
|
|
|
|
(Ok(lhs_src), Err(e)) if missing_as_empty && e.kind() == NotFound => (lhs_src, vec![]),
|
|
|
|
|
(Err(e), Ok(rhs_src)) if missing_as_empty && e.kind() == NotFound => (vec![], rhs_src),
|
|
|
|
|
|
|
|
|
|
(lhs_res, rhs_res) => {
|
|
|
|
|
// Something else went wrong. Print both errors
|
|
|
|
|
// encountered.
|
|
|
|
|
|