changeset 32466:28b773aa3ff2

policy: define C module versions individually This allows us to bump the version for a single module without changing all of them.
author Jun Wu <quark@fb.com>
date Mon, 22 May 2017 22:59:40 -0700
parents 8db2feb04ceb
children 7d8da7b54dc0
files mercurial/policy.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/policy.py	Sat May 20 19:43:58 2017 +0200
+++ b/mercurial/policy.py	Mon May 22 22:59:40 2017 -0700
@@ -70,8 +70,18 @@
     getattr(mod, r'__doc__', None)
     return fakelocals[modname]
 
+# keep in sync with "version" in C modules
+_cextversions = {
+    r'base85': 1,
+    r'bdiff': 1,
+    r'diffhelpers': 1,
+    r'mpatch': 1,
+    r'osutil': 1,
+    r'parsers': 1,
+}
+
 def _checkmod(pkgname, modname, mod):
-    expected = 1  # TODO: maybe defined in table?
+    expected = _cextversions.get(modname)
     actual = getattr(mod, r'version', None)
     if actual != expected:
         raise ImportError(r'cannot import module %s.%s '