policy: reroute proxy modules internally
This allows us to split encoding functions from pure.parsers without doing
that for cext.parsers. See the next patch for why.
--- a/mercurial/cffi/base85.py Mon Jul 31 22:58:06 2017 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-# base85.py: pure python base85 codec
-#
-# Copyright (C) 2009 Brendan Cully <brendan@kublai.com>
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-from __future__ import absolute_import
-
-from ..pure.base85 import *
--- a/mercurial/cffi/diffhelpers.py Mon Jul 31 22:58:06 2017 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-# diffhelpers.py - pure Python implementation of diffhelpers.c
-#
-# Copyright 2009 Matt Mackall <mpm@selenic.com> and others
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-from __future__ import absolute_import
-
-from ..pure.diffhelpers import *
--- a/mercurial/cffi/parsers.py Mon Jul 31 22:58:06 2017 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-# parsers.py - Python implementation of parsers.c
-#
-# Copyright 2009 Matt Mackall <mpm@selenic.com> and others
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-from __future__ import absolute_import
-
-from ..pure.parsers import *
--- a/mercurial/policy.py Mon Jul 31 22:58:06 2017 +0900
+++ b/mercurial/policy.py Mon Jul 31 23:40:36 2017 +0900
@@ -78,6 +78,13 @@
(r'cext', r'parsers'): 1,
}
+# map import request to other package or module
+_modredirects = {
+ (r'cffi', r'base85'): (r'pure', r'base85'),
+ (r'cffi', r'diffhelpers'): (r'pure', r'diffhelpers'),
+ (r'cffi', r'parsers'): (r'pure', r'parsers'),
+}
+
def _checkmod(pkgname, modname, mod):
expected = _cextversions.get((pkgname, modname))
actual = getattr(mod, r'version', None)
@@ -94,11 +101,14 @@
raise ImportError(r'invalid HGMODULEPOLICY %r' % policy)
assert verpkg or purepkg
if verpkg:
+ pn, mn = _modredirects.get((verpkg, modname), (verpkg, modname))
try:
- mod = _importfrom(verpkg, modname)
- _checkmod(verpkg, modname, mod)
+ mod = _importfrom(pn, mn)
+ if pn == verpkg:
+ _checkmod(pn, mn, mod)
return mod
except ImportError:
if not purepkg:
raise
- return _importfrom(purepkg, modname)
+ pn, mn = _modredirects.get((purepkg, modname), (purepkg, modname))
+ return _importfrom(pn, mn)