highlight: use matcher API to test if file should be pygmentized
authorYuya Nishihara <yuya@tcha.org>
Tue, 10 Jul 2018 23:49:48 +0900
changeset 38688 2570dca0f21c
parent 38687 1500cbe22d53
child 38689 ff5b6fca1082
highlight: use matcher API to test if file should be pygmentized Prepares for the upcoming API change. We'll no longer have to call the fileset function directly since the cost of the matcher-based fileset will become O(number of tests) from O(number of files in subset).
hgext/highlight/__init__.py
--- a/hgext/highlight/__init__.py	Sun Jun 10 20:58:10 2018 +0900
+++ b/hgext/highlight/__init__.py	Tue Jul 10 23:49:48 2018 +0900
@@ -36,7 +36,6 @@
 
 from mercurial import (
     extensions,
-    fileset,
 )
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
@@ -51,9 +50,8 @@
     filenameonly = web.configbool('web', 'highlightonlymatchfilename', False)
 
     ctx = fctx.changectx()
-    tree = fileset.parse(expr)
-    mctx = fileset.matchctx(ctx, subset=[fctx.path()], status=None)
-    if fctx.path() in fileset.getset(mctx, tree):
+    m = ctx.matchfileset(expr)
+    if m(fctx.path()):
         highlight.pygmentize(field, fctx, style, tmpl,
                 guessfilenameonly=filenameonly)