Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/pre_regex.rs @ 52557:b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
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.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Fri, 13 Dec 2024 15:05:37 +0000 |
parents | 1866119cbad7 |
children |
comparison
equal
deleted
inserted
replaced
52556:1866119cbad7 | 52557:b89c934e6269 |
---|---|
17 | 17 |
18 pub fn escape_char_for_re(c: u8) -> &'static [u8] { | 18 pub fn escape_char_for_re(c: u8) -> &'static [u8] { |
19 &RE_ESCAPE[c as usize] | 19 &RE_ESCAPE[c as usize] |
20 } | 20 } |
21 | 21 |
22 /// An intermediate regular expression representation, that can be used | |
23 /// both to compile down to a `Regex` for matching, or converted to | |
24 /// a string directly for diagnostics. | |
22 #[derive(Debug, Clone)] | 25 #[derive(Debug, Clone)] |
23 pub enum PreRegex { | 26 pub enum PreRegex { |
24 Empty, | 27 Empty, |
25 Dot, | 28 Dot, |
26 DotStar, | 29 DotStar, |