diff rust/rhg/src/blackbox.rs @ 50683:d39ac3468ad4

rust-dependencies: switch from `users` to `whoami` `users` is unmaintained, with the maintainer apparently MIA. `whoami` is a popular crate that does simple wrapping of platform-specific calls. This makes the overhead from using `blackbox` lower. It used to be up 10ms on slower hardware for both calls, now down to <1ms which is always good.
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 13 Jun 2023 14:35:36 +0200
parents 137a93125902
children 7f8f6fe13fa9
line wrap: on
line diff
--- a/rust/rhg/src/blackbox.rs	Mon Jun 12 23:41:28 2023 +0200
+++ b/rust/rhg/src/blackbox.rs	Tue Jun 13 14:35:36 2023 +0200
@@ -120,8 +120,7 @@
 impl ConfiguredBlackbox<'_> {
     fn log(&self, date_time: &DateTime, message: &[u8]) {
         let date = format_bytes::Utf8(date_time.format(self.date_format));
-        let user = users::get_current_username().map(get_bytes_from_os_str);
-        let user = user.as_deref().unwrap_or(b"???");
+        let user = get_bytes_from_os_str(whoami::username_os());
         let rev = format_bytes::Utf8(match self.repo.dirstate_parents() {
             Ok(parents) if parents.p2 == hg::revlog::node::NULL_NODE => {
                 format!("{:x}", parents.p1)