refactor duplicated fill_mm() in checkout and merge-recursive