changeset 35323:1fe3c8296cfe

hgweb: rewrite `template = A and B or C` to be a proper ternary operator
author Anton Shestakov <av6@dwimlabs.net>
date Fri, 08 Dec 2017 22:27:14 +0800
parents c67fb3bfe3a1
children e223c0438f89
files mercurial/hgweb/webcommands.py mercurial/hgweb/webutil.py
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Wed Dec 06 18:37:49 2017 -0800
+++ b/mercurial/hgweb/webcommands.py	Fri Dec 08 22:27:14 2017 +0800
@@ -413,7 +413,7 @@
     else:
         nextentry = []
 
-    return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
+    return tmpl('shortlog' if shortlog else 'changelog', changenav=changenav,
                 node=ctx.hex(), rev=pos, symrev=symrev, changesets=count,
                 entries=entries,
                 latestentry=latestentry, nextentry=nextentry,
--- a/mercurial/hgweb/webutil.py	Wed Dec 06 18:37:49 2017 -0800
+++ b/mercurial/hgweb/webutil.py	Fri Dec 08 22:27:14 2017 +0800
@@ -411,7 +411,7 @@
     files = []
     parity = paritygen(web.stripecount)
     for blockno, f in enumerate(ctx.files()):
-        template = f in ctx and 'filenodelink' or 'filenolink'
+        template = 'filenodelink' if f in ctx else 'filenolink'
         files.append(tmpl(template,
                           node=ctx.hex(), file=f, blockno=blockno + 1,
                           parity=next(parity)))
@@ -572,7 +572,7 @@
 
     fileno = 0
     for filename, adds, removes, isbinary in stats:
-        template = filename in files and 'diffstatlink' or 'diffstatnolink'
+        template = 'diffstatlink' if filename in files else 'diffstatnolink'
         total = adds + removes
         fileno += 1
         yield tmpl(template, node=ctx.hex(), file=filename, fileno=fileno,