mercurial/match.py
changeset 42452 a3a8887e4426
parent 42367 96fc696a9cb2
child 42766 e94c8f584ee2
--- 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,