Mercurial > public > mercurial-scm > hg-stable
diff mercurial/policy.py @ 52433:6673cec8605c
rust: add PyO3 based Rust extension module
Rebased by gracinet on top of cleanups for the Mercurial 7.0
development cycle.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Mon, 27 Nov 2023 12:21:44 -0500 |
parents | 5e2f0fec0a47 |
children | c28ba6fb3fae |
line wrap: on
line diff
--- 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