x/tools: implement three-way merge and use in all tools that apply fixes #68765
Labels
Analysis
Issues related to static analysis (vet, x/tools/go/analysis)
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Refactoring
Issues related to refactoring tools
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
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:
@pjweinb @findleyr @timothy-king
The text was updated successfully, but these errors were encountered: