Mercurial: How to subsequently make a change to a changeset summary after it has been checked in? [duplicate]

一笑奈何 提交于 2020-01-15 11:05:17

问题


Possible Duplicate:
Is it possible to edit a summary after a commit using TortoiseHg?

In Mercurial, if I forget to include the defect # in a check-in summary, how do you change the summary of a previously checked-in changeset, besides tweaking a flat-file and checking in a subsequent changeset just to comment on the previous check-in?

Using TortoiseHG.


回答1:


the appropriate way to do this is to use histedit. Histedit allows you to remove, modify, combine or otherwise edit your previous commits.

Histedit does not ship with Mercurial and it cannot be used with TortoiseHg, but the usage is very simple:

> hg histedit <rev>

where is the revision you want to change the comment on. Histedit will generate a list of changesets and show you their SHA1. Besides each changeset there is a word indicating what histedit will do with each changeset once you close the text window. Next to the changeset you want to modify - replace 'pick' with 'edit'. Close the text window and then issue this command:

> hg histedit --continue

and another text window will appear containing the log message. Change the message to whatever you want. You can do this for multiple changesets in one go, provided the files have not been shared yet. This is a pretty trivial use of histedit, more complicated uses involved combining commits or removing a portion of some commit.

EDIT 4/24/2011: Mercurial queues seems to be a more acceptable/supported way to perform a task like this. Check here for information on the mq extension.




回答2:


If you haven't shared the changeset, you can use rollback and/or strip to undo the changesets, then redo them correctly. rollback will undo a single changeset, while strip removes a arbitrary changeset, and all descendants.

Again, do not do this if you have already shared/pushed the changesets, or it can cause confusion.

In TortoiseHG, rollback is in the Recovery dialog, and strip is available in the revision context menu if you enable MQ.



来源:https://stackoverflow.com/questions/3604743/mercurial-how-to-subsequently-make-a-change-to-a-changeset-summary-after-it-has

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!