hg: make file view in hgweb working

Summary:
hgweb's file view must determine if the displayed file revision is
the head of the filelog graph. As remotefilelog does not implement file
revision, we have to check if headrevs is implemented.

Reviewed By: DurhamG

Differential Revision: D6954143

fbshipit-source-id: 0657e58110112537dc5baadf743c657d4ecf372a
This commit is contained in:
David Soria Parra 2018-02-12 15:58:42 -08:00 committed by Saurabh Singh
parent 516c0b5131
commit 9939f03d8e

View File

@ -135,7 +135,9 @@ def _filerevision(web, req, tmpl, fctx):
f = fctx.path() f = fctx.path()
text = fctx.data() text = fctx.data()
parity = paritygen(web.stripecount) parity = paritygen(web.stripecount)
ishead = fctx.filerev() in fctx.filelog().headrevs() ishead = False
if util.safehasattr(fctx.filelog(), 'headrevs'):
ishead = fctx.filerev() in fctx.filelog().headrevs()
if util.binary(text): if util.binary(text):
mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' mt = mimetypes.guess_type(f)[0] or 'application/octet-stream'
@ -879,7 +881,9 @@ def annotate(web, req, tmpl):
fctx = webutil.filectx(web.repo, req) fctx = webutil.filectx(web.repo, req)
f = fctx.path() f = fctx.path()
parity = paritygen(web.stripecount) parity = paritygen(web.stripecount)
ishead = fctx.filerev() in fctx.filelog().headrevs() ishead = False
if util.safehasattr(fctx.filelog(), 'headrevs'):
ishead = fctx.filerev() in fctx.filelog().headrevs()
# parents() is called once per line and several lines likely belong to # parents() is called once per line and several lines likely belong to
# same revision. So it is worth caching. # same revision. So it is worth caching.