changeset 50859:2b4bcdc948e7

rust: don't escape spaces in regex Spaces are not in fact a regex special character, and escaping them is not correct.
author Spencer Baugh <sbaugh@janestreet.com>
date Wed, 02 Aug 2023 09:59:49 -0400
parents df6dfad5009a
children f50e71fdfcb4
files rust/hg-core/src/filepatterns.rs
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/filepatterns.rs	Wed Aug 02 10:09:23 2023 -0400
+++ b/rust/hg-core/src/filepatterns.rs	Wed Aug 02 09:59:49 2023 -0400
@@ -24,7 +24,7 @@
 lazy_static! {
     static ref RE_ESCAPE: Vec<Vec<u8>> = {
         let mut v: Vec<Vec<u8>> = (0..=255).map(|byte| vec![byte]).collect();
-        let to_escape = b"()[]{}?*+-|^$\\.&~# \t\n\r\x0b\x0c";
+        let to_escape = b"()[]{}?*+-|^$\\.&~#\t\n\r\x0b\x0c";
         for byte in to_escape {
             v[*byte as usize].insert(0, b'\\');
         }
@@ -641,8 +641,8 @@
         assert_eq!(escape_pattern(untouched), untouched.to_vec());
         // All escape codes
         assert_eq!(
-            escape_pattern(br#"()[]{}?*+-|^$\\.&~# \t\n\r\v\f"#),
-            br#"\(\)\[\]\{\}\?\*\+\-\|\^\$\\\\\.\&\~\#\ \\t\\n\\r\\v\\f"#
+            escape_pattern(br#"()[]{}?*+-|^$\\.&~#\t\n\r\v\f"#),
+            br#"\(\)\[\]\{\}\?\*\+\-\|\^\$\\\\\.\&\~\#\\t\\n\\r\\v\\f"#
                 .to_vec()
         );
     }