【问题标题】:Mercurial annotate/blame gives incorrect originating revisionMercurial 注释/责备给出了不正确的原始修订
【发布时间】:2026-01-31 19:20:09
【问题描述】:

我最近在跟踪负责源文件中特定行的变更集时遇到了问题。 hg blame 给了我一个从未合并到我感兴趣的分支中的修订版。

我发现,如果之前进行了类似的不相关更改,Mercurial 仍会将其显示为原始修订。这是一个错误还是应该表现得像这样?如果是后者,你能解释一下原因吗?

这是最简单的例子:

hg init test
cd test

# Create a new file that has 3 lines
echo "111\n222\n333" > test.txt
hg commit -Am "Original file"

# Append "444" to the file
echo "444" >> test.txt
hg commit -m "Abandoned change"

# Go back to the first revision and append the same "444" to the file
hg up 0
echo "444" >> test.txt
hg commit -m "Actual change"

这是回购的样子:

$ hg glog
@  changeset:   2:1b16b07e058e
|  tag:         tip
|  parent:      0:e58635de081c
|  user:        Nobody <nobody@nowhere.org>
|  date:        Tue Nov 20 17:17:41 2012 +0100
|  summary:     Actual change
|
| o  changeset:   1:b02ee64b2e2d
|/   user:        Nobody <nobody@nowhere.org>
|    date:        Tue Nov 20 17:17:41 2012 +0100
|    summary:     Abandoned change
|
o  changeset:   0:e58635de081c
   user:        Nobody <nobody@nowhere.org>
   date:        Tue Nov 20 17:17:41 2012 +0100
   summary:     Original file

现在,当我运行 hg blame 时,我希望看到最后一行来自变更集 2,而不是变更集 1。

$ hg blame test.txt
0: 111
0: 222
0: 333
1: 444

【问题讨论】:

    标签: mercurial blame


    【解决方案1】:

    这不是预期的行为,您遇到了 Bug 1839

    【讨论】: