Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 31388:9e57033fec0c
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.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 12 Mar 2017 21:50:42 -0700 |
parents | 5da0c7888dc4 |
children | 084050d76e4f |
comparison
equal
deleted
inserted
replaced
31387:3d3109339b57 | 31388:9e57033fec0c |
---|---|
296 '''return a subrepo for the stored revision, or wdir if this is a wdir | 296 '''return a subrepo for the stored revision, or wdir if this is a wdir |
297 context. | 297 context. |
298 ''' | 298 ''' |
299 return subrepo.subrepo(self, path, allowwdir=True) | 299 return subrepo.subrepo(self, path, allowwdir=True) |
300 | 300 |
301 def match(self, pats=[], include=None, exclude=None, default='glob', | 301 def match(self, pats=None, include=None, exclude=None, default='glob', |
302 listsubrepos=False, badfn=None): | 302 listsubrepos=False, badfn=None): |
303 r = self._repo | 303 r = self._repo |
304 return matchmod.match(r.root, r.getcwd(), pats, | 304 return matchmod.match(r.root, r.getcwd(), pats or [], |
305 include, exclude, default, | 305 include, exclude, default, |
306 auditor=r.nofsauditor, ctx=self, | 306 auditor=r.nofsauditor, ctx=self, |
307 listsubrepos=listsubrepos, badfn=badfn) | 307 listsubrepos=listsubrepos, badfn=badfn) |
308 | 308 |
309 def diff(self, ctx2=None, match=None, **opts): | 309 def diff(self, ctx2=None, match=None, **opts): |
1513 self._repo.dirstate.add(dest) | 1513 self._repo.dirstate.add(dest) |
1514 elif self._repo.dirstate[dest] in 'r': | 1514 elif self._repo.dirstate[dest] in 'r': |
1515 self._repo.dirstate.normallookup(dest) | 1515 self._repo.dirstate.normallookup(dest) |
1516 self._repo.dirstate.copy(source, dest) | 1516 self._repo.dirstate.copy(source, dest) |
1517 | 1517 |
1518 def match(self, pats=[], include=None, exclude=None, default='glob', | 1518 def match(self, pats=None, include=None, exclude=None, default='glob', |
1519 listsubrepos=False, badfn=None): | 1519 listsubrepos=False, badfn=None): |
1520 r = self._repo | 1520 r = self._repo |
1521 | 1521 |
1522 # Only a case insensitive filesystem needs magic to translate user input | 1522 # Only a case insensitive filesystem needs magic to translate user input |
1523 # to actual case in the filesystem. | 1523 # to actual case in the filesystem. |
1524 if not util.fscasesensitive(r.root): | 1524 if not util.fscasesensitive(r.root): |
1525 return matchmod.icasefsmatcher(r.root, r.getcwd(), pats, include, | 1525 return matchmod.icasefsmatcher(r.root, r.getcwd(), pats or [], |
1526 exclude, default, r.auditor, self, | 1526 include, exclude, default, r.auditor, |
1527 listsubrepos=listsubrepos, | 1527 self, listsubrepos=listsubrepos, |
1528 badfn=badfn) | 1528 badfn=badfn) |
1529 return matchmod.match(r.root, r.getcwd(), pats, | 1529 return matchmod.match(r.root, r.getcwd(), pats or [], |
1530 include, exclude, default, | 1530 include, exclude, default, |
1531 auditor=r.auditor, ctx=self, | 1531 auditor=r.auditor, ctx=self, |
1532 listsubrepos=listsubrepos, badfn=badfn) | 1532 listsubrepos=listsubrepos, badfn=badfn) |
1533 | 1533 |
1534 def _filtersuspectsymlink(self, files): | 1534 def _filtersuspectsymlink(self, files): |