Mercurial > hg
diff hgext/highlight/__init__.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | a7abc6081bc5 |
children | 687b865b95ad |
line wrap: on
line diff
--- a/hgext/highlight/__init__.py Sat Oct 05 10:29:34 2019 -0400 +++ b/hgext/highlight/__init__.py Sun Oct 06 09:45:02 2019 -0400 @@ -45,6 +45,7 @@ # leave the attribute unspecified. testedwith = 'ships-with-hg-core' + def pygmentize(web, field, fctx, tmpl): style = web.config('web', 'pygments_style', 'colorful') expr = web.config('web', 'highlightfiles', "size('<5M')") @@ -53,8 +54,10 @@ ctx = fctx.changectx() m = ctx.matchfileset(expr) if m(fctx.path()): - highlight.pygmentize(field, fctx, style, tmpl, - guessfilenameonly=filenameonly) + highlight.pygmentize( + field, fctx, style, tmpl, guessfilenameonly=filenameonly + ) + def filerevision_highlight(orig, web, fctx): mt = web.res.headers['Content-Type'] @@ -70,6 +73,7 @@ return orig(web, fctx) + def annotate_highlight(orig, web): mt = web.res.headers['Content-Type'] if 'html' in mt: @@ -78,21 +82,28 @@ return orig(web) + def generate_css(web): pg_style = web.config('web', 'pygments_style', 'colorful') fmter = highlight.HtmlFormatter(style=pycompat.sysstr(pg_style)) web.res.headers['Content-Type'] = 'text/css' style_defs = fmter.get_style_defs(pycompat.sysstr('')) - web.res.setbodybytes(''.join([ - '/* pygments_style = %s */\n\n' % pg_style, - pycompat.bytestr(style_defs), - ])) + web.res.setbodybytes( + ''.join( + [ + '/* pygments_style = %s */\n\n' % pg_style, + pycompat.bytestr(style_defs), + ] + ) + ) return web.res.sendresponse() + def extsetup(ui): # monkeypatch in the new version - extensions.wrapfunction(webcommands, '_filerevision', - filerevision_highlight) + extensions.wrapfunction( + webcommands, '_filerevision', filerevision_highlight + ) extensions.wrapfunction(webcommands, 'annotate', annotate_highlight) webcommands.highlightcss = generate_css webcommands.__all__.append('highlightcss')