Submitter | Denis Laxalde |
---|---|
Date | Feb. 22, 2017, 3:10 p.m. |
Message ID | <b3f8ef870003ee2ca6b6.1487776201@sh77.tls.logilab.fr> |
Download | mbox | patch |
Permalink | /patch/18711/ |
State | Accepted |
Delegated to: | Yuya Nishihara |
Headers | show |
Comments
On Wed, 22 Feb 2017 16:10:01 +0100, Denis Laxalde wrote: > # HG changeset patch > # User Denis Laxalde <denis.laxalde@logilab.fr> > # Date 1484670348 -3600 > # Tue Jan 17 17:25:48 2017 +0100 > # Node ID b3f8ef870003ee2ca6b6db70860a065f255902b7 > # Parent ddf1b3d89b595aa5b376bb51a8edf458b8f1b1c8 > # EXP-Topic linerange-log/hgweb-filelog > hgweb: explictly pass basectx in webutil.diffs > > There's only one case where `basectx` parameter is None (over two usages), so > it's probably not worth handling the special case as it makes code-reading > harder. > > Along the way, use ctx.p1() instead of checking for ctx.parents() being empty > which should not occur. Nice cleanup. Queued this, thanks.
Patch
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -753,13 +753,14 @@ def filediff(web, req, tmpl): if fctx is not None: path = fctx.path() 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, None, [path], parity, style) + diffs = webutil.diffs(web.repo, tmpl, ctx, basectx, [path], parity, 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 @@ -463,14 +463,7 @@ def diffs(repo, tmpl, ctx, basectx, file m = match.always(repo.root, repo.getcwd()) diffopts = patch.diffopts(repo.ui, untrusted=True) - if basectx is None: - parents = ctx.parents() - if parents: - node1 = parents[0].node() - else: - node1 = nullid - else: - node1 = basectx.node() + node1 = basectx.node() node2 = ctx.node() block = []