# HG changeset patch # User Yuya Nishihara # Date 2018-09-23 07:11:01 # Node ID 4f44f747f0941c0435a7fecb2e3ef9495af89c6c # Parent 536f22d6c2c5b8bf00795592901ae58552433390 hgweb: use scmutil.binnode() to translate None to wdir hash (issue5988) I left some of ctx.node() calls unchanged as they seemed unlikely to be workingctx, or passed to diff functions where None is the default value. Note that a None revision can also cause a similar problem, but I'm not sure if we can simply bulk-replace ctx.rev() with scmutil.intrev(ctx) as there's large hole between tip revision and wdir revision. If such pair were passed in to xrange() for example, we would waste CPU time. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -294,7 +294,7 @@ def _search(web): for ctx in searchfunc[0](funcarg): count += 1 - n = ctx.node() + n = scmutil.binnode(ctx) showtags = webutil.showtag(web.repo, 'changelogtag', n) files = webutil.listfilediffs(ctx.files(), n, web.maxfiles) @@ -521,7 +521,7 @@ def manifest(web): symrev = 'tip' path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', '')) mf = ctx.manifest() - node = ctx.node() + node = scmutil.binnode(ctx) files = {} dirs = {} @@ -868,7 +868,7 @@ def comparison(web): leftrev = parent.rev() leftnode = parent.node() rightrev = ctx.rev() - rightnode = ctx.node() + rightnode = scmutil.binnode(ctx) if path in ctx: fctx = ctx[path] rightlines = filelines(fctx) diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -416,7 +416,7 @@ def _kwfunc(f): return f def commonentry(repo, ctx): - node = ctx.node() + node = scmutil.binnode(ctx) return { # TODO: perhaps ctx.changectx() should be assigned if ctx is a # filectx, but I'm not pretty sure if that would always work because @@ -451,7 +451,7 @@ def changelistentry(web, ctx): ''' repo = web.repo rev = ctx.rev() - n = ctx.node() + n = scmutil.binnode(ctx) showtags = showtag(repo, 'changelogtag', n) files = listfilediffs(ctx.files(), n, web.maxfiles) @@ -485,7 +485,7 @@ def symrevorshortnode(req, ctx): if 'node' in req.qsparams: return templatefilters.revescape(req.qsparams['node']) else: - return short(ctx.node()) + return short(scmutil.binnode(ctx)) def _listfilesgen(context, ctx, stripecount): parity = paritygen(stripecount) @@ -501,8 +501,9 @@ def _listfilesgen(context, ctx, stripeco def changesetentry(web, ctx): '''Obtain a dictionary to be used to render the "changeset" template.''' - showtags = showtag(web.repo, 'changesettag', ctx.node()) - showbookmarks = showbookmark(web.repo, 'changesetbookmark', ctx.node()) + showtags = showtag(web.repo, 'changesettag', scmutil.binnode(ctx)) + showbookmarks = showbookmark(web.repo, 'changesetbookmark', + scmutil.binnode(ctx)) showbranch = nodebranchnodefault(ctx) basectx = basechangectx(web.repo, web.req)