Mercurial - 使用类似于货架的队列?
我最近开始使用 MQ,因为我喜欢处理独立补丁并在不影响存储库的情况下提交的想法,直到变更集足够完善为止。在此之前,我曾经使用过 Mercurial 的书架扩展,但发现它有点不稳定。我仍在 MQ 中尝试弄清楚如何使补丁彼此分离,并以不特定的顺序以及跨不同的分支应用它们。这是我的正常流程 -
1. 开始开发新补丁:
hg qnew fix-bug-1234 -m "fix bug 1234"
# do some work
hg qrefresh
2. 获取要处理的新功能/错误:
hg qpop fix-bug-1234
hg qnew some-feature -m "implement feature X"
# some work on feature X (perhaps in a different branch)
hg qrefresh
3. 在此时,我想重新开始修复错误,并把功能工作放在一边。我认为这很简单:
hg qpop some-feature
hg qpush fix-bug-1234
# wrap up bug fix
hg qfinish fix-bug-1234
# get back to work on feature
但是,MQ 似乎总是使用该系列中创建的最新补丁,并且无论我使用的 qpop/qpush 命令如何都应用它。我应该注意到,我处理的文件也是完全独立的(尽管它们有时可能是相同的)。
我在这里错过了什么吗?我应该为此使用 hg qqueue 吗?谢谢。
I've recently started working with MQ as I like the idea of working on isolated patches and committing without affecting the repo until the changeset is refined enough. Before that, I used to work with Mercurial's shelves extension, but found it a bit unstable. What I'm still trying to figure out in MQ is how to keep patches separate from each other and apply them in no particular order, and across different branches. Here's my normal flow -
1. Start working on a new patch:
hg qnew fix-bug-1234 -m "fix bug 1234"
# do some work
hg qrefresh
2. Get a new feature/bug to work on:
hg qpop fix-bug-1234
hg qnew some-feature -m "implement feature X"
# some work on feature X (perhaps in a different branch)
hg qrefresh
3. At this point, I'd like to get back to working on bugfix, and put aside the feature work. I thought it's as simple as:
hg qpop some-feature
hg qpush fix-bug-1234
# wrap up bug fix
hg qfinish fix-bug-1234
# get back to work on feature
However, MQ seems to always use the latest patch created in the series, and apply it regardless of the qpop/qpush command I'm using. I should note that the files I work on are completely separate as well (though they can sometimes be the same).
Am I missing something here? Should I be using hg qqueue
for this? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用守卫。它们允许您维护补丁的顺序,而无需重新排列您的
系列
文件,并有选择地仅应用补丁的子集,仍然以堆栈排序的方式。您的情况的一个例子是:
此时,您处于这样的情况:补丁
feature
位于堆栈中的bugfix
之前。现在,您可以使用守卫来选择其中之一,并在两者之间切换:如果您想使用
feature
:如果您想使用
bugfix
:请注意由于您选择了正向防护
bugfixguard
,MQ 跳过了功能
(因为它的正向防护与所选的不同)并应用了改为补丁bugfix
(这确实匹配选定的后卫)。使用防护时,一些有用的工具是
hg qseries -v
,对于受防护的未应用补丁,它将显示G
而不是通常的U
,和 hg qselect -l ,它将显示与每个补丁关联的防护。You could use guards. They allow you to maintain an ordering of patches without rearranging your
series
file, and selectively apply only a subset of patches, still in a stack-ordered fashion.An example in your case would be:
At this point, you're in a situation where patch
feature
comes beforebugfix
in your stack. Now you can use guards to select one or the other, and switch between the two:If you want to work on
feature
:If you want to work on
bugfix
:Note that since you selected the positive guard
bugfixguard
, MQ leap-frogged overfeature
(because it's positive guard was different than the one selected) and applied the patchbugfix
instead (which did match the selected guard).Some useful tools when working with guards are
hg qseries -v
, which will display aG
instead of the usualU
for a guarded, unapplied patch, andhg qselect -l
which will display the guards associated with each patch.hg qpop -a
从堆栈中删除所有补丁hg qpush --move some-patch
以应用“some-patch”,而不应用之前可能存在的任何其他补丁它在补丁堆栈中hg qpop -a
to remove all patches from the stackhg qpush --move some-patch
to apply "some-patch" without applying whatever other patches may be before it in the patch stack不,你没有错过任何东西。 mq 扩展确实做出了一个非常强有力的假设,即补丁队列是线性的。如果您要创建多补丁功能/修复,那么
qqueue
就可以了……但是如果您的功能/修复只是单个补丁,并且您希望能够应用一个补丁而不应用其他补丁,重新排列.hg/patches/series
(它存储补丁的应用顺序)可能会更容易。我这样做(和手动编辑补丁)足够多,以至于我有一个 shell 别名:
或者,如果您不介意同时应用多个补丁,您可以使用 qgoto:
No, you aren't missing anything. The
mq
extension does make a pretty strong assumption that patch queues are linear. If you're going to be creating multi-patch features/fixes thenqqueue
would work… But if your features/fixes are just single patches and you want to be able to apply one with out applying the others, it might be easier to just re-arrange.hg/patches/series
(which stores the order that patches will be applied).I do this (and hand-editing patches) enough that I've got a shell alias:
Alternately, if you don't mind applying multiple patches at the same time, you could use
qgoto
: