如何使用mercurial队列将工作分成多个补丁?

Mar*_*tos 10 mercurial mercurial-queue

如果我一直在编写代码并忘记创建补丁系列,我该如何回顾性地创建补丁系列?到目前为止,唯一想到的是:

# Prepare and test the first batch of changes.
$ hg qrecord -m 'first batch' 1.patch
$ hg qnew -m 'stash downstream changes' stash-1.patch
$ hg qdelete -k temp-1.patch
$ make hello
cc     hello.c   -o hello
hello.c: In function ‘main’:
hello.c:4: error: syntax error at end of input
make: *** [hello] Error 1
$ echo '}' >> hello.c
$ make hello
cc     hello.c   -o hello
$ hg qrefresh

# Recover the stashed changes.
$ patch -p1 < .hg/patches/last.patch

# And around we go again!
$ hg qrecord -m 'second batch' 2.patch
$ hg qnew -m 'stash downstream changes' stash-2.patch
$ hg qdelete -k stash-2.patch
$ make hello
...
Run Code Online (Sandbox Code Playgroud)

这种非常麻烦的方法也是危险的.我可能会忘记-k接通qdelete,此时我会将我的前额撞到砖墙上几分钟,或者在qrecord操作过程中我可能会包含太多或太少.

有没有更好的办法?

(我真正喜欢的是能够hg qpop在我想要分割的补丁之前,并使用当前不存在的命令hg qunrecord,以交互方式将补丁从补丁中吸收到我的工作目录中.一旦我开心了随着变化,hg qnew -f可以在旧的前面挤出一个新的补丁.)

wie*_*rob 6

MQTutorial解释如何分割补丁.因此,您可以从当前工作中创建补丁并将其拆分为多个补丁.

  • 我通常做的是使用两个存储库和一个很好的视觉差异工具,如Beyond Compare.使用教程中的名称,我从使用OP的repo A开始,然后将A克隆到B.然后在AI`qpop -a`中,差异A和B,樱桃选择P1的变化从B复制到A ,`qnew -f P1`,然后复制其余的,`qnew -f P2`. (3认同)