# HG changeset patch # User Gregory Szorc # Date 1489380642 25200 # Node ID 9e57033fec0caaf551c285d37f304079587ab570 # Parent 3d3109339b57341b333c1112beb41dd281fa944a context: don't use mutable default argument value Mutable default argument values are a Python gotcha and can represent subtle, hard-to-find bugs. Lets rid our code base of them. diff -r 3d3109339b57 -r 9e57033fec0c mercurial/context.py --- a/mercurial/context.py Mon Mar 13 11:19:24 2017 -0700 +++ b/mercurial/context.py Sun Mar 12 21:50:42 2017 -0700 @@ -298,10 +298,10 @@ ''' return subrepo.subrepo(self, path, allowwdir=True) - def match(self, pats=[], include=None, exclude=None, default='glob', + def match(self, pats=None, include=None, exclude=None, default='glob', listsubrepos=False, badfn=None): r = self._repo - return matchmod.match(r.root, r.getcwd(), pats, + return matchmod.match(r.root, r.getcwd(), pats or [], include, exclude, default, auditor=r.nofsauditor, ctx=self, listsubrepos=listsubrepos, badfn=badfn) @@ -1515,18 +1515,18 @@ self._repo.dirstate.normallookup(dest) self._repo.dirstate.copy(source, dest) - def match(self, pats=[], include=None, exclude=None, default='glob', + def match(self, pats=None, include=None, exclude=None, default='glob', listsubrepos=False, badfn=None): 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, include, - exclude, default, r.auditor, self, - listsubrepos=listsubrepos, + return matchmod.icasefsmatcher(r.root, r.getcwd(), pats or [], + include, exclude, default, r.auditor, + self, listsubrepos=listsubrepos, badfn=badfn) - return matchmod.match(r.root, r.getcwd(), pats, + return matchmod.match(r.root, r.getcwd(), pats or [], include, exclude, default, auditor=r.auditor, ctx=self, listsubrepos=listsubrepos, badfn=badfn)