Patchwork [5,of,9] py3: replace dict.iterkeys() with iter(dict)

login
register
mail settings
Submitter Pulkit Goyal
Date June 15, 2017, 9:34 p.m.
Message ID <8c2bdaf9a1901676753e.1497562487@workspace>
Download mbox | patch
Permalink /patch/21408/
State Accepted
Headers show

Comments

Pulkit Goyal - June 15, 2017, 9:34 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1497557807 -19800
#      Fri Jun 16 01:46:47 2017 +0530
# Node ID 8c2bdaf9a1901676753ed57df5a99299ded8fa08
# Parent  bdab6e36523f1e547f1753c67d84b3149fea59fe
py3: replace dict.iterkeys() with iter(dict)

dict.iterkeys() does not exists on Python 3.
Yuya Nishihara - June 16, 2017, 1:51 p.m.
On Fri, 16 Jun 2017 03:04:47 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1497557807 -19800
> #      Fri Jun 16 01:46:47 2017 +0530
> # Node ID 8c2bdaf9a1901676753ed57df5a99299ded8fa08
> # Parent  bdab6e36523f1e547f1753c67d84b3149fea59fe
> py3: replace dict.iterkeys() with iter(dict)
> 
> dict.iterkeys() does not exists on Python 3.
> 
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -838,7 +838,7 @@
>          for copykey, copyvalue in copy.iteritems():
>              if copyvalue in relevantfiles:
>                  relevantfiles.add(copykey)
> -        for movedirkey in movewithdir.iterkeys():
> +        for movedirkey in iter(movewithdir):

Nit: No explicit iter() needed. Updated in flight.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -838,7 +838,7 @@ 
         for copykey, copyvalue in copy.iteritems():
             if copyvalue in relevantfiles:
                 relevantfiles.add(copykey)
-        for movedirkey in movewithdir.iterkeys():
+        for movedirkey in iter(movewithdir):
             relevantfiles.add(movedirkey)
         filesmatcher = scmutil.matchfiles(repo, relevantfiles)
         matcher = matchmod.intersectmatchers(matcher, filesmatcher)