Show More
@@ -14,12 +14,15 b' use crate::{' | |||||
14 | matchers::Matcher, |
|
14 | matchers::Matcher, | |
15 | utils::{ |
|
15 | utils::{ | |
16 | files::HgMetadata, |
|
16 | files::HgMetadata, | |
17 | hg_path::{hg_path_to_path_buf, HgPath}, |
|
17 | hg_path::{ | |
|
18 | hg_path_to_path_buf, os_string_to_hg_path_buf, HgPath, HgPathBuf, | |||
|
19 | }, | |||
18 | }, |
|
20 | }, | |
19 | CopyMap, DirstateEntry, DirstateMap, EntryState, |
|
21 | CopyMap, DirstateEntry, DirstateMap, EntryState, | |
20 | }; |
|
22 | }; | |
21 | use rayon::prelude::*; |
|
23 | use rayon::prelude::*; | |
22 | use std::collections::HashSet; |
|
24 | use std::collections::HashSet; | |
|
25 | use std::fs::{read_dir, DirEntry}; | |||
23 | use std::path::Path; |
|
26 | use std::path::Path; | |
24 |
|
27 | |||
25 | /// Marker enum used to dispatch new status entries into the right collections. |
|
28 | /// Marker enum used to dispatch new status entries into the right collections. | |
@@ -48,6 +51,32 b' fn mod_compare(a: i32, b: i32) -> bool {' | |||||
48 | a & i32::max_value() != b & i32::max_value() |
|
51 | a & i32::max_value() != b & i32::max_value() | |
49 | } |
|
52 | } | |
50 |
|
53 | |||
|
54 | /// Return a sorted list containing information about the entries | |||
|
55 | /// in the directory. | |||
|
56 | /// | |||
|
57 | /// * `skip_dot_hg` - Return an empty vec if `path` contains a `.hg` directory | |||
|
58 | fn list_directory( | |||
|
59 | path: impl AsRef<Path>, | |||
|
60 | skip_dot_hg: bool, | |||
|
61 | ) -> std::io::Result<Vec<(HgPathBuf, DirEntry)>> { | |||
|
62 | let mut results = vec![]; | |||
|
63 | let entries = read_dir(path.as_ref())?; | |||
|
64 | ||||
|
65 | for entry in entries { | |||
|
66 | let entry = entry?; | |||
|
67 | let filename = os_string_to_hg_path_buf(entry.file_name())?; | |||
|
68 | let file_type = entry.file_type()?; | |||
|
69 | if skip_dot_hg && filename.as_bytes() == b".hg" && file_type.is_dir() { | |||
|
70 | return Ok(vec![]); | |||
|
71 | } else { | |||
|
72 | results.push((HgPathBuf::from(filename), entry)) | |||
|
73 | } | |||
|
74 | } | |||
|
75 | ||||
|
76 | results.sort_unstable_by_key(|e| e.0.clone()); | |||
|
77 | Ok(results) | |||
|
78 | } | |||
|
79 | ||||
51 | /// The file corresponding to the dirstate entry was found on the filesystem. |
|
80 | /// The file corresponding to the dirstate entry was found on the filesystem. | |
52 | fn dispatch_found( |
|
81 | fn dispatch_found( | |
53 | filename: impl AsRef<HgPath>, |
|
82 | filename: impl AsRef<HgPath>, |
General Comments 0
You need to be logged in to leave comments.
Login now