Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
50682:2cc5de261d76 | 50683:d39ac3468ad4 |
---|---|
118 } | 118 } |
119 | 119 |
120 impl ConfiguredBlackbox<'_> { | 120 impl ConfiguredBlackbox<'_> { |
121 fn log(&self, date_time: &DateTime, message: &[u8]) { | 121 fn log(&self, date_time: &DateTime, message: &[u8]) { |
122 let date = format_bytes::Utf8(date_time.format(self.date_format)); | 122 let date = format_bytes::Utf8(date_time.format(self.date_format)); |
123 let user = users::get_current_username().map(get_bytes_from_os_str); | 123 let user = get_bytes_from_os_str(whoami::username_os()); |
124 let user = user.as_deref().unwrap_or(b"???"); | |
125 let rev = format_bytes::Utf8(match self.repo.dirstate_parents() { | 124 let rev = format_bytes::Utf8(match self.repo.dirstate_parents() { |
126 Ok(parents) if parents.p2 == hg::revlog::node::NULL_NODE => { | 125 Ok(parents) if parents.p2 == hg::revlog::node::NULL_NODE => { |
127 format!("{:x}", parents.p1) | 126 format!("{:x}", parents.p1) |
128 } | 127 } |
129 Ok(parents) => format!("{:x}+{:x}", parents.p1, parents.p2), | 128 Ok(parents) => format!("{:x}+{:x}", parents.p1, parents.p2), |