Merge 'add x' and 'remove y' into 'replace y with x'