There was a comment in the code that said "Trying to do both iter
and contains using the same visit heap and seen set is complex
enough that it slows down both. Keep them separate.". However, it
seems easy and efficient to make contains keep an iterator across
calls.
I couldn't measure any slowdown from hg bundle --all (which seem to
call lazyancestors.contains frequently).
1HG: --