Mercurial > public > mercurial-scm > hg
diff mercurial/cmdutil.py @ 36346:f62369667a7c
py3: use list comprehensions instead of filter where we need to eagerly filter
These two uses of filter() are then checked for truthiness, but on Python 3:
>>> bool(filter(None, []))
True
So we need to stop depending on that. Fortunately it's easy to replace
the filter with an equivalent list comprehension.
Differential Revision: https://phab.mercurial-scm.org/D2364
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 21 Feb 2018 10:10:02 -0500 |
parents | 428de1a59f2d |
children | ef6ae3f64c23 |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Wed Feb 21 10:08:35 2018 -0500 +++ b/mercurial/cmdutil.py Wed Feb 21 10:10:02 2018 -0500 @@ -1831,7 +1831,7 @@ else: self.revs.discard(value) ctx = change(value) - matches = filter(match, ctx.files()) + matches = [f for f in ctx.files() if match(f)] if matches: fncache[value] = matches self.set.add(value)