Mercurial > hg
comparison mercurial/hgweb/webcommands.py @ 32136:f238a483a1fd
webcommands: use fctx.isbinary
author | Jun Wu <quark@fb.com> |
---|---|
date | Wed, 03 May 2017 18:04:43 -0700 |
parents | a298f5c61b34 |
children | 1b90036f42f0 |
comparison
equal
deleted
inserted
replaced
32135:347ab2d47463 | 32136:f238a483a1fd |
---|---|
806 context = parsecontext(req.form['context'][0]) | 806 context = parsecontext(req.form['context'][0]) |
807 else: | 807 else: |
808 context = parsecontext(web.config('web', 'comparisoncontext', '5')) | 808 context = parsecontext(web.config('web', 'comparisoncontext', '5')) |
809 | 809 |
810 def filelines(f): | 810 def filelines(f): |
811 if util.binary(f.data()): | 811 if f.isbinary(): |
812 mt = mimetypes.guess_type(f.path())[0] | 812 mt = mimetypes.guess_type(f.path())[0] |
813 if not mt: | 813 if not mt: |
814 mt = 'application/octet-stream' | 814 mt = 'application/octet-stream' |
815 return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))] | 815 return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))] |
816 return f.data().splitlines() | 816 return f.data().splitlines() |
884 | 884 |
885 for p in parentscache[rev]: | 885 for p in parentscache[rev]: |
886 yield p | 886 yield p |
887 | 887 |
888 def annotate(**map): | 888 def annotate(**map): |
889 if util.binary(fctx.data()): | 889 if fctx.isbinary(): |
890 mt = (mimetypes.guess_type(fctx.path())[0] | 890 mt = (mimetypes.guess_type(fctx.path())[0] |
891 or 'application/octet-stream') | 891 or 'application/octet-stream') |
892 lines = [((fctx.filectx(fctx.filerev()), 1), '(binary:%s)' % mt)] | 892 lines = [((fctx.filectx(fctx.filerev()), 1), '(binary:%s)' % mt)] |
893 else: | 893 else: |
894 lines = webutil.annotate(fctx, web.repo.ui) | 894 lines = webutil.annotate(fctx, web.repo.ui) |