How do I split work into multiple patches with mercurial queues?

我怕爱的太早我们不能终老 提交于 2019-12-04 02:59:36
wierob

The MQTutorial explains how to split patches. So you could create a patch from you current work and split it into several patches.

kuy

TortoiseHg has very useful feature "Hunk Selection" in Commit dialog for kind of this work:
http://tortoisehg.bitbucket.io/manual/2.0/commit.html#change-selection

I think the crecord extension will let you do this. It gives you an interactive curses based interface where you can choose exactly what's in a commit.

gavenkoa

Enable built-in extensions:

[extensions]
mq=
record=
shelve=

Then move MQ into working tree and split changes and remove original patch:

$ hg qpop my.patch
$ patch -p1 <.hg/patches/my.patch

$ hg qnew -i my1.patch
 ....
$ hg qnew -i my2.patch
 ....
$ hg qnew myN.patch   # last without interactive stuff

$ hg qdelete --keep my.patch

Between my$i.patch and my$((i+1)).patch you can use hg shelve/hg unshelve to test if project built and pass tests on top of my$i.patch without later changes!

If you find that something missing on this stage use hg qref on shelved changes or hg qref -i on unshelved changes!

See also Mercurial: move MQ patch to shelve?

First, install crecord because it is just a way way nicer way of splitting changes up.

$ hg qcrecord part1
$ hg qnew part2 # ok, slightly a lie at this point
$ hg qpop
$ echo "}" >> hello.c
$ hg qrefresh
$ hg qpush
$ hg qcrefresh # Keep just what you want in part2
$ ...

The only thing special to crecord here is the qcrefresh command. If you're not a curses fan, you can still do all of the same stuff here, just replace qcrefresh with hg qrefresh -X 're:.'. Or hg qrefresh -I aauuuuuggghhh if you'd prefer. (It's your "uncommit" using -X or -I.)

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