Patchwork [1,of,5] context.walk: call util.all() a generator, not a list

login
register
mail settings
Submitter Martin von Zweigbergk
Date March 18, 2015, 8:27 p.m.
Message ID <2ecdb84c187ea3044f61.1426710460@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8150/
State Superseded
Headers show

Comments

Martin von Zweigbergk - March 18, 2015, 8:27 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1426695986 25200
#      Wed Mar 18 09:26:26 2015 -0700
# Node ID 2ecdb84c187ea3044f61fec65ceaeb1193a72582
# Parent  b7f936f47f2b104a60840bae571e009742126afc
context.walk: call util.all() a generator, not a list

The file set can be large, so avoid going through the entire file set
when a file happens not to be in the context.
Martin von Zweigbergk - March 18, 2015, 10:16 p.m.
On Wed, Mar 18, 2015 at 1:27 PM Martin von Zweigbergk <martinvonz@google.com>
wrote:

> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1426695986 25200
> #      Wed Mar 18 09:26:26 2015 -0700
> # Node ID 2ecdb84c187ea3044f61fec65ceaeb1193a72582
> # Parent  b7f936f47f2b104a60840bae571e009742126afc
> context.walk: call util.all() a generator, not a list
>

Missing a "with" before "a generator". Sorry.


>
> The file set can be large, so avoid going through the entire file set
> when a file happens not to be in the context.
>
> diff -r b7f936f47f2b -r 2ecdb84c187e mercurial/context.py
> --- a/mercurial/context.py      Sun Mar 15 21:52:35 2015 -0400
> +++ b/mercurial/context.py      Wed Mar 18 09:26:26 2015 -0700
> @@ -594,7 +594,7 @@
>
>          # avoid the entire walk if we're only looking for specific files
>          if fset and not match.anypats():
> -            if util.all([fn in self for fn in fset]):
> +            if util.all(fn in self for fn in fset):
>                  for fn in sorted(fset):
>                      if match(fn):
>                          yield fn
>

Patch

diff -r b7f936f47f2b -r 2ecdb84c187e mercurial/context.py
--- a/mercurial/context.py	Sun Mar 15 21:52:35 2015 -0400
+++ b/mercurial/context.py	Wed Mar 18 09:26:26 2015 -0700
@@ -594,7 +594,7 @@ 
 
         # avoid the entire walk if we're only looking for specific files
         if fset and not match.anypats():
-            if util.all([fn in self for fn in fset]):
+            if util.all(fn in self for fn in fset):
                 for fn in sorted(fset):
                     if match(fn):
                         yield fn