rebase: extract merge code to new source file