Patchwork D1619: highlight: eagerly discover plugin lexers while demandimport is off

login
register
mail settings
Submitter phabricator
Date Dec. 8, 2017, 9:23 p.m.
Message ID <differential-rev-PHID-DREV-jqkceamoguqppqbr35qb-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26127/
State Superseded
Headers show

Comments

phabricator - Dec. 8, 2017, 9:23 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Since highlight is only relevant for servers, it seems worthwhile to
  just trigger this eagerly, which avoids really weird traceback
  problems caused by demandimport messing with some of the lexer plugins.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1619

AFFECTED FILES
  hgext/highlight/highlight.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/highlight/highlight.py b/hgext/highlight/highlight.py
--- a/hgext/highlight/highlight.py
+++ b/hgext/highlight/highlight.py
@@ -22,8 +22,12 @@ 
     import pygments
     import pygments.formatters
     import pygments.lexers
+    import pygments.plugin
     import pygments.util
 
+    for unused in pygments.plugin.find_plugin_lexers():
+        pass
+
 highlight = pygments.highlight
 ClassNotFound = pygments.util.ClassNotFound
 guess_lexer = pygments.lexers.guess_lexer