Patchwork [6,of,6] repoview: avoid processing the same rev twice in _getstatichidden

login
register
mail settings
Submitter Pierre-Yves David
Date April 3, 2015, 10:23 p.m.
Message ID <7accf9c57110d99e4e14.1428099831@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8491/
State Accepted
Commit 7c6f9097e2e03be6630d782114ac312264f7333a
Headers show

Comments

Pierre-Yves David - April 3, 2015, 10:23 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1428097278 25200
#      Fri Apr 03 14:41:18 2015 -0700
# Node ID 7accf9c57110d99e4e14a0552161a1d4bc652dcc
# Parent  1bc2f01364c0ffb2b2048d5d35d3c7d03d89caf7
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.
Durham Goode - April 3, 2015, 11:15 p.m.
On 4/3/15 3:23 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1428097278 25200
> #      Fri Apr 03 14:41:18 2015 -0700
> # Node ID 7accf9c57110d99e4e14a0552161a1d4bc652dcc
> # Parent  1bc2f01364c0ffb2b2048d5d35d3c7d03d89caf7
> 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.
This series looks good to me.  Feel free to clowncopter it (since I'm 
not currently set up to import patches from the mailing list).
Durham Goode - April 5, 2015, 7:38 p.m.
On 4/3/15 4:15 PM, Durham Goode wrote:
>
>
> On 4/3/15 3:23 PM, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>> # Date 1428097278 25200
>> #      Fri Apr 03 14:41:18 2015 -0700
>> # Node ID 7accf9c57110d99e4e14a0552161a1d4bc652dcc
>> # Parent  1bc2f01364c0ffb2b2048d5d35d3c7d03d89caf7
>> 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.
> This series looks good to me.  Feel free to clowncopter it (since I'm 
> not currently set up to import patches from the mailing list).
I got my clowncopter push stuff setup.  This series is pushed to the 
clowncopter.

Patch

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -39,10 +39,11 @@  def _getstatichidden(repo):
         # Skip heads which are public (guaranteed to not be hidden)
         heap = [-r for r in repo.changelog.headrevs() if getphase(repo, r)]
         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
             # removed 'rev' from the 'hidden' set, 'rev' is going to be hidden.
             blocker = rev not in hidden
@@ -50,12 +51,15 @@  def _getstatichidden(repo):
                 if parent == nullrev:
                     continue
                 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
 
 def _getdynamicblockers(repo):
     """Non-cacheable revisions blocking hidden changesets from being filtered.