Patchwork D2364: py3: use list comprehensions instead of filter where we need to eagerly filter

login
register
mail settings
Submitter phabricator
Date Feb. 22, 2018, 3:10 a.m.
Message ID <7a9b3a6125d94e857dcd1b68bd0ace14@localhost.localdomain>
Download mbox | patch
Permalink /patch/28224/
State Not Applicable
Headers show

Comments

phabricator - Feb. 22, 2018, 3:10 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf62369667a7c: py3: use list comprehensions instead of filter where we need to eagerly filter (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2364?vs=5944&id=5972

REVISION DETAIL
  https://phab.mercurial-scm.org/D2364

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/copies.py

CHANGE DETAILS




To: durin42, #hg-reviewers, pulkit, indygreg
Cc: mercurial-devel

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -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)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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)