Show More
@@ -20,7 +20,7 b' use std::{borrow::Cow, fmt};' | |||
|
20 | 20 | |
|
21 | 21 | /// Wrong type of file from a `BadMatch` |
|
22 | 22 | /// Note: a lot of those don't exist on all platforms. |
|
23 | #[derive(Debug, Copy, Clone)] | |
|
23 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] | |
|
24 | 24 | pub enum BadType { |
|
25 | 25 | CharacterDevice, |
|
26 | 26 | BlockDevice, |
@@ -14,6 +14,7 b' use crate::utils::files::get_bytes_from_' | |||
|
14 | 14 | use crate::utils::files::get_path_from_bytes; |
|
15 | 15 | use crate::utils::hg_path::HgPath; |
|
16 | 16 | use crate::BadMatch; |
|
17 | use crate::BadType; | |
|
17 | 18 | use crate::DirstateStatus; |
|
18 | 19 | use crate::HgPathCow; |
|
19 | 20 | use crate::PatternFileWarning; |
@@ -24,6 +25,7 b' use rayon::prelude::*;' | |||
|
24 | 25 | use sha1::{Digest, Sha1}; |
|
25 | 26 | use std::borrow::Cow; |
|
26 | 27 | use std::io; |
|
28 | use std::os::unix::prelude::FileTypeExt; | |
|
27 | 29 | use std::path::Path; |
|
28 | 30 | use std::path::PathBuf; |
|
29 | 31 | use std::sync::Mutex; |
@@ -388,11 +390,7 b" impl<'a, 'tree, 'on_disk> StatusCommon<'" | |||
|
388 | 390 | )); |
|
389 | 391 | match std::fs::symlink_metadata(&fs_path) { |
|
390 | 392 | Ok(fs_metadata) => { |
|
391 | let file_type = | |
|
392 | match fs_metadata.file_type().try_into() { | |
|
393 | Ok(file_type) => file_type, | |
|
394 | Err(_) => return Ok(()), | |
|
395 | }; | |
|
393 | let file_type = fs_metadata.file_type().into(); | |
|
396 | 394 | let entry = DirEntry { |
|
397 | 395 | hg_path: Cow::Borrowed( |
|
398 | 396 | dirstate_node |
@@ -513,6 +511,15 b" impl<'a, 'tree, 'on_disk> StatusCommon<'" | |||
|
513 | 511 | // replaced by a directory or something else. |
|
514 | 512 | self.mark_removed_or_deleted_if_file(&dirstate_node)?; |
|
515 | 513 | } |
|
514 | if let Some(bad_type) = fs_entry.is_bad() { | |
|
515 | if self.matcher.exact_match(hg_path) { | |
|
516 | let path = dirstate_node.full_path(self.dmap.on_disk)?; | |
|
517 | self.outcome.lock().unwrap().bad.push(( | |
|
518 | path.to_owned().into(), | |
|
519 | BadMatch::BadType(bad_type), | |
|
520 | )) | |
|
521 | } | |
|
522 | } | |
|
516 | 523 | if fs_entry.is_dir() { |
|
517 | 524 | if self.options.collect_traversed_dirs { |
|
518 | 525 | self.outcome |
@@ -866,21 +873,27 b' enum FakeFileType {' | |||
|
866 | 873 | File, |
|
867 | 874 | Directory, |
|
868 | 875 | Symlink, |
|
876 | BadType(BadType), | |
|
869 | 877 | } |
|
870 | 878 | |
|
871 |
impl |
|
|
872 | type Error = (); | |
|
873 | ||
|
874 | fn try_from(f: std::fs::FileType) -> Result<Self, Self::Error> { | |
|
879 | impl From<std::fs::FileType> for FakeFileType { | |
|
880 | fn from(f: std::fs::FileType) -> Self { | |
|
875 | 881 | if f.is_dir() { |
|
876 |
|
|
|
882 | Self::Directory | |
|
877 | 883 | } else if f.is_file() { |
|
878 |
|
|
|
884 | Self::File | |
|
879 | 885 | } else if f.is_symlink() { |
|
880 |
|
|
|
886 | Self::Symlink | |
|
887 | } else if f.is_fifo() { | |
|
888 | Self::BadType(BadType::FIFO) | |
|
889 | } else if f.is_block_device() { | |
|
890 | Self::BadType(BadType::BlockDevice) | |
|
891 | } else if f.is_char_device() { | |
|
892 | Self::BadType(BadType::CharacterDevice) | |
|
893 | } else if f.is_socket() { | |
|
894 | Self::BadType(BadType::Socket) | |
|
881 | 895 | } else { |
|
882 | // Things like FIFO etc. | |
|
883 | Err(()) | |
|
896 | Self::BadType(BadType::Unknown) | |
|
884 | 897 | } |
|
885 | 898 | } |
|
886 | 899 | } |
@@ -942,10 +955,7 b" impl<'a> DirEntry<'a> {" | |||
|
942 | 955 | }; |
|
943 | 956 | let filename = |
|
944 | 957 | Cow::Owned(get_bytes_from_os_string(file_name).into()); |
|
945 |
let file_type = |
|
|
946 | Ok(file_type) => file_type, | |
|
947 | Err(_) => continue, | |
|
948 | }; | |
|
958 | let file_type = FakeFileType::from(file_type); | |
|
949 | 959 | results.push(DirEntry { |
|
950 | 960 | hg_path: filename, |
|
951 | 961 | fs_path: Cow::Owned(full_path.to_path_buf()), |
@@ -974,6 +984,13 b" impl<'a> DirEntry<'a> {" | |||
|
974 | 984 | fn is_symlink(&self) -> bool { |
|
975 | 985 | self.file_type == FakeFileType::Symlink |
|
976 | 986 | } |
|
987 | ||
|
988 | fn is_bad(&self) -> Option<BadType> { | |
|
989 | match self.file_type { | |
|
990 | FakeFileType::BadType(ty) => Some(ty), | |
|
991 | _ => None, | |
|
992 | } | |
|
993 | } | |
|
977 | 994 | } |
|
978 | 995 | |
|
979 | 996 | /// Return the `mtime` of a temporary file newly-created in the `.hg` directory |
General Comments 0
You need to be logged in to leave comments.
Login now