Patchwork [5,of,8] hgweb: explicitly tests for None in webutil

login
register
mail settings
Submitter Pierre-Yves David
Date March 16, 2017, 11:28 a.m.
Message ID <1596b4613bec63db08c0.1489663689@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19384/
State Accepted
Headers show

Comments

Pierre-Yves David - March 16, 2017, 11:28 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1489615809 25200
#      Wed Mar 15 15:10:09 2017 -0700
# Node ID 1596b4613bec63db08c0d4d10e3f26f5635ce21b
# Parent  83112ff862072df863540c8c9356f64eb26faa41
# EXP-Topic mutable-default
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 1596b4613bec
hgweb: explicitly tests for None in webutil

Changeset d2878bec55bd removed the mutable default value, but did not explicitly
tested for None. Such implicit testing can introduce semantic and performance
issue. We move to an explicit testing for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -143,7 +143,9 @@  class filerevnav(revnav):
 
 class _siblings(object):
     def __init__(self, siblings=None, hiderev=None):
-        self.siblings = [s for s in siblings or [] if s.node() != nullid]
+        if siblings is None:
+            siblings = []
+        self.siblings = [s for s in siblings if s.node() != nullid]
         if len(self.siblings) == 1 and self.siblings[0].rev() == hiderev:
             self.siblings = []