--- a/rust/hg-core/src/matchers.rs Thu May 07 16:56:03 2020 -0400
+++ b/rust/hg-core/src/matchers.rs Thu May 07 23:52:08 2020 +0200
@@ -347,7 +347,9 @@
) -> PatternResult<impl Fn(&HgPath) -> bool + Sync> {
use std::io::Write;
- let mut escaped_bytes = vec![];
+ // The `regex` crate adds `.*` to the start and end of expressions if there
+ // are no anchors, so add the start anchor.
+ let mut escaped_bytes = vec![b'^', b'(', b'?', b':'];
for byte in pattern {
if *byte > 127 {
write!(escaped_bytes, "\\x{:x}", *byte).unwrap();
@@ -355,6 +357,7 @@
escaped_bytes.push(*byte);
}
}
+ escaped_bytes.push(b')');
// Avoid the cost of UTF8 checking
//