Mercurial > hg
comparison hgext/highlight/highlight.py @ 32908:661025fd3e1c
highlight: put pygments import inside demandimport.deactivated
I tripped on some weirdness relating to _thread vs threading way down
in a dep of highlight recently. I'm not really sure why I'm only just
seeing this defect now, but experimentally this fixes the problem, and
shouldn't cause any load-time slowness for people until pygments is
actually about to be used since highlight.highlight is still lazily
loaded in the highlight/__init__.py file.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sun, 18 Jun 2017 23:05:54 -0400 |
parents | 6a98f9408a50 |
children | 169d66db5920 |
comparison
equal
deleted
inserted
replaced
32907:bd77ac2bd23a | 32908:661025fd3e1c |
---|---|
8 # The original module was split in an interface and an implementation | 8 # The original module was split in an interface and an implementation |
9 # file to defer pygments loading and speedup extension setup. | 9 # file to defer pygments loading and speedup extension setup. |
10 | 10 |
11 from __future__ import absolute_import | 11 from __future__ import absolute_import |
12 | 12 |
13 import pygments | |
14 import pygments.formatters | |
15 import pygments.lexers | |
16 import pygments.util | |
17 | |
18 from mercurial import demandimport | 13 from mercurial import demandimport |
19 demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__']) | 14 demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__']) |
20 | 15 |
21 from mercurial import ( | 16 from mercurial import ( |
22 encoding, | 17 encoding, |
23 util, | 18 util, |
24 ) | 19 ) |
20 | |
21 with demandimport.deactivated(): | |
22 import pygments | |
23 import pygments.formatters | |
24 import pygments.lexers | |
25 import pygments.util | |
25 | 26 |
26 highlight = pygments.highlight | 27 highlight = pygments.highlight |
27 ClassNotFound = pygments.util.ClassNotFound | 28 ClassNotFound = pygments.util.ClassNotFound |
28 guess_lexer = pygments.lexers.guess_lexer | 29 guess_lexer = pygments.lexers.guess_lexer |
29 guess_lexer_for_filename = pygments.lexers.guess_lexer_for_filename | 30 guess_lexer_for_filename = pygments.lexers.guess_lexer_for_filename |