You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mercurial最终合并提交后预期文件缺失的原因排查

Mercurial合并后文件丢失问题

工作中遇到Mercurial的异常问题:预期存在的文件在最终合并提交后消失。已构造复现场景:default分支经最终合并后,foo.txt本应存在——合并的一个父节点因早前提交删除了该文件,另一个父节点在删除提交后的提交中恢复了它,但实际合并后文件仍处于删除状态。

提交序列示意图

展示复现问题的仓库提交历史

复现仓库的构建命令

hg init

echo foo > foo.txt
echo bar > bar.txt
hg add foo.txt bar.txt
hg commit -m "Add foo.txt and bar.txt"

hg branch feature
hg remove foo.txt
hg commit -m "Remove foo.txt"

echo barbar > bar.txt
hg commit -m "Modify bar.txt"

hg update default
echo baz > baz.txt
hg add baz.txt
hg commit -m "Add baz.txt"

hg update feature
hg merge default
hg commit -m "Merge default"

echo foo > foo.txt
hg add foo.txt
hg commit -m "Restore foo.txt"

hg update default
echo bazbaz > baz.txt
hg commit -m "Modify baz.txt"

hg update 0
hg merge 2
hg commit -m "Merge feature"

hg merge
hg commit -m "Merge"

hg merge feature
hg commit -m "Merge feature"   

最终合并后的工作目录状态

> ls
bar.txt  baz.txt

补充说明

  • 该问题影响Mercurial 5.9.3和6.3.2版本,但5.0.2版本不受此问题影响
  • 在Mercurial社区频道讨论后,修改复现步骤(在文件创建后添加编辑操作),结果仍出现foo.txt缺失的情况

内容的提问来源于stack exchange,提问作者Bjartr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 19:26:16