Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/utils/files.rs @ 42850:b1b984f9c01d
rust-utils: add normalize_case util to mirror Python one
While we still don't handle filenames properly cross-platform, this at least
sticks closer to the Python behavior.
Differential Revision: https://phab.mercurial-scm.org/D6756
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Thu, 22 Aug 2019 14:31:07 +0200 |
parents | 4b3b27d567d5 |
children | 7a01778bc7b7 |
line wrap: on
line diff
--- a/rust/hg-core/src/utils/files.rs Wed Aug 28 08:16:58 2019 -0400 +++ b/rust/hg-core/src/utils/files.rs Thu Aug 22 14:31:07 2019 +0200 @@ -71,6 +71,15 @@ dirs } +/// TODO improve handling of utf8 file names. Our overall strategy for +/// filenames has to be revisited anyway, since Windows is UTF-16. +pub fn normalize_case(bytes: &[u8]) -> Vec<u8> { + #[cfg(windows)] // NTFS compares via upper() + return bytes.to_ascii_uppercase(); + #[cfg(unix)] + bytes.to_ascii_lowercase() +} + #[cfg(test)] mod tests { #[test]