Description
When analysis and refactoring tools suggest multiple fixes to the same file, those fixes should be treated as independent changes, each analogous to a separate CL. Just as multiple CLs are resolved into a linear sequence using a tool such as diff3 or git-mergetool, our fixes should be reconciled intelligently too. For example, two fixes that add the same import should compose to a single diff that adds the desired import only once.
Merging two changes may fail; in that case, the (arbitrary) winner should be applied, and the loser skipped and reported to the caller.
The task of this issue is to design and implement a three-way merge algorithm and use it from all our tools (multichecker, analysistest, gopls, etc) that produce multiple independent edits. A poor-quality implementation (e.g. fail on any conflict) may serve as a temporary placeholder for a more sophisticated one (e.g. fork+exec diff3 or git-mergetool, or implement the diff3 algorithm atop x/tools/internal/diff/lcs).
For more background, see: