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

Yuya Nishihara yuya at tcha.org
Thu Mar 16 10:42:53 EDT 2017


On Thu, 16 Mar 2017 13:23:25 +0530, Pulkit Goyal wrote:
> # 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))

Perhaps we should make commonancestorsheads() return a list so we'll never
have another iterator-vs-list bug.


More information about the Mercurial-devel mailing list