Mercurial > public > mercurial-scm > hg
comparison mercurial/copies.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 | c02771617a70 |
children | a4f02a17420d |
comparison
equal
deleted
inserted
replaced
36345:f85e32a5e5c8 | 36346:f62369667a7c |
---|---|
683 | 683 |
684 # file is missing if it isn't present in the destination, but is present in | 684 # file is missing if it isn't present in the destination, but is present in |
685 # the base and present in the source. | 685 # the base and present in the source. |
686 # Presence in the base is important to exclude added files, presence in the | 686 # Presence in the base is important to exclude added files, presence in the |
687 # source is important to exclude removed files. | 687 # source is important to exclude removed files. |
688 missingfiles = filter(lambda f: f not in m1 and f in base and f in c2, | 688 filt = lambda f: f not in m1 and f in base and f in c2 |
689 changedfiles) | 689 missingfiles = [f for f in changedfiles if filt(f)] |
690 | 690 |
691 if missingfiles: | 691 if missingfiles: |
692 basenametofilename = collections.defaultdict(list) | 692 basenametofilename = collections.defaultdict(list) |
693 dirnametofilename = collections.defaultdict(list) | 693 dirnametofilename = collections.defaultdict(list) |
694 | 694 |