Show More
@@ -10,17 +10,13 b' use crate::ui::Ui;' | |||||
10 | use clap::{Arg, SubCommand}; |
|
10 | use clap::{Arg, SubCommand}; | |
11 | use hg; |
|
11 | use hg; | |
12 | use hg::dirstate_tree::dispatch::DirstateMapMethods; |
|
12 | use hg::dirstate_tree::dispatch::DirstateMapMethods; | |
13 |
use hg::errors:: |
|
13 | use hg::errors::HgError; | |
14 | use hg::manifest::Manifest; |
|
14 | use hg::manifest::Manifest; | |
15 | use hg::matchers::AlwaysMatcher; |
|
15 | use hg::matchers::AlwaysMatcher; | |
16 | use hg::repo::Repo; |
|
16 | use hg::repo::Repo; | |
17 | use hg::utils::hg_path::{hg_path_to_os_string, HgPath}; |
|
17 | use hg::utils::hg_path::{hg_path_to_os_string, HgPath}; | |
18 | use hg::{HgPathCow, StatusOptions}; |
|
18 | use hg::{HgPathCow, StatusOptions}; | |
19 | use log::{info, warn}; |
|
19 | use log::{info, warn}; | |
20 | use std::convert::TryInto; |
|
|||
21 | use std::fs; |
|
|||
22 | use std::io::BufReader; |
|
|||
23 | use std::io::Read; |
|
|||
24 |
|
20 | |||
25 | pub const HELP_TEXT: &str = " |
|
21 | pub const HELP_TEXT: &str = " | |
26 | Show changed files in the working directory |
|
22 | Show changed files in the working directory | |
@@ -279,26 +275,7 b' fn cat_file_is_modified(' | |||||
279 | })?; |
|
275 | })?; | |
280 | let contents_in_p1 = filelog_entry.data()?; |
|
276 | let contents_in_p1 = filelog_entry.data()?; | |
281 |
|
277 | |||
282 | let fs_path = repo |
|
278 | let fs_path = hg_path_to_os_string(hg_path).expect("HgPath conversion"); | |
283 |
|
|
279 | let fs_contents = repo.working_directory_vfs().read(fs_path)?; | |
284 | .join(hg_path_to_os_string(hg_path).expect("HgPath conversion")); |
|
280 | return Ok(contents_in_p1 == &*fs_contents); | |
285 | let hg_data_len: u64 = match contents_in_p1.len().try_into() { |
|
|||
286 | Ok(v) => v, |
|
|||
287 | Err(_) => { |
|
|||
288 | // conversion of data length to u64 failed, |
|
|||
289 | // good luck for any file to have this content |
|
|||
290 | return Ok(true); |
|
|||
291 | } |
|
|||
292 | }; |
|
|||
293 | let fobj = fs::File::open(&fs_path).when_reading_file(&fs_path)?; |
|
|||
294 | if fobj.metadata().when_reading_file(&fs_path)?.len() != hg_data_len { |
|
|||
295 | return Ok(true); |
|
|||
296 | } |
|
|||
297 | for (fs_byte, &hg_byte) in BufReader::new(fobj).bytes().zip(contents_in_p1) |
|
|||
298 | { |
|
|||
299 | if fs_byte.when_reading_file(&fs_path)? != hg_byte { |
|
|||
300 | return Ok(true); |
|
|||
301 | } |
|
|||
302 | } |
|
|||
303 | Ok(false) |
|
|||
304 | } |
|
281 | } |
General Comments 0
You need to be logged in to leave comments.
Login now