Patchwork [4,of,6,py3] dirstate: use iter.__next__ instead of iter.next

login
register
mail settings
Submitter Pulkit Goyal
Date March 16, 2017, 4:13 a.m.
Message ID <69aafa5d3e0f109c7b50.1489637599@pulkit-goyal>
Download mbox | patch
Permalink /patch/19377/
State Changes Requested
Headers show

Comments

Pulkit Goyal - March 16, 2017, 4:13 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1489634873 -19800
#      Thu Mar 16 08:57:53 2017 +0530
# Node ID 69aafa5d3e0f109c7b501758381f65fd9b375196
# Parent  db48c50cb5831c7c1265296d8d6c8d589ed41689
dirstate: use iter.__next__ instead of iter.next

In Python 3 world, iter.next() is renamed to iter.__next__()
via Mercurial-devel - March 16, 2017, 4:59 a.m.
On Wed, Mar 15, 2017 at 9:13 PM, Pulkit Goyal <7895pulkit@gmail.com> wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1489634873 -19800
> #      Thu Mar 16 08:57:53 2017 +0530
> # Node ID 69aafa5d3e0f109c7b501758381f65fd9b375196
> # Parent  db48c50cb5831c7c1265296d8d6c8d589ed41689
> dirstate: use iter.__next__ instead of iter.next
>
> In Python 3 world, iter.next() is renamed to iter.__next__()

Will next(iter) do the same in both versions?

>
> diff -r db48c50cb583 -r 69aafa5d3e0f mercurial/dirstate.py
> --- a/mercurial/dirstate.py     Thu Mar 16 08:03:51 2017 +0530
> +++ b/mercurial/dirstate.py     Thu Mar 16 08:57:53 2017 +0530
> @@ -1115,7 +1115,10 @@
>              else:
>                  # We may not have walked the full directory tree above,
>                  # so stat and check everything we missed.
> -                nf = iter(visit).next
> +                if pycompat.ispy3:
> +                    nf = iter(visit).__next__
> +                else:
> +                    nf = iter(visit).next
>                  for st in util.statfiles([join(i) for i in visit]):
>                      results[nf()] = st
>          return results
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r db48c50cb583 -r 69aafa5d3e0f mercurial/dirstate.py
--- a/mercurial/dirstate.py	Thu Mar 16 08:03:51 2017 +0530
+++ b/mercurial/dirstate.py	Thu Mar 16 08:57:53 2017 +0530
@@ -1115,7 +1115,10 @@ 
             else:
                 # We may not have walked the full directory tree above,
                 # so stat and check everything we missed.
-                nf = iter(visit).next
+                if pycompat.ispy3:
+                    nf = iter(visit).__next__
+                else:
+                    nf = iter(visit).next
                 for st in util.statfiles([join(i) for i in visit]):
                     results[nf()] = st
         return results