manifest: convert a recursive function to iterative one using stacks
I am debugging a memory issue from yesterday where hg update goes upto taking
22GB of memory on our internal treemanifest repository. This is an interesting
function and I saw memory consumption increasing while this function was
It's sometimes hard to understand a recursive function and also the profile
won't show you actual operations which took time, rather it will show you the
function again and again in profile.
I am yet to notice any memory consumption decrease with this patch, but I
believe this will help like in making this a generator.
Differential Revision: https://phab.mercurial-scm.org/D5413