Add size cap in needs_merge

The caller can now cap the list of files that need merging so the size
of the files in the non-expired list does not exceed it.
This can be used to avoid massive, extremely long merges.