##// END OF EJS Templates
rust: remove support for `re2`...
Raphaël Gomès -
r45406:9f96beb9 default
parent child Browse files
Show More
@@ -1650,13 +1650,6 b' def debuginstall(ui, **opts):'
1650 fm.plain(_(b'checking "re2" regexp engine (%s)\n') % re2)
1650 fm.plain(_(b'checking "re2" regexp engine (%s)\n') % re2)
1651 fm.data(re2=bool(util._re2))
1651 fm.data(re2=bool(util._re2))
1652
1652
1653 rust_debug_mod = policy.importrust("debug")
1654 if rust_debug_mod is not None:
1655 re2_rust = b'installed' if rust_debug_mod.re2_installed else b'missing'
1656
1657 msg = b'checking "re2" regexp engine Rust bindings (%s)\n'
1658 fm.plain(_(msg % re2_rust))
1659
1660 # templates
1653 # templates
1661 p = templater.templatepaths()
1654 p = templater.templatepaths()
1662 fm.write(b'templatedirs', b'checking templates (%s)...\n', b' '.join(p))
1655 fm.write(b'templatedirs', b'checking templates (%s)...\n', b' '.join(p))
@@ -42,11 +42,6 b' version = "1.3.4"'
42 source = "registry+https://github.com/rust-lang/crates.io-index"
42 source = "registry+https://github.com/rust-lang/crates.io-index"
43
43
44 [[package]]
44 [[package]]
45 name = "cc"
46 version = "1.0.50"
47 source = "registry+https://github.com/rust-lang/crates.io-index"
48
49 [[package]]
50 name = "cfg-if"
45 name = "cfg-if"
51 version = "0.1.10"
46 version = "0.1.10"
52 source = "registry+https://github.com/rust-lang/crates.io-index"
47 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -208,12 +203,10 b' name = "hg-core"'
208 version = "0.1.0"
203 version = "0.1.0"
209 dependencies = [
204 dependencies = [
210 "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
205 "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
211 "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
212 "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
206 "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
213 "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
207 "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
214 "hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
208 "hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
215 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
209 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
216 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
217 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
210 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
218 "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
211 "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
219 "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
212 "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -655,7 +648,6 b' source = "registry+https://github.com/ru'
655 "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
648 "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
656 "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
649 "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
657 "checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
650 "checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
658 "checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
659 "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
651 "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
660 "checksum chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2"
652 "checksum chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2"
661 "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
653 "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
@@ -36,36 +36,6 b' extension will be used by default unless'
36 One day we may use this environment variable to switch to new experimental
36 One day we may use this environment variable to switch to new experimental
37 binding crates like a hypothetical ``HGWITHRUSTEXT=hpy``.
37 binding crates like a hypothetical ``HGWITHRUSTEXT=hpy``.
38
38
39 Using the fastest ``hg status``
40 -------------------------------
41
42 The code for ``hg status`` needs to conform to ``.hgignore`` rules, which are
43 all translated into regex.
44
45 In the first version, for compatibility and ease of development reasons, the
46 Re2 regex engine was chosen until we figured out if the ``regex`` crate had
47 similar enough behavior.
48
49 Now that that work has been done, the default behavior is to use the ``regex``
50 crate, that provides a significant performance boost compared to the standard
51 Python + C path in many commands such as ``status``, ``diff`` and ``commit``,
52
53 However, the ``Re2`` path remains slightly faster for our use cases and remains
54 a better option for getting the most speed out of your Mercurial.
55
56 If you want to use ``Re2``, you need to install ``Re2`` following Google's
57 guidelines: https://github.com/google/re2/wiki/Install.
58 Then, use ``HG_RUST_FEATURES=with-re2`` and
59 ``HG_RE2_PATH=system|<path to your re2 install>`` when building ``hg`` to
60 signal the use of Re2. Using the local path instead of the "system" RE2 links
61 it statically.
62
63 For example::
64
65 $ HG_RUST_FEATURES=with-re2 HG_RE2_PATH=system make PURE=--rust
66 $ # OR
67 $ HG_RUST_FEATURES=with-re2 HG_RE2_PATH=/path/to/re2 make PURE=--rust
68
69 Developing Rust
39 Developing Rust
70 ===============
40 ===============
71
41
@@ -114,14 +84,3 b' To format the entire Rust workspace::'
114 $ cargo +nightly fmt
84 $ cargo +nightly fmt
115
85
116 This requires you to have the nightly toolchain installed.
86 This requires you to have the nightly toolchain installed.
117
118 Additional features
119 -------------------
120
121 As mentioned in the section about ``hg status``, code paths using ``re2`` are
122 opt-in.
123
124 For example::
125
126 $ cargo check --features with-re2
127
@@ -4,7 +4,6 b' version = "0.1.0"'
4 authors = ["Georges Racinet <gracinet@anybox.fr>"]
4 authors = ["Georges Racinet <gracinet@anybox.fr>"]
5 description = "Mercurial pure Rust core library, with no assumption on Python bindings (FFI)"
5 description = "Mercurial pure Rust core library, with no assumption on Python bindings (FFI)"
6 edition = "2018"
6 edition = "2018"
7 build = "build.rs"
8
7
9 [lib]
8 [lib]
10 name = "hg"
9 name = "hg"
@@ -13,7 +12,6 b' name = "hg"'
13 byteorder = "1.3.4"
12 byteorder = "1.3.4"
14 hex = "0.4.2"
13 hex = "0.4.2"
15 lazy_static = "1.4.0"
14 lazy_static = "1.4.0"
16 libc = { version = "0.2.66", optional = true }
17 memchr = "2.3.3"
15 memchr = "2.3.3"
18 rand = "0.7.3"
16 rand = "0.7.3"
19 rand_pcg = "0.2.1"
17 rand_pcg = "0.2.1"
@@ -31,10 +29,3 b' clap = "*"'
31 memmap = "0.7.0"
29 memmap = "0.7.0"
32 pretty_assertions = "0.6.1"
30 pretty_assertions = "0.6.1"
33 tempfile = "3.1.0"
31 tempfile = "3.1.0"
34
35 [build-dependencies]
36 cc = { version = "1.0.48", optional = true }
37
38 [features]
39 default = []
40 with-re2 = ["cc", "libc"]
@@ -23,8 +23,6 b' mod filepatterns;'
23 pub mod matchers;
23 pub mod matchers;
24 pub mod revlog;
24 pub mod revlog;
25 pub use revlog::*;
25 pub use revlog::*;
26 #[cfg(feature = "with-re2")]
27 pub mod re2;
28 pub mod utils;
26 pub mod utils;
29
27
30 // Remove this to see (potential) non-artificial compile failures. MacOS
28 // Remove this to see (potential) non-artificial compile failures. MacOS
@@ -141,9 +139,6 b' pub enum PatternError {'
141 /// Needed a pattern that can be turned into a regex but got one that
139 /// Needed a pattern that can be turned into a regex but got one that
142 /// can't. This should only happen through programmer error.
140 /// can't. This should only happen through programmer error.
143 NonRegexPattern(IgnorePattern),
141 NonRegexPattern(IgnorePattern),
144 /// This is temporary, see `re2/mod.rs`.
145 /// This will cause a fallback to Python.
146 Re2NotInstalled,
147 }
142 }
148
143
149 impl ToString for PatternError {
144 impl ToString for PatternError {
@@ -166,10 +161,6 b' impl ToString for PatternError {'
166 PatternError::NonRegexPattern(pattern) => {
161 PatternError::NonRegexPattern(pattern) => {
167 format!("'{:?}' cannot be turned into a regex", pattern)
162 format!("'{:?}' cannot be turned into a regex", pattern)
168 }
163 }
169 PatternError::Re2NotInstalled => {
170 "Re2 is not installed, cannot use regex functionality."
171 .to_string()
172 }
173 }
164 }
174 }
165 }
175 }
166 }
@@ -7,8 +7,6 b''
7
7
8 //! Structs and types for matching files and directories.
8 //! Structs and types for matching files and directories.
9
9
10 #[cfg(feature = "with-re2")]
11 use crate::re2::Re2;
12 use crate::{
10 use crate::{
13 dirstate::dirs_multiset::DirsChildrenMultiset,
11 dirstate::dirs_multiset::DirsChildrenMultiset,
14 filepatterns::{
12 filepatterns::{
@@ -239,29 +237,24 b" impl<'a> Matcher for FileMatcher<'a> {"
239 }
237 }
240
238
241 /// Matches files that are included in the ignore rules.
239 /// Matches files that are included in the ignore rules.
242 #[cfg_attr(
240 /// ```
243 feature = "with-re2",
241 /// use hg::{
244 doc = r##"
242 /// matchers::{IncludeMatcher, Matcher},
245 ```
243 /// IgnorePattern,
246 use hg::{
244 /// PatternSyntax,
247 matchers::{IncludeMatcher, Matcher},
245 /// utils::hg_path::HgPath
248 IgnorePattern,
246 /// };
249 PatternSyntax,
247 /// use std::path::Path;
250 utils::hg_path::HgPath
248 /// ///
251 };
249 /// let ignore_patterns =
252 use std::path::Path;
250 /// vec![IgnorePattern::new(PatternSyntax::RootGlob, b"this*", Path::new(""))];
253 ///
251 /// let (matcher, _) = IncludeMatcher::new(ignore_patterns, "").unwrap();
254 let ignore_patterns =
252 /// ///
255 vec![IgnorePattern::new(PatternSyntax::RootGlob, b"this*", Path::new(""))];
253 /// assert_eq!(matcher.matches(HgPath::new(b"testing")), false);
256 let (matcher, _) = IncludeMatcher::new(ignore_patterns, "").unwrap();
254 /// assert_eq!(matcher.matches(HgPath::new(b"this should work")), true);
257 ///
255 /// assert_eq!(matcher.matches(HgPath::new(b"this also")), true);
258 assert_eq!(matcher.matches(HgPath::new(b"testing")), false);
256 /// assert_eq!(matcher.matches(HgPath::new(b"but not this")), false);
259 assert_eq!(matcher.matches(HgPath::new(b"this should work")), true);
257 /// ```
260 assert_eq!(matcher.matches(HgPath::new(b"this also")), true);
261 assert_eq!(matcher.matches(HgPath::new(b"but not this")), false);
262 ```
263 "##
264 )]
265 pub struct IncludeMatcher<'a> {
258 pub struct IncludeMatcher<'a> {
266 patterns: Vec<u8>,
259 patterns: Vec<u8>,
267 match_fn: Box<dyn for<'r> Fn(&'r HgPath) -> bool + 'a + Sync>,
260 match_fn: Box<dyn for<'r> Fn(&'r HgPath) -> bool + 'a + Sync>,
@@ -319,22 +312,6 b" impl<'a> Matcher for IncludeMatcher<'a> "
319 }
312 }
320 }
313 }
321
314
322 #[cfg(feature = "with-re2")]
323 /// Returns a function that matches an `HgPath` against the given regex
324 /// pattern.
325 ///
326 /// This can fail when the pattern is invalid or not supported by the
327 /// underlying engine `Re2`, for instance anything with back-references.
328 #[timed]
329 fn re_matcher(
330 pattern: &[u8],
331 ) -> PatternResult<impl Fn(&HgPath) -> bool + Sync> {
332 let regex = Re2::new(pattern);
333 let regex = regex.map_err(|e| PatternError::UnsupportedSyntax(e))?;
334 Ok(move |path: &HgPath| regex.is_match(path.as_bytes()))
335 }
336
337 #[cfg(not(feature = "with-re2"))]
338 /// Returns a function that matches an `HgPath` against the given regex
315 /// Returns a function that matches an `HgPath` against the given regex
339 /// pattern.
316 /// pattern.
340 ///
317 ///
@@ -844,7 +821,6 b' mod tests {'
844 );
821 );
845 }
822 }
846
823
847 #[cfg(feature = "with-re2")]
848 #[test]
824 #[test]
849 fn test_includematcher() {
825 fn test_includematcher() {
850 // VisitchildrensetPrefix
826 // VisitchildrensetPrefix
@@ -10,7 +10,6 b' crate-type = ["cdylib"]'
10
10
11 [features]
11 [features]
12 default = ["python27"]
12 default = ["python27"]
13 with-re2 = ["hg-core/with-re2"]
14
13
15 # Features to build an extension module:
14 # Features to build an extension module:
16 python27 = ["cpython/python27-sys", "cpython/extension-module-2-7"]
15 python27 = ["cpython/python27-sys", "cpython/extension-module-2-7"]
@@ -16,8 +16,6 b' pub fn init_module(py: Python, package: '
16 m.add(py, "__package__", package)?;
16 m.add(py, "__package__", package)?;
17 m.add(py, "__doc__", "Rust debugging information")?;
17 m.add(py, "__doc__", "Rust debugging information")?;
18
18
19 m.add(py, "re2_installed", cfg!(feature = "with-re2"))?;
20
21 let sys = PyModule::import(py, "sys")?;
19 let sys = PyModule::import(py, "sys")?;
22 let sys_modules: PyDict = sys.get(py, "modules")?.extract(py)?;
20 let sys_modules: PyDict = sys.get(py, "modules")?.extract(py)?;
23 sys_modules.set_item(py, dotted_name, &m)?;
21 sys_modules.set_item(py, dotted_name, &m)?;
@@ -18,7 +18,6 b' hg debuginstall'
18 checking available compression engines (*zlib*) (glob)
18 checking available compression engines (*zlib*) (glob)
19 checking available compression engines for wire protocol (*zlib*) (glob)
19 checking available compression engines for wire protocol (*zlib*) (glob)
20 checking "re2" regexp engine \((available|missing)\) (re)
20 checking "re2" regexp engine \((available|missing)\) (re)
21 checking "re2" regexp engine Rust bindings \((installed|missing)\) (re) (rust !)
22 checking templates (*mercurial?templates)... (glob)
21 checking templates (*mercurial?templates)... (glob)
23 checking default template (*mercurial?templates?map-cmdline.default) (glob)
22 checking default template (*mercurial?templates?map-cmdline.default) (glob)
24 checking commit editor... (*) (glob)
23 checking commit editor... (*) (glob)
@@ -78,7 +77,6 b' hg debuginstall with no username'
78 checking available compression engines (*zlib*) (glob)
77 checking available compression engines (*zlib*) (glob)
79 checking available compression engines for wire protocol (*zlib*) (glob)
78 checking available compression engines for wire protocol (*zlib*) (glob)
80 checking "re2" regexp engine \((available|missing)\) (re)
79 checking "re2" regexp engine \((available|missing)\) (re)
81 checking "re2" regexp engine Rust bindings \((installed|missing)\) (re) (rust !)
82 checking templates (*mercurial?templates)... (glob)
80 checking templates (*mercurial?templates)... (glob)
83 checking default template (*mercurial?templates?map-cmdline.default) (glob)
81 checking default template (*mercurial?templates?map-cmdline.default) (glob)
84 checking commit editor... (*) (glob)
82 checking commit editor... (*) (glob)
@@ -126,7 +124,6 b' path variables are expanded (~ is the sa'
126 checking available compression engines (*zlib*) (glob)
124 checking available compression engines (*zlib*) (glob)
127 checking available compression engines for wire protocol (*zlib*) (glob)
125 checking available compression engines for wire protocol (*zlib*) (glob)
128 checking "re2" regexp engine \((available|missing)\) (re)
126 checking "re2" regexp engine \((available|missing)\) (re)
129 checking "re2" regexp engine Rust bindings \((installed|missing)\) (re) (rust !)
130 checking templates (*mercurial?templates)... (glob)
127 checking templates (*mercurial?templates)... (glob)
131 checking default template (*mercurial?templates?map-cmdline.default) (glob)
128 checking default template (*mercurial?templates?map-cmdline.default) (glob)
132 checking commit editor... ($TESTTMP/tools/testeditor.exe)
129 checking commit editor... ($TESTTMP/tools/testeditor.exe)
@@ -154,7 +151,6 b' not found (this is intentionally using b'
154 checking available compression engines (*zlib*) (glob)
151 checking available compression engines (*zlib*) (glob)
155 checking available compression engines for wire protocol (*zlib*) (glob)
152 checking available compression engines for wire protocol (*zlib*) (glob)
156 checking "re2" regexp engine \((available|missing)\) (re)
153 checking "re2" regexp engine \((available|missing)\) (re)
157 checking "re2" regexp engine Rust bindings \((installed|missing)\) (re) (rust !)
158 checking templates (*mercurial?templates)... (glob)
154 checking templates (*mercurial?templates)... (glob)
159 checking default template (*mercurial?templates?map-cmdline.default) (glob)
155 checking default template (*mercurial?templates?map-cmdline.default) (glob)
160 checking commit editor... (c:\foo\bar\baz.exe) (windows !)
156 checking commit editor... (c:\foo\bar\baz.exe) (windows !)
@@ -211,7 +207,6 b" since it's bin on most platforms but Scr"
211 checking available compression engines (*) (glob)
207 checking available compression engines (*) (glob)
212 checking available compression engines for wire protocol (*) (glob)
208 checking available compression engines for wire protocol (*) (glob)
213 checking "re2" regexp engine \((available|missing)\) (re)
209 checking "re2" regexp engine \((available|missing)\) (re)
214 checking "re2" regexp engine Rust bindings \((installed|missing)\) (re) (rust !)
215 checking templates ($TESTTMP/installenv/*/site-packages/mercurial/templates)... (glob)
210 checking templates ($TESTTMP/installenv/*/site-packages/mercurial/templates)... (glob)
216 checking default template ($TESTTMP/installenv/*/site-packages/mercurial/templates/map-cmdline.default) (glob)
211 checking default template ($TESTTMP/installenv/*/site-packages/mercurial/templates/map-cmdline.default) (glob)
217 checking commit editor... (*) (glob)
212 checking commit editor... (*) (glob)
@@ -252,7 +247,6 b" since it's bin on most platforms but Scr"
252 checking available compression engines (*) (glob)
247 checking available compression engines (*) (glob)
253 checking available compression engines for wire protocol (*) (glob)
248 checking available compression engines for wire protocol (*) (glob)
254 checking "re2" regexp engine \((available|missing)\) (re)
249 checking "re2" regexp engine \((available|missing)\) (re)
255 checking "re2" regexp engine Rust bindings \((installed|missing)\) (re) (rust !)
256 checking templates ($TESTTMP/installenv/*/site-packages/mercurial/templates)... (glob)
250 checking templates ($TESTTMP/installenv/*/site-packages/mercurial/templates)... (glob)
257 checking default template ($TESTTMP/installenv/*/site-packages/mercurial/templates/map-cmdline.default) (glob)
251 checking default template ($TESTTMP/installenv/*/site-packages/mercurial/templates/map-cmdline.default) (glob)
258 checking commit editor... (*) (glob)
252 checking commit editor... (*) (glob)
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now