memory-usage: fix `hg log --follow --rev R F` space complexity
When running hg log --follow --rev REVS FILES
, the log code will walk the
history of all FILES starting from the file revisions that exists in each REVS.
Before doing so, it looks if the files actually exists in the target revisions. To do so, it opens the manifest of each revision in REVS to look up if we find the associated items in FILES.
Before this changeset this was done in a way that created a changectx for each target revision, keeping them in memory while we look into each file.
If the set of REVS is large, this means keeping the manifest for each entry in
REVS in memory. That can be large… if REV is in the form ::X
, this can quickly
become huge and saturate the memory. We have seen usage allocating 2GB per
second until memory runs out.
So this changeset invert the two loop so that only one revision is kept in memory during the operation. This solve the memory explosion issue.