# HG changeset patch # User Yuya Nishihara # Date 2018-09-10 12:46:19 # Node ID fd9029d36c41e77002ca9647827c11b86f896d8c # Parent f6bcb4f9cd3cd0b216fb96635c6c12a7bf10c3d2 ancestor: return early from _lazyancestorsiter() when reached to stoprev There's no need to empty the heap. diff --git a/mercurial/ancestor.py b/mercurial/ancestor.py --- a/mercurial/ancestor.py +++ b/mercurial/ancestor.py @@ -281,12 +281,13 @@ def _lazyancestorsiter(parentrevs, initr while visit: current = -nextitem(visit) - if current >= stoprev: - yield current - for parent in parentrevs(current): - if parent not in seen: - schedule(visit, -parent) - see(parent) + if current < stoprev: + break + yield current + for parent in parentrevs(current): + if parent not in seen: + schedule(visit, -parent) + see(parent) class lazyancestors(object): def __init__(self, pfunc, revs, stoprev=0, inclusive=False):