我目前正在使用TortoiseHg (Mercurial),不小心提交了一个错误的提交消息。如何在存储库中编辑这条提交消息?


当前回答

回滚-重新应用是一个非常简单的解决方案,但它只对最后一次提交有帮助。Mercurial Queues功能强大得多(注意,为了使用“hg q*”命令,您需要启用Mercurial Queues Extension)。

其他回答

In TortoiseHg, right-click on the revision you want to modify. Choose Modify History->Import MQ. That will convert all the revisions up to and including the selected revision from Mercurial changesets into Mercurial Queue patches. Select the Patch you want to modify the message for, and it should automatically change the screen to the MQ editor. Edit the message which is in the middle of the screen, then click QRefresh. Finally, right click on the patch and choose Modify History->Finish Patch, which will convert it from a patch back into a change set.

哦,这里假设MQ是这个存储库上TortoiseHG的活动扩展。如果没有,您应该能够单击File->Settings,单击Extensions,然后单击mq复选框。它应该警告你,你必须关闭TortoiseHg之前的扩展是活跃的,所以关闭并重新开放。

我是这样做的。首先,不要强迫你的改变,否则你就不走运了。抓取并安装崩溃扩展。提交另一个虚拟变更集。然后使用折叠将前两个更改集合并为一个。它将提示您输入一条新的提交消息,为您提供您已经拥有的作为起点的消息。您已经有效地更改了原来的提交消息。

如果我想编辑的版本不是那么旧,我会使用一个hack:

假设你的转速是500,而你想编辑497。

hg export -o rev497 497
hg export -o rev498 498
hg export -o rev499 499
hg export -o rev500 500

编辑rev497文件并更改消息。(它位于以“#”开头的第一行之后)

hg import rev497
hg import rev498
hg import rev499
hg import rev500

我以前是这么做的:

想象一下,您有500个提交,错误的提交消息在r.498中。

hg qimport -r 498:tip
hg qpop -a
joe .hg/patches/498.diff
(change the comment, after the mercurial header)
hg qpush -a
hg qdelete -r qbase:qtip

我知道这是一个老帖子,你把问题标记为答案。我正在寻找同样的事情最近,我发现histedit扩展非常有用。这个过程解释如下:

http://knowledgestockpile.blogspot.com/2010/12/changing-commit-message-of-revision-in.html