【问题标题】:Why is the file I expect to be present missing after the final merge commit in Mercurial?为什么在 Mercurial 中最终合并提交后我希望存在的文件丢失了?
【发布时间】:2023-01-30 05:23:41
【问题描述】:

我在工作中遇到了 Mercurial 的情况,我希望文件存在,但它不存在,我想更好地理解为什么。我已经整理了这个问题的重现。在此重现中,我希望文件 foo.txt 在最终合并后默认存在,因为合并的一个父级不存在该文件,因为它较早被删除,而另一个父级由于提交而将其添加回去那事发生了删除文件的提交。相反,该文件仍然被删除,为什么?

这是提交序列的图像:

下面是从空目录到在该状态下拥有 Mercurial 存储库的实际命令。

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

【问题讨论】:

    标签: merge version-control mercurial merge-conflict-resolution


    【解决方案1】:

    我只是将 repro 中的步骤粘贴到此处的终端中并尝试了(两次),但它没有重现所描述的问题:foo.txt 存在。

    最终结果是一个工作目录,其中包含:

    C:Usersbcdesource	est>dir
    ...
     Directory of C:Usersbcdesource	est
    
    01/29/2023  04:08 PM    <DIR>          .
    01/29/2023  04:07 PM    <DIR>          ..
    01/29/2023  04:08 PM    <DIR>          .hg
    01/29/2023  04:07 PM                 0 .hgignore
    01/29/2023  04:08 PM                 9 bar.txt
    01/29/2023  04:08 PM                 9 baz.txt
    01/29/2023  04:08 PM                 6 foo.txt
                   4 File(s)             24 bytes
    

    THG 中的图形看起来与问题中的图形相同。

    我碰巧在 Windows 上使用 HG 5.0.2。我怀疑版本或操作系统是否相关(?)

    【讨论】:

      猜你喜欢
      • 2012-08-17
      • 1970-01-01
      • 2021-11-22
      • 1970-01-01
      • 1970-01-01
      • 2016-02-25
      • 2015-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多