[PATCH 3 of 3 py3] context: explicitly evaluate list returned by map

Pulkit Goyal 7895pulkit at gmail.com
Thu Mar 16 03:53:25 EDT 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1489639281 -19800
#      Thu Mar 16 10:11:21 2017 +0530
# Node ID 8d85d7ca9fd3eea90a2f09c7d471fc3f3c78d430
# Parent  de18c43f8ce17d52542e6df233e809b6a6ee0a07
context: explicitly evaluate list returned by map

On python 3, map returns an iterator so we need to convert it to list before
finding the len or subscripting it.

After this `hg status --all` works on Python 3.

diff -r de18c43f8ce1 -r 8d85d7ca9fd3 mercurial/context.py
--- a/mercurial/context.py	Thu Mar 16 10:10:00 2017 +0530
+++ b/mercurial/context.py	Thu Mar 16 10:11:21 2017 +0530
@@ -622,7 +622,7 @@
         n2 = c2._node
         if n2 is None:
             n2 = c2._parents[0]._node
-        cahs = self._repo.changelog.commonancestorsheads(self._node, n2)
+        cahs = list(self._repo.changelog.commonancestorsheads(self._node, n2))
         if not cahs:
             anc = nullid
         elif len(cahs) == 1:
diff -r de18c43f8ce1 -r 8d85d7ca9fd3 mercurial/util.py
--- a/mercurial/util.py	Thu Mar 16 10:10:00 2017 +0530
+++ b/mercurial/util.py	Thu Mar 16 10:11:21 2017 +0530
@@ -2920,7 +2920,7 @@
             del dirs[base]
 
     def __iter__(self):
-        return self._dirs.iterkeys()
+        return iter(self._dirs)
 
     def __contains__(self, d):
         return d in self._dirs


More information about the Mercurial-devel mailing list