# HG changeset patch # User Pierre-Yves David # Date 1489617204 25200 # Node ID 084050d76e4f23ddcfc8cb0d2e2416b4e8a13309 # Parent ac7aa96e4cd86a38ddbf1ac15345b3277108fc8f context: explicitly tests for None Changeset 9e57033fec0c 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 diff -r ac7aa96e4cd8 -r 084050d76e4f mercurial/context.py --- a/mercurial/context.py Wed Mar 15 15:11:52 2017 -0700 +++ b/mercurial/context.py Wed Mar 15 15:33:24 2017 -0700 @@ -300,8 +300,10 @@ def match(self, pats=None, include=None, exclude=None, default='glob', listsubrepos=False, badfn=None): + if pats is None: + pats = [] r = self._repo - return matchmod.match(r.root, r.getcwd(), pats or [], + return matchmod.match(r.root, r.getcwd(), pats, include, exclude, default, auditor=r.nofsauditor, ctx=self, listsubrepos=listsubrepos, badfn=badfn) @@ -1517,16 +1519,18 @@ def match(self, pats=None, include=None, exclude=None, default='glob', listsubrepos=False, badfn=None): + if pats is None: + pats = [] r = self._repo # Only a case insensitive filesystem needs magic to translate user input # to actual case in the filesystem. if not util.fscasesensitive(r.root): - return matchmod.icasefsmatcher(r.root, r.getcwd(), pats or [], + return matchmod.icasefsmatcher(r.root, r.getcwd(), pats, include, exclude, default, r.auditor, self, listsubrepos=listsubrepos, badfn=badfn) - return matchmod.match(r.root, r.getcwd(), pats or [], + return matchmod.match(r.root, r.getcwd(), pats, include, exclude, default, auditor=r.auditor, ctx=self, listsubrepos=listsubrepos, badfn=badfn)