如何在Mercurial中编辑错误的提交消息? [重复]

本文翻译自:How to edit incorrect commit message in Mercurial? [duplicate]

This question already has answers here : 这个问题已经在这里有了答案
Closed 2 years ago . 2年前关闭。

I am currently using TortoiseHg (Mercurial) and accidentally committed an incorrect commit message. 我当前正在使用TortoiseHg(Mercurial),并意外提交了错误的提交消息。 How do I go about editing this commit message in the repository? 如何在存储库中编辑此提交消息?


#1楼

参考:https://stackoom.com/question/2c5E/如何在Mercurial中编辑错误的提交消息-重复


#2楼

Good news: hg 2.2 just added git like --amend option. 好消息:hg 2.2 刚刚添加了 git之类的--amend选项。

and in tortoiseHg, you can use "Amend current revision" by select black arrow on the right of commit button 在tortoiseHg中,您可以通过选择“提交”按钮右侧的黑色箭头来使用“修改当前修订版”

一种


#3楼

Well, I used to do this way: 好吧,我曾经这样做:

Imagine, you have 500 commits, and your erroneous commit message is in r.498. 想象一下,您有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

#4楼

In TortoiseHg, right-click on the revision you want to modify. 在TortoiseHg中,右键单击要修改的修订。 Choose Modify History->Import MQ. 选择“修改历史记录”->“导入MQ”。 That will convert all the revisions up to and including the selected revision from Mercurial changesets into Mercurial Queue patches. 这样会将所有修订版本(包括从Mercurial变更集选择的修订版本)转换为Mercurial Queue补丁。 Select the Patch you want to modify the message for, and it should automatically change the screen to the MQ editor. 选择您要修改消息的补丁,它将自动将屏幕切换到MQ编辑器。 Edit the message which is in the middle of the screen, then click QRefresh. 编辑屏幕中间的消息,然后单击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. 最后,右键单击补丁,然后选择“修改历史记录”->“完成补丁”,这会将其从补丁转换回变更集。

Oh, this assumes that MQ is an active extension for TortoiseHG on this repository. 哦,这假设MQ是该存储库上TortoiseHG的有效扩展。 If not, you should be able to click File->Settings, click Extensions, and click the mq checkbox. 如果不是,您应该能够单击文件->设置,单击扩展名,然后单击mq复选框。 It should warn you that you have to close TortoiseHg before the extension is active, so close and reopen. 它应该警告您必须在扩展激活前关闭TortoiseHg,因此请关闭并重新打开。


#5楼

Rollback-and-reapply is realy simple solution, but it can help only with the last commit. 回滚和重新应用是非常简单的解决方案,但是它只能在最后一次提交时提供帮助。 Mercurial Queues is much more powerful thing (note that you need to enable Mercurial Queues Extension in order to use "hg q*" commands). Mercurial Queues功能更强大(请注意,您需要启用Mercurial Queues Extension才能使用“ hg q *”命令)。


#6楼

One hack i use if the revision i want to edit is not so old: 如果要编辑的修订版本不太旧,我可以使用一种技巧:

Let's say you're at rev 500 and you want to edit 497. 假设您的转速为500,而您想要编辑497。

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

Edit rev497 file and change the message. 编辑rev497文件并更改消息。 (It's after first lines preceded by "#") (在第一行之后加上“#”)

hg import rev497
hg import rev498
hg import rev499
hg import rev500
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章