Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/dirstate_tree/status.rs @ 52030:b55f653a0b34
rust-utils: move the `filesystem_now` function to a util
This is going to be useful for an upcoming `hg update` fastpath.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Mon, 30 Sep 2024 17:45:10 +0200 |
parents | 3876d4c6c79e |
children | 644c696b6c18 |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/status.rs Mon Sep 30 17:43:51 2024 +0200 +++ b/rust/hg-core/src/dirstate_tree/status.rs Mon Sep 30 17:45:10 2024 +0200 @@ -9,6 +9,7 @@ use crate::dirstate_tree::on_disk::DirstateV2ParseError; use crate::matchers::get_ignore_function; use crate::matchers::{Matcher, VisitChildrenSet}; +use crate::utils::files::filesystem_now; use crate::utils::files::get_bytes_from_os_string; use crate::utils::files::get_bytes_from_path; use crate::utils::files::get_path_from_bytes; @@ -30,7 +31,6 @@ use std::path::Path; use std::path::PathBuf; use std::sync::Mutex; -use std::time::SystemTime; /// Returns the status of the working directory compared to its parent /// changeset. @@ -1034,22 +1034,3 @@ } } } - -/// Return the `mtime` of a temporary file newly-created in the `.hg` directory -/// of the give repository. -/// -/// This is similar to `SystemTime::now()`, with the result truncated to the -/// same time resolution as other files’ modification times. Using `.hg` -/// instead of the system’s default temporary directory (such as `/tmp`) makes -/// it more likely the temporary file is in the same disk partition as contents -/// of the working directory, which can matter since different filesystems may -/// store timestamps with different resolutions. -/// -/// This may fail, typically if we lack write permissions. In that case we -/// should continue the `status()` algoritm anyway and consider the current -/// date/time to be unknown. -fn filesystem_now(repo_root: &Path) -> Result<SystemTime, io::Error> { - tempfile::tempfile_in(repo_root.join(".hg"))? - .metadata()? - .modified() -}