mercurial/policy.py
changeset 52402 6673cec8605c
parent 51959 5e2f0fec0a47
child 52406 c28ba6fb3fae
--- a/mercurial/policy.py	Fri Dec 06 00:58:45 2024 -0500
+++ b/mercurial/policy.py	Mon Nov 27 12:21:44 2023 -0500
@@ -132,7 +132,9 @@
     return policy.endswith(b'-allow')
 
 
-def importrust(modname: str, member: "Optional[str]" = None, default=None):
+def importrust(
+    modname: str, member: "Optional[str]" = None, default=None, pyo3=False
+):
     """Import Rust module according to policy and availability.
 
     If policy isn't a Rust one, this returns `default`.
@@ -143,8 +145,10 @@
     if not policy.startswith(b'rust'):
         return default
 
+    dlib_name = "pyo3-rustext" if pyo3 else "rustext"
+
     try:
-        mod = _importfrom('rustext', modname)
+        mod = _importfrom(dlib_name, modname)
     except ImportError:
         if _isrustpermissive():
             return default