开发者

What to do when you have too many changes within a single patch in an hg mq the patch queue?

The purpose of the hg mq plugin is to be ab开发者_JS百科le to make perfect commits to your repository, not confusing the changes that you made in your absent-minded ADHD induced rambling through your code;

For instance....

I'm working on bug x when I notice bug y and start working on it instead. At this point you are supposed to create a new patch in the patch queue so as not to confuse the changes when it is hg qfinish committed to your repository.

Now suppose for a minute that you forget make the new patch and in the process hg qrefresh. Then later realizing your mistake you wish to separate the changes from that one patch into two patches.

I realize that it has to do with editing your patch file (and a new patch file) in the queue to separate the changes into separate patches and later commits. However, I'm not yet skilled at editing the diff patch files.

Where can I learn about this? And how might one go about this?


Another option (assuming it runs on your platform) is version 2.0 of TortoiseHG. The 'inappropriately' named Shelve utility allows for moving of chunks and files between patches, or into the working directory. It's available for Windows, Linux and possibly OSX.

http://tortoisehg.bitbucket.io/


As noted in this related SO question, check out the "Split a patch into multiple patches" section of the MQ tutorial.


You can activate the record extension, adding to .hgrc the following lines:

[extensions]
hgext.record =

You can clear your current patch with

hg qrefresh nothing

(note that the "nothing" is just a random string: the arguments to qrefresh is the list of files which must be included in the current patch, so anything that is not the name of a modified file will do - I usually use "0")

Now with hg qrecord <patchName> you can choose interactively which changes must go in the new patch. The remaining changes can then be added to another patch with qnew or another qrecord. You can finally use qpop, qfold or edit .hg/patches/series to merge and reorder the patches.


I have a shell alias, viq="vim $(hg root)/.hg/patches/", that I use for just these situations!

I'll just run viq to pull up the patches, then hand-edit the diff and move the hunks into other patches as appropriate.

I prefer this over interactive methods (eg, git add -i) because I don't feel as safe working from the interactive prompt as I do working from my editor (I know that my editor makes backups, has trivial undo, etc…).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜