用大模型+代码图谱自动解决代码合并冲突,更懂开发者意图。
Rover: Context-aware Conflict Resolution with LLM

- 构建多层代码属性图,捕捉跨文件依赖关系
- 通过图连通性聚类出有意义的上下文,提升准确率
- 在多个维度上优于现有工具,适合大型项目开发
代码合并是大规模项目中的关键挑战。现有方案如程序分析和机器学习虽有潜力,但存在明显局限:程序分析难以推断开发者的意图,依赖保守策略将未解决冲突留给人工处理;基于模型的方法因缺乏上下文感知,在涉及复杂依赖的冲突中表现不佳。为此,我们提出Rover,一个融合程序分析与大语言模型(LLMs)的新型冲突解决系统。为生成具备上下文感知的提示,我们设计了多层代码属性图(MtCPG),该表示能捕捉跨文件依赖,支持对特定冲突进行上下文分析。利用图连通性算法,Rover进一步将冲突代码及关联修改聚类为有意义的“上下文”,引导LLM生成更精准的解决方案。实验对比显示,Rover在字符、词汇和语义层面均优于独立的LLM、机器学习基线MergeGen以及建议工具WizardMerge(以邻近代码为上下文)。结果表明,Rover在冲突解决能力上全面领先。
原文摘要 · Abstract (English)
Code merging is a significant challenge, particularly in large-scale projects. Existing solutions, including program analysis and machine learning, show promise but face critical limitations. Program analysis lacks the ability to infer developers' intentions, relying on conservative strategies that offload unresolved conflicts for manual handling. Meanwhile, model-based approaches struggle with conflicts involving complex code dependencies due to insufficient contextual awareness. To address these gaps, we introduce Rover, a novel conflict resolution system that integrates program analysis with large language models (LLMs). To obtain context-aware prompts, we propose Multi-layer Code Property Graph (MtCPG), a new representation capturing inter-file dependencies and enabling contextual analysis for a given conflict. Using graph connectivity algorithms, Rover further clusters conflicting code and associated changes into meaningful "contexts" that guide the LLM in generating accurate resolutions. We compared Rover with standalone LLMs, machine learning baseline MergeGen, and suggestion provider tool WizardMerge with adjacent code as the contexts. Evaluation results show that Rover surpasses all of these approaches in terms of conflict resolution, achieving higher similarity to ground-truth resolutions at character, lexical, and semantic levels.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。