Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/webcommands.py @ 40211:d216ae4cc3f6
py3: r'' prefix default values for mimetypes.guess_mime()
As suggested by @yuja in D4967.
Differential Revision: https://phab.mercurial-scm.org/D5020
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 12 Oct 2018 19:49:02 +0200 |
parents | 9310037f0636 |
children | b24c23f7c1f9 |
comparison
equal
deleted
inserted
replaced
40210:8f192f2c4a1e | 40211:d216ae4cc3f6 |
---|---|
149 ishead = fctx.filenode() in fctx.filelog().heads() | 149 ishead = fctx.filenode() in fctx.filelog().heads() |
150 | 150 |
151 if stringutil.binary(text): | 151 if stringutil.binary(text): |
152 mt = pycompat.sysbytes( | 152 mt = pycompat.sysbytes( |
153 mimetypes.guess_type(pycompat.fsdecode(f))[0] | 153 mimetypes.guess_type(pycompat.fsdecode(f))[0] |
154 or 'application/octet-stream') | 154 or r'application/octet-stream') |
155 text = '(binary:%s)' % mt | 155 text = '(binary:%s)' % mt |
156 | 156 |
157 def lines(context): | 157 def lines(context): |
158 for lineno, t in enumerate(text.splitlines(True)): | 158 for lineno, t in enumerate(text.splitlines(True)): |
159 yield {"line": t, | 159 yield {"line": t, |
862 | 862 |
863 def filelines(f): | 863 def filelines(f): |
864 if f.isbinary(): | 864 if f.isbinary(): |
865 mt = pycompat.sysbytes( | 865 mt = pycompat.sysbytes( |
866 mimetypes.guess_type(pycompat.fsdecode(f.path()))[0] | 866 mimetypes.guess_type(pycompat.fsdecode(f.path()))[0] |
867 or 'application/octet-stream') | 867 or r'application/octet-stream') |
868 return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))] | 868 return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))] |
869 return f.data().splitlines() | 869 return f.data().splitlines() |
870 | 870 |
871 fctx = None | 871 fctx = None |
872 parent = ctx.p1() | 872 parent = ctx.p1() |
950 | 950 |
951 def annotate(context): | 951 def annotate(context): |
952 if fctx.isbinary(): | 952 if fctx.isbinary(): |
953 mt = pycompat.sysbytes( | 953 mt = pycompat.sysbytes( |
954 mimetypes.guess_type(pycompat.fsdecode(fctx.path()))[0] | 954 mimetypes.guess_type(pycompat.fsdecode(fctx.path()))[0] |
955 or 'application/octet-stream') | 955 or r'application/octet-stream') |
956 lines = [dagop.annotateline(fctx=fctx.filectx(fctx.filerev()), | 956 lines = [dagop.annotateline(fctx=fctx.filectx(fctx.filerev()), |
957 lineno=1, text='(binary:%s)' % mt)] | 957 lineno=1, text='(binary:%s)' % mt)] |
958 else: | 958 else: |
959 lines = webutil.annotate(web.req, fctx, web.repo.ui) | 959 lines = webutil.annotate(web.req, fctx, web.repo.ui) |
960 | 960 |