diff --git a/rust/hg-core/src/utils/files.rs b/rust/hg-core/src/utils/files.rs --- a/rust/hg-core/src/utils/files.rs +++ b/rust/hg-core/src/utils/files.rs @@ -29,6 +29,14 @@ Path::new(os_str) } +// TODO: need to convert from WTF8 to MBCS bytes on Windows. +// that's why Vec is returned. +#[cfg(unix)] +pub fn get_bytes_from_path(path: impl AsRef) -> Vec { + use std::os::unix::ffi::OsStrExt; + path.as_ref().as_os_str().as_bytes().to_vec() +} + /// An iterator over repository path yielding itself and its ancestors. #[derive(Copy, Clone, Debug)] pub struct Ancestors<'a> { diff --git a/rust/hg-cpython/src/filepatterns.rs b/rust/hg-cpython/src/filepatterns.rs --- a/rust/hg-cpython/src/filepatterns.rs +++ b/rust/hg-cpython/src/filepatterns.rs @@ -68,7 +68,7 @@ .iter() .map(|(path, syn)| { ( - PyBytes::new(py, &path.to_string_lossy().as_bytes()), + PyBytes::new(py, &files::get_bytes_from_path(path)), PyBytes::new(py, syn), ) })