Skip to content
Snippets Groups Projects
  1. Dec 13, 2024
    • Arseniy Alekseyev's avatar
      rust-hgignore: add a scripting command to print the hgignore regexp · b89c934e
      Arseniy Alekseyev authored
      Add a command `script::hgignore --print-re` to print the
      hgignore regexp.
      
      One complication is that the `rootfilesin`-only matcher doesn't use a
      regular expression, and the existing converts it to something that's
      not a regular expression.
      
      We add code to handle that case.
      
      Since this command is now sufficient to generate a tidy-looking
      regexp for scripting, this frees up the "debug" command to report
      the internal regexp used by the regex engine, so we make that
      change too.
      b89c934e
  2. Dec 06, 2024
    • Arseniy Alekseyev's avatar
      rust-ignore: construct regex Hir object directly, avoiding large regex string · 1866119c
      Arseniy Alekseyev authored
      Rework how we convert patterns to regexes in rust.
      Instead of going patterns -> string -> Regex, which is slow and causes
      some correctness issues, build a structured regex_syntax::hir::Hir value,
      which is faster and it also prevents surprising regex escape.
      
      This change makes the time of `build_regex_match` go from ~70-80ms
      to ~40ms in my testing (for a large hgignore).
      
      The bug I mentioned involves regex patterns that "escape" their
      intended scope. For example, a sequence of hgignore regexp patterns like
      this would previously lead to surprising behavior:
      
          foo(?:
          bar
          baz
          )
      
      this matches foobar and foobaz, and doesn't match bar and baz.
      
      The new behavior is to report a pattern parse error
      The Python hg also has this bug, so this bugfix
      not really helping much, but it's probably better to
      fall back to real Python bugs than to simulate them.
      1866119c
Loading