Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/utils/files.rs @ 52781:6183949219b2
rhg: implement rhg annotate
This initial implementation produces the same output as Python for all the files
I've tried, and is usually 1.5-9x faster. The algorithm is mostly the same, but
one key difference is that the Rust implementation only converts filelog
revisions to changelog revisions if they will actually appear in the output.
This does not support all the command line flags yet. In particular, --template,
--include, --exclude, --skip, and whitespace-related flags will cause fallback
to Python. Also, --rev 'wdir()' (often used by editor plugins) is not supported.
There is also no pager.
author | Mitchell Kember <mkember@janestreet.com> |
---|---|
date | Fri, 24 Jan 2025 12:01:12 -0500 |
parents | 94e2547e6f3d |
children |
line wrap: on
line diff
--- a/rust/hg-core/src/utils/files.rs Fri Jan 24 13:07:15 2025 -0500 +++ b/rust/hg-core/src/utils/files.rs Fri Jan 24 12:01:12 2025 -0500 @@ -333,6 +333,12 @@ .modified() } +/// Returns true if file content is considered to be binary (not text). +pub fn is_binary(content: &[u8]) -> bool { + // Matches binary() in utils/stringutil.py. + !content.is_empty() && memchr::memchr(b'\0', content).is_some() +} + #[cfg(test)] mod tests { use super::*;