# HG changeset patch # User Pierre-Yves David # Date 2015-04-03 21:41:18 # Node ID 7c6f9097e2e03be6630d782114ac312264f7333a # Parent ad6dea5d96f219ab4cdd12155081b2ba1879dbe6 repoview: avoid processing the same rev twice in _getstatichidden If a rev had multiple children, it would be added to the heap multiple times. We now ensure it is added only once. diff --git a/mercurial/repoview.py b/mercurial/repoview.py --- a/mercurial/repoview.py +++ b/mercurial/repoview.py @@ -43,6 +43,7 @@ def _getstatichidden(repo): heapq.heapify(heap) heappop = heapq.heappop heappush = heapq.heappush + seen = set() # no need to init it with heads, they have no children while heap: rev = -heappop(heap) # All children have been processed so at that point, if no children @@ -54,8 +55,11 @@ def _getstatichidden(repo): if blocker: # If visible, ensure parent will be visible too hidden.discard(parent) - # Skip nodes which are public (guaranteed to not be hidden) - if getphase(repo, rev): + # - Avoid adding the same revision twice + # - Skip nodes which are public (guaranteed to not be hidden) + pre = len(seen) + seen.add(parent) + if pre < len(seen) and getphase(repo, rev): heappush(heap, -parent) return hidden