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))) |