Mercurial > hg-stable
diff mercurial/match.py @ 42468:a3a8887e4426
rust: using policy.importrust from Python callers
This commit converts all current Python callers of
mercurial.rustext to the new policy.importrust system.
After this point, going through policy.importrust
or policy.importmod (in some more distant future)
is mandatory for callers of Rust code outside of
Python tests.
We felt it to be appropriate to keep Rust-specific tests
run inconditionally if the Rust extensions are present.
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Thu, 30 May 2019 09:14:41 +0200 |
parents | 96fc696a9cb2 |
children | e94c8f584ee2 |
line wrap: on
line diff
--- a/mercurial/match.py Wed May 29 13:27:56 2019 +0200 +++ b/mercurial/match.py Thu May 30 09:14:41 2019 +0200 @@ -17,6 +17,7 @@ encoding, error, pathutil, + policy, pycompat, util, ) @@ -24,11 +25,7 @@ stringutil, ) -try: - from . import rustext - rustext.__name__ # force actual import (see hgdemandimport) -except ImportError: - rustext = None +rustmod = policy.importrust('filepatterns') allpatternkinds = ('re', 'glob', 'path', 'relglob', 'relpath', 'relre', 'rootglob', @@ -1197,14 +1194,14 @@ regular expression. globsuffix is appended to the regexp of globs.''' - if rustext is not None: + if rustmod is not None: try: - return rustext.filepatterns.build_single_regex( + return rustmod.build_single_regex( kind, pat, globsuffix ) - except rustext.filepatterns.PatternError: + except rustmod.PatternError: raise error.ProgrammingError( 'not a regex pattern: %s:%s' % (kind, pat) ) @@ -1460,8 +1457,8 @@ This is useful to debug ignore patterns. ''' - if rustext is not None: - result, warnings = rustext.filepatterns.read_pattern_file( + if rustmod is not None: + result, warnings = rustmod.read_pattern_file( filepath, bool(warn), sourceinfo,