Mercurial > public > mercurial-scm > hg
diff hgext/highlight.py @ 6393:894875eae49b
hgweb: refactor hgweb code
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Fri, 28 Mar 2008 19:40:44 +0100 |
parents | e75aab656f46 |
children | 55bc0a035e1f |
line wrap: on
line diff
--- a/hgext/highlight.py Fri Mar 28 19:37:28 2008 +0100 +++ b/hgext/highlight.py Fri Mar 28 19:40:44 2008 +0100 @@ -31,7 +31,7 @@ 'pkg_resources', '__main__',]) -from mercurial.hgweb.hgweb_mod import hgweb +from mercurial.hgweb import webcommands, webutil from mercurial import util from mercurial.templatefilters import filters @@ -79,20 +79,19 @@ newl = oldl.replace('line|escape', 'line|colorize') tmpl.cache[field] = newl -def filerevision_highlight(self, tmpl, fctx): - pygmentize(self, tmpl, fctx, 'fileline') - - return realrevision(self, tmpl, fctx) +web_filerevision = webcommands._filerevision +web_annotate = webcommands.annotate -def fileannotate_highlight(self, tmpl, fctx): - pygmentize(self, tmpl, fctx, 'annotateline') +def filerevision_highlight(web, tmpl, fctx): + pygmentize(web, tmpl, fctx, 'fileline') + return web_filerevision(web, tmpl, fctx) - return realannotate(self, tmpl, fctx) +def annotate_highlight(web, req, tmpl): + fctx = webutil.filectx(web.repo, req) + pygmentize(web, tmpl, fctx, 'annotateline') + return web_annotate(web, req, tmpl) # monkeypatch in the new version -# should be safer than overriding the method in a derived class -# and then patching the class -realrevision = hgweb.filerevision -hgweb.filerevision = filerevision_highlight -realannotate = hgweb.fileannotate -hgweb.fileannotate = fileannotate_highlight + +webcommands._filerevision = filerevision_highlight +webcommands.annotate = annotate_highlight