[PATCH 2 of 3] highlight: inline checkfctx()

Gregory Szorc gregory.szorc at gmail.com
Wed Oct 14 20:22:34 CDT 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1444869824 25200
#      Wed Oct 14 17:43:44 2015 -0700
# Node ID bf9868e78cdfa8acb4a9a035bc21d49260043f5c
# Parent  7269a021a45143109239459fbedca6c6bd408367
highlight: inline checkfctx()

It is only used once. pygmentize() is pretty small. Let's just inline
it.

diff --git a/hgext/highlight/__init__.py b/hgext/highlight/__init__.py
--- a/hgext/highlight/__init__.py
+++ b/hgext/highlight/__init__.py
@@ -28,18 +28,16 @@ from mercurial import extensions, encodi
 # be specifying the version(s) of Mercurial they are tested with, or
 # leave the attribute unspecified.
 testedwith = 'internal'
 
-def checkfctx(fctx, expr):
+def pygmentize(web, field, fctx, tmpl):
+    style = web.config('web', 'pygments_style', 'colorful')
+    expr = web.config('web', 'highlightfiles', "size('<5M')")
+
     ctx = fctx.changectx()
     tree = fileset.parse(expr)
     mctx = fileset.matchctx(ctx, subset=[fctx.path()], status=None)
-    return fctx.path() in fileset.getset(mctx, tree)
-
-def pygmentize(web, field, fctx, tmpl):
-    style = web.config('web', 'pygments_style', 'colorful')
-    expr = web.config('web', 'highlightfiles', "size('<5M')")
-    if checkfctx(fctx, expr):
+    if fctx.path() in fileset.getset(mctx, tree):
         highlight.pygmentize(field, fctx, style, tmpl)
 
 def filerevision_highlight(orig, web, req, tmpl, fctx):
     mt = ''.join(tmpl('mimetype', encoding=encoding.encoding))


More information about the Mercurial-devel mailing list