Show More
@@ -24,6 +24,12 b' from .utils import (' | |||
|
24 | 24 | stringutil, |
|
25 | 25 | ) |
|
26 | 26 | |
|
27 | try: | |
|
28 | from . import rustext | |
|
29 | rustext.__name__ # force actual import (see hgdemandimport) | |
|
30 | except ImportError: | |
|
31 | rustext = None | |
|
32 | ||
|
27 | 33 | allpatternkinds = ('re', 'glob', 'path', 'relglob', 'relpath', 'relre', |
|
28 | 34 | 'rootglob', |
|
29 | 35 | 'listfile', 'listfile0', 'set', 'include', 'subinclude', |
@@ -1175,8 +1181,22 b' def _globre(pat):' | |||
|
1175 | 1181 | return res |
|
1176 | 1182 | |
|
1177 | 1183 | def _regex(kind, pat, globsuffix): |
|
1178 |
'''Convert a (normalized) pattern of any kind into a |
|
|
1184 | '''Convert a (normalized) pattern of any kind into a | |
|
1185 | regular expression. | |
|
1179 | 1186 | globsuffix is appended to the regexp of globs.''' |
|
1187 | ||
|
1188 | if rustext is not None: | |
|
1189 | try: | |
|
1190 | return rustext.filepatterns.build_single_regex( | |
|
1191 | kind, | |
|
1192 | pat, | |
|
1193 | globsuffix | |
|
1194 | ) | |
|
1195 | except rustext.filepatterns.PatternError: | |
|
1196 | raise error.ProgrammingError( | |
|
1197 | 'not a regex pattern: %s:%s' % (kind, pat) | |
|
1198 | ) | |
|
1199 | ||
|
1180 | 1200 | if not pat: |
|
1181 | 1201 | return '' |
|
1182 | 1202 | if kind == 're': |
@@ -1418,9 +1438,24 b' def readpatternfile(filepath, warn, sour' | |||
|
1418 | 1438 | pattern # pattern of the current default type |
|
1419 | 1439 | |
|
1420 | 1440 | if sourceinfo is set, returns a list of tuples: |
|
1421 |
(pattern, lineno, originalline). |
|
|
1441 | (pattern, lineno, originalline). | |
|
1442 | This is useful to debug ignore patterns. | |
|
1422 | 1443 | ''' |
|
1423 | 1444 | |
|
1445 | if rustext is not None: | |
|
1446 | result, warnings = rustext.filepatterns.read_pattern_file( | |
|
1447 | filepath, | |
|
1448 | bool(warn), | |
|
1449 | sourceinfo, | |
|
1450 | ) | |
|
1451 | ||
|
1452 | for warning_params in warnings: | |
|
1453 | # Can't be easily emitted from Rust, because it would require | |
|
1454 | # a mechanism for both gettext and calling the `warn` function. | |
|
1455 | warn(_("%s: ignoring invalid syntax '%s'\n") % warning_params) | |
|
1456 | ||
|
1457 | return result | |
|
1458 | ||
|
1424 | 1459 | syntaxes = { |
|
1425 | 1460 | 're': 'relre:', |
|
1426 | 1461 | 'regexp': 'relre:', |
@@ -115,6 +115,11 b' substitutions = [' | |||
|
115 | 115 | # Various platform error strings, keyed on a common replacement string |
|
116 | 116 | _errors = { |
|
117 | 117 | br'$ENOENT$': ( |
|
118 | # IOError in Python does not have the same error message | |
|
119 | # than in Rust, and automatic conversion is not possible | |
|
120 | # because of module member privacy. | |
|
121 | br'No such file or directory \(os error 2\)', | |
|
122 | ||
|
118 | 123 | # strerror() |
|
119 | 124 | br'No such file or directory', |
|
120 | 125 |
General Comments 0
You need to be logged in to leave comments.
Login now