# HG changeset patch # User Augie Fackler # Date 1519225802 18000 # Node ID f62369667a7cbe3b1e7ee1fb4f95e4ca880c15f1 # Parent f85e32a5e5c869c248167a72518a6cc3d856b002 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 diff -r f85e32a5e5c8 -r f62369667a7c mercurial/cmdutil.py --- 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) diff -r f85e32a5e5c8 -r f62369667a7c mercurial/copies.py --- a/mercurial/copies.py Wed Feb 21 10:08:35 2018 -0500 +++ b/mercurial/copies.py Wed Feb 21 10:10:02 2018 -0500 @@ -685,8 +685,8 @@ # the base and present in the source. # Presence in the base is important to exclude added files, presence in the # source is important to exclude removed files. - missingfiles = filter(lambda f: f not in m1 and f in base and f in c2, - changedfiles) + filt = lambda f: f not in m1 and f in base and f in c2 + missingfiles = [f for f in changedfiles if filt(f)] if missingfiles: basenametofilename = collections.defaultdict(list)