Patchwork [4,of,8] match: explicitly tests for None

login
register
mail settings
Submitter Pierre-Yves David
Date March 16, 2017, 11:28 a.m.
Message ID <83112ff862072df86354.1489663688@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19388/
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 1489615725 25200
#      Wed Mar 15 15:08:45 2017 -0700
# Node ID 83112ff862072df863540c8c9356f64eb26faa41
# Parent  27d5ab143c3344006509c5a3b29e2cb66445aa04
# 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 83112ff86207
match: explicitly tests for None

Changeset 6168d4b93634 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/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -117,8 +117,10 @@  class match(object):
                               the same directory
         '<something>' - a pattern of the specified default type
         """
-        include = include or []
-        exclude = exclude or []
+        if include is None:
+            include = []
+        if exclude is None:
+            exclude = []
 
         self._root = root
         self._cwd = cwd