changeset 24620:7c6f9097e2e0

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 03 Apr 2015 14:41:18 -0700
parents ad6dea5d96f2
children 1e05f11619bb
files mercurial/repoview.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/repoview.py	Fri Apr 03 14:37:52 2015 -0700
+++ b/mercurial/repoview.py	Fri Apr 03 14:41:18 2015 -0700
@@ -43,6 +43,7 @@
         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 @@
                 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