# HG changeset patch # User Denis Laxalde <denis.laxa...@logilab.fr> # Date 1489398019 -3600 # Mon Mar 13 10:40:19 2017 +0100 # Node ID e62a136ee79973157cded80c7f578dc60b7f6a68 # Parent 527a247f114f8af37326805fd6cce923f9ac6453 # Available At http://hg.logilab.org/users/dlaxalde/hg # hg pull http://hg.logilab.org/users/dlaxalde/hg -r e62a136ee799 # EXP-Topic linerange-log/hgweb-filelog hgweb: handle "parity" internally in webutil.diffs()
There's apparently no reason to have the "parity" of diff blocks that webutil.diffs() generates coming from outside the function. So have it internally managed. We thus now pass a "web" object to webutil.diffs() to get access to both "repo" and "stripecount" attribute. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -756,12 +756,11 @@ def filediff(web, req, tmpl): ctx = fctx.changectx() basectx = ctx.p1() - parity = paritygen(web.stripecount) style = web.config('web', 'style', 'paper') if 'style' in req.form: style = req.form['style'][0] - diffs = webutil.diffs(web.repo, tmpl, ctx, basectx, [path], parity, style) + diffs = webutil.diffs(web, tmpl, ctx, basectx, [path], style) if fctx is not None: rename = webutil.renamelink(fctx) ctx = fctx diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -388,8 +388,7 @@ def changesetentry(web, req, tmpl, ctx): if 'style' in req.form: style = req.form['style'][0] - parity = paritygen(web.stripecount) - diff = diffs(web.repo, tmpl, ctx, basectx, None, parity, style) + diff = diffs(web, tmpl, ctx, basectx, None, style) parity = paritygen(web.stripecount) diffstatsgen = diffstatgen(ctx, basectx) @@ -414,7 +413,7 @@ def listfilediffs(tmpl, files, node, max if len(files) > max: yield tmpl('fileellipses') -def diffs(repo, tmpl, ctx, basectx, files, parity, style): +def diffs(wep, tmpl, ctx, basectx, files, style): def prettyprintlines(lines, blockno): for lineno, l in enumerate(lines, 1): @@ -433,6 +432,7 @@ def diffs(repo, tmpl, ctx, basectx, file lineid="l%s" % difflineno, linenumber="% 8s" % difflineno) + repo = web.repo if files: m = match.exact(repo.root, repo.getcwd(), files) else: @@ -441,6 +441,7 @@ def diffs(repo, tmpl, ctx, basectx, file diffopts = patch.diffopts(repo.ui, untrusted=True) node1 = basectx.node() node2 = ctx.node() + parity = paritygen(web.stripecount) diffhunks = patch.diffhunks(repo, node1, node2, m, opts=diffopts) for blockno, (header, hunks) in enumerate(diffhunks, 1): _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel