Patchwork [2,of,9,py3,v3] phases: explicitly evaluate list returned by map

login
register
mail settings
Submitter Augie Fackler
Date March 12, 2017, 5:59 p.m.
Message ID <d656211a72279aa55428.1489341550@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/19191/
State Accepted
Headers show

Comments

Augie Fackler - March 12, 2017, 5:59 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1489283600 18000
#      Sat Mar 11 20:53:20 2017 -0500
# Node ID d656211a72279aa55428121be114b4059e7117ab
# Parent  b2106f4f2502bc94defa43e33c7b9b18fe726f95
phases: explicitly evaluate list returned by map

On Python 3 map() returns a generator, which bool()s to true even if
it had an empty input set. Work around this by using list() on the
map() result.

Patch

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -213,7 +213,7 @@  class phasecache(object):
         self._phaserevs = revs
         self._populatephaseroots(repo)
         for phase in trackedphases:
-            roots = map(repo.changelog.rev, self.phaseroots[phase])
+            roots = list(map(repo.changelog.rev, self.phaseroots[phase]))
             if roots:
                 for rev in roots:
                     revs[rev] = phase