discovery: move cl.hasnode outside of the for-loop
IIUC, resolving attributes for changelog can lead to some overhead. So this
patch moves that to outside of a for-loop.
Differential Revision: https://phab.mercurial-scm.org/D6147
discovery: prevent deleting items from a dictionary
Removing elements from Python dictionary is expensive. So let's prevent adding
them instead.
I added a newline to make code look a bit better.
Differential Revision: https://phab.mercurial-scm.org/D6146