Show More
@@ -9,6 +9,7 b' use crate::dirstate_tree::dirstate_map::' | |||||
9 | use crate::dirstate_tree::on_disk::DirstateV2ParseError; |
|
9 | use crate::dirstate_tree::on_disk::DirstateV2ParseError; | |
10 | use crate::matchers::get_ignore_function; |
|
10 | use crate::matchers::get_ignore_function; | |
11 | use crate::matchers::{Matcher, VisitChildrenSet}; |
|
11 | use crate::matchers::{Matcher, VisitChildrenSet}; | |
|
12 | use crate::utils::files::filesystem_now; | |||
12 | use crate::utils::files::get_bytes_from_os_string; |
|
13 | use crate::utils::files::get_bytes_from_os_string; | |
13 | use crate::utils::files::get_bytes_from_path; |
|
14 | use crate::utils::files::get_bytes_from_path; | |
14 | use crate::utils::files::get_path_from_bytes; |
|
15 | use crate::utils::files::get_path_from_bytes; | |
@@ -30,7 +31,6 b' use std::os::unix::prelude::FileTypeExt;' | |||||
30 | use std::path::Path; |
|
31 | use std::path::Path; | |
31 | use std::path::PathBuf; |
|
32 | use std::path::PathBuf; | |
32 | use std::sync::Mutex; |
|
33 | use std::sync::Mutex; | |
33 | use std::time::SystemTime; |
|
|||
34 |
|
34 | |||
35 | /// Returns the status of the working directory compared to its parent |
|
35 | /// Returns the status of the working directory compared to its parent | |
36 | /// changeset. |
|
36 | /// changeset. | |
@@ -1034,22 +1034,3 b" impl<'a> DirEntry<'a> {" | |||||
1034 | } |
|
1034 | } | |
1035 | } |
|
1035 | } | |
1036 | } |
|
1036 | } | |
1037 |
|
||||
1038 | /// Return the `mtime` of a temporary file newly-created in the `.hg` directory |
|
|||
1039 | /// of the give repository. |
|
|||
1040 | /// |
|
|||
1041 | /// This is similar to `SystemTime::now()`, with the result truncated to the |
|
|||
1042 | /// same time resolution as other files’ modification times. Using `.hg` |
|
|||
1043 | /// instead of the system’s default temporary directory (such as `/tmp`) makes |
|
|||
1044 | /// it more likely the temporary file is in the same disk partition as contents |
|
|||
1045 | /// of the working directory, which can matter since different filesystems may |
|
|||
1046 | /// store timestamps with different resolutions. |
|
|||
1047 | /// |
|
|||
1048 | /// This may fail, typically if we lack write permissions. In that case we |
|
|||
1049 | /// should continue the `status()` algoritm anyway and consider the current |
|
|||
1050 | /// date/time to be unknown. |
|
|||
1051 | fn filesystem_now(repo_root: &Path) -> Result<SystemTime, io::Error> { |
|
|||
1052 | tempfile::tempfile_in(repo_root.join(".hg"))? |
|
|||
1053 | .metadata()? |
|
|||
1054 | .modified() |
|
|||
1055 | } |
|
@@ -16,11 +16,15 b' use crate::utils::{' | |||||
16 | }; |
|
16 | }; | |
17 | use lazy_static::lazy_static; |
|
17 | use lazy_static::lazy_static; | |
18 | use same_file::is_same_file; |
|
18 | use same_file::is_same_file; | |
19 | use std::borrow::{Cow, ToOwned}; |
|
|||
20 | use std::ffi::{OsStr, OsString}; |
|
19 | use std::ffi::{OsStr, OsString}; | |
21 | use std::iter::FusedIterator; |
|
20 | use std::iter::FusedIterator; | |
22 | use std::ops::Deref; |
|
21 | use std::ops::Deref; | |
23 | use std::path::{Path, PathBuf}; |
|
22 | use std::path::{Path, PathBuf}; | |
|
23 | use std::{ | |||
|
24 | borrow::{Cow, ToOwned}, | |||
|
25 | io, | |||
|
26 | time::SystemTime, | |||
|
27 | }; | |||
24 |
|
28 | |||
25 | pub fn get_os_str_from_bytes(bytes: &[u8]) -> &OsStr { |
|
29 | pub fn get_os_str_from_bytes(bytes: &[u8]) -> &OsStr { | |
26 | let os_str; |
|
30 | let os_str; | |
@@ -306,6 +310,25 b' pub fn relativize_path(path: &HgPath, cw' | |||||
306 | } |
|
310 | } | |
307 | } |
|
311 | } | |
308 |
|
312 | |||
|
313 | /// Return the `mtime` of a temporary file newly-created in the `.hg` directory | |||
|
314 | /// of the give repository. | |||
|
315 | /// | |||
|
316 | /// This is similar to `SystemTime::now()`, with the result truncated to the | |||
|
317 | /// same time resolution as other files’ modification times. Using `.hg` | |||
|
318 | /// instead of the system’s default temporary directory (such as `/tmp`) makes | |||
|
319 | /// it more likely the temporary file is in the same disk partition as contents | |||
|
320 | /// of the working directory, which can matter since different filesystems may | |||
|
321 | /// store timestamps with different resolutions. | |||
|
322 | /// | |||
|
323 | /// This may fail, typically if we lack write permissions. In that case we | |||
|
324 | /// should continue the `status()` algoritm anyway and consider the current | |||
|
325 | /// date/time to be unknown. | |||
|
326 | pub fn filesystem_now(repo_root: &Path) -> Result<SystemTime, io::Error> { | |||
|
327 | tempfile::tempfile_in(repo_root.join(".hg"))? | |||
|
328 | .metadata()? | |||
|
329 | .modified() | |||
|
330 | } | |||
|
331 | ||||
309 | #[cfg(test)] |
|
332 | #[cfg(test)] | |
310 | mod tests { |
|
333 | mod tests { | |
311 | use super::*; |
|
334 | use super::*; |
General Comments 0
You need to be logged in to leave comments.
Login now