# HG changeset patch # User Yuya Nishihara # Date 2017-06-17 23:59:09 # Node ID d3d36bcdf0361f874d91516204fd8a778bd58c72 # Parent 08e2793d9f654fda6276c894318bb797cafd08e0 dagop: just compare with the last value to deduplicate input of revancestors() Since we're using a max heap, the current rev should be a duplicate only if it equals to the previous one. We don't have to maintain the whole seen set. # reverse(ancestors(tip)) using hg repo 0) 0.086420 1) 0.081051 diff --git a/mercurial/dagop.py b/mercurial/dagop.py --- a/mercurial/dagop.py +++ b/mercurial/dagop.py @@ -37,15 +37,15 @@ def _genrevancestors(repo, revs, followf if inputrev is not None: heapq.heappush(pendingheap, -inputrev) - seen = set() + lastrev = None while pendingheap: currev = -heapq.heappop(pendingheap) if currev == inputrev: inputrev = next(irevs, None) if inputrev is not None: heapq.heappush(pendingheap, -inputrev) - if currev not in seen: - seen.add(currev) + if currev != lastrev: + lastrev = currev yield currev try: for prev in cl.parentrevs(currev)[:cut]: