[lib] fix: do not lazy import missing modules (closes #99402)

With python2.7, pygments loads the pkg_resources module which try to load a CPython3.3 module. This cause troubles as the lazy import system do not raise the expected ImportError exception on python2.7.

authorAlain Leufroy <alain.leufroy@logilab.fr>
changeset51dc48d57f07
branchstable
phasepublic
hiddenno
parent revision#96922b47a8a8 [tui] call ``set`` directly instead of ``footer`` attribute that does not exist (closes #98669)
child revision#ba0660fccbe7 closes #100530 : fix unnecessary dependency on docutils.core.
files modified by this revision
hgviewlib/hgpatches/__init__.py
# HG changeset patch
# User Alain Leufroy <alain.leufroy@logilab.fr>
# Date 1341502551 -7200
# Thu Jul 05 17:35:51 2012 +0200
# Branch stable
# Node ID 51dc48d57f07112a186df53d4260b78d2a420e7a
# Parent 96922b47a8a89da964a4bc7e6a46e9808e0914b5
[lib] fix: do not lazy import missing modules (closes #99402)

With python2.7, ``pygments`` loads the ``pkg_resources`` module which try to load a CPython3.3
module. This cause troubles as the lazy import system do not raise the expected
ImportError exception on python2.7.

diff --git a/hgviewlib/hgpatches/__init__.py b/hgviewlib/hgpatches/__init__.py
@@ -17,10 +17,14 @@
1  older versions
2  """
3 
4  from functools import partial
5  from mercurial import changelog, filelog, patch, context
6 +from mercurial import demandimport
7 +
8 +# for CPython > 2.7 (see pkg_resources) module [loaded by pygments])
9 +demandimport.ignore.append("_frozen_importlib")
10 
11  if not hasattr(changelog.changelog, '__len__'):
12      changelog.changelog.__len__ = changelog.changelog.count
13  if not hasattr(filelog.filelog, '__len__'):
14      filelog.filelog.__len__ = filelog.filelog.count