changeset 31082:abb92b3d370e

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.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Tue, 17 Jan 2017 17:25:48 +0100
parents be74ce1b930f
children c42feb5f3143
files mercurial/hgweb/webcommands.py mercurial/hgweb/webutil.py
diffstat 2 files changed, 3 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Wed Feb 22 18:26:12 2017 -0800
+++ b/mercurial/hgweb/webcommands.py	Tue Jan 17 17:25:48 2017 +0100
@@ -754,13 +754,14 @@
     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
--- a/mercurial/hgweb/webutil.py	Wed Feb 22 18:26:12 2017 -0800
+++ b/mercurial/hgweb/webutil.py	Tue Jan 17 17:25:48 2017 +0100
@@ -442,14 +442,7 @@
         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 = []