merge_bases_many(): split out the logic to paint history