# HG changeset patch # User Yuya Nishihara # Date 1501512036 -32400 # Node ID cd2aca0808f859d2bcd7643a2b5cffadbbdab947 # Parent a22339d389d456f2ee4573ffaa668860335700f6 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. diff -r a22339d389d4 -r cd2aca0808f8 mercurial/cffi/base85.py --- 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 -# -# 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 * diff -r a22339d389d4 -r cd2aca0808f8 mercurial/cffi/diffhelpers.py --- 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 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 * diff -r a22339d389d4 -r cd2aca0808f8 mercurial/cffi/parsers.py --- 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 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 * diff -r a22339d389d4 -r cd2aca0808f8 mercurial/policy.py --- 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)