##// END OF EJS Templates
rust-filepatterns: remove bridge code for filepatterns-related functions...
Raphaël Gomès -
r44589:3bd77c64 default
parent child Browse files
Show More
@@ -24,7 +24,7 b' from . import ('
24 24 )
25 25 from .utils import stringutil
26 26
27 rustmod = policy.importrust('filepatterns')
27 rustmod = policy.importrust('dirstate')
28 28
29 29 allpatternkinds = (
30 30 b're',
@@ -1273,15 +1273,6 b' def _regex(kind, pat, globsuffix):'
1273 1273 '''Convert a (normalized) pattern of any kind into a
1274 1274 regular expression.
1275 1275 globsuffix is appended to the regexp of globs.'''
1276
1277 if rustmod is not None:
1278 try:
1279 return rustmod.build_single_regex(kind, pat, globsuffix)
1280 except rustmod.PatternError:
1281 raise error.ProgrammingError(
1282 b'not a regex pattern: %s:%s' % (kind, pat)
1283 )
1284
1285 1276 if not pat and kind in (b'glob', b'relpath'):
1286 1277 return b''
1287 1278 if kind == b're':
@@ -1554,18 +1545,6 b' def readpatternfile(filepath, warn, sour'
1554 1545 This is useful to debug ignore patterns.
1555 1546 '''
1556 1547
1557 if rustmod is not None:
1558 result, warnings = rustmod.read_pattern_file(
1559 filepath, bool(warn), sourceinfo,
1560 )
1561
1562 for warning_params in warnings:
1563 # Can't be easily emitted from Rust, because it would require
1564 # a mechanism for both gettext and calling the `warn` function.
1565 warn(_(b"%s: ignoring invalid syntax '%s'\n") % warning_params)
1566
1567 return result
1568
1569 1548 syntaxes = {
1570 1549 b're': b'relre:',
1571 1550 b'regexp': b'relre:',
@@ -13,7 +13,7 b''
13 13 //!
14 14 //! [`GraphError`]: struct.GraphError.html
15 15 use cpython::{
16 exc::{IOError, RuntimeError, ValueError},
16 exc::{RuntimeError, ValueError},
17 17 py_exception, PyErr, Python,
18 18 };
19 19 use hg;
@@ -39,34 +39,6 b' impl GraphError {'
39 39 }
40 40 }
41 41
42 py_exception!(rustext, PatternError, RuntimeError);
43 py_exception!(rustext, PatternFileError, RuntimeError);
44 42 py_exception!(rustext, HgPathPyError, RuntimeError);
45 43
46 impl PatternError {
47 pub fn pynew(py: Python, inner: hg::PatternError) -> PyErr {
48 match inner {
49 hg::PatternError::UnsupportedSyntax(m) => {
50 PatternError::new(py, ("PatternError", m))
51 }
52 }
53 }
54 }
55
56 impl PatternFileError {
57 pub fn pynew(py: Python, inner: hg::PatternFileError) -> PyErr {
58 match inner {
59 hg::PatternFileError::IO(e) => {
60 let value = (e.raw_os_error().unwrap_or(2), e.to_string());
61 PyErr::new::<IOError, _>(py, value)
62 }
63 hg::PatternFileError::Pattern(e, l) => match e {
64 hg::PatternError::UnsupportedSyntax(m) => {
65 PatternFileError::new(py, ("PatternFileError", m, l))
66 }
67 },
68 }
69 }
70 }
71
72 44 py_exception!(shared_ref, AlreadyBorrowed, RuntimeError);
@@ -33,7 +33,6 b' pub mod dagops;'
33 33 pub mod dirstate;
34 34 pub mod discovery;
35 35 pub mod exceptions;
36 pub mod filepatterns;
37 36 pub mod parsers;
38 37 pub mod revlog;
39 38 pub mod utils;
@@ -53,25 +52,10 b' py_module_initializer!(rustext, initrust'
53 52 m.add(py, "revlog", revlog::init_module(py, &dotted_name)?)?;
54 53 m.add(
55 54 py,
56 "filepatterns",
57 filepatterns::init_module(py, &dotted_name)?,
58 )?;
59 m.add(
60 py,
61 55 "parsers",
62 56 parsers::init_parsers_module(py, &dotted_name)?,
63 57 )?;
64 58 m.add(py, "GraphError", py.get_type::<exceptions::GraphError>())?;
65 m.add(
66 py,
67 "PatternFileError",
68 py.get_type::<exceptions::PatternFileError>(),
69 )?;
70 m.add(
71 py,
72 "PatternError",
73 py.get_type::<exceptions::PatternError>(),
74 )?;
75 59 Ok(())
76 60 });
77 61
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now