Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/webcommands.py @ 38060:aeccb08af311
hgweb: wrap {lines} of filerevision with mappinggenerator
No bare generator of mappings should be put in a template mapping.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 04 Apr 2018 00:24:09 +0900 |
parents | 5989261a8356 |
children | d3b4c4769b5c |
comparison
equal
deleted
inserted
replaced
38059:4c3ab15f3532 | 38060:aeccb08af311 |
---|---|
147 | 147 |
148 if stringutil.binary(text): | 148 if stringutil.binary(text): |
149 mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' | 149 mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' |
150 text = '(binary:%s)' % mt | 150 text = '(binary:%s)' % mt |
151 | 151 |
152 def lines(): | 152 def lines(context): |
153 for lineno, t in enumerate(text.splitlines(True)): | 153 for lineno, t in enumerate(text.splitlines(True)): |
154 yield {"line": t, | 154 yield {"line": t, |
155 "lineid": "l%d" % (lineno + 1), | 155 "lineid": "l%d" % (lineno + 1), |
156 "linenumber": "% 6d" % (lineno + 1), | 156 "linenumber": "% 6d" % (lineno + 1), |
157 "parity": next(parity)} | 157 "parity": next(parity)} |
158 | 158 |
159 return web.sendtemplate( | 159 return web.sendtemplate( |
160 'filerevision', | 160 'filerevision', |
161 file=f, | 161 file=f, |
162 path=webutil.up(f), | 162 path=webutil.up(f), |
163 text=lines(), | 163 text=templateutil.mappinggenerator(lines), |
164 symrev=webutil.symrevorshortnode(web.req, fctx), | 164 symrev=webutil.symrevorshortnode(web.req, fctx), |
165 rename=webutil.renamelink(fctx), | 165 rename=webutil.renamelink(fctx), |
166 permissions=fctx.manifest().flags(f), | 166 permissions=fctx.manifest().flags(f), |
167 ishead=int(ishead), | 167 ishead=int(ishead), |
168 **pycompat.strkwargs(webutil.commonentry(web.repo, fctx))) | 168 **pycompat.strkwargs(webutil.commonentry(web.repo, fctx))) |