【问题标题】:Mercurial - Working with Queues similar to Shelves?Mercurial - 使用类似于货架的队列?
【发布时间】:2011-10-31 07:04:58
【问题描述】:

我最近开始使用 MQ,因为我喜欢在不影响 repo 的情况下处理隔离补丁和提交的想法,直到变更集足够细化。在此之前,我曾经使用 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 吗?谢谢。

【问题讨论】:

    标签: mercurial workflow shelve mercurial-queue


    【解决方案1】:

    您可以使用guards。它们允许您在不重新排列 series 文件的情况下维护补丁程序的顺序,并有选择地仅应用补丁程序的子集,仍然以堆栈排序的方式。

    你的例子是:

    hg qnew bugfix
    # ..hack hack..
    hg qrefresh
    # want to switch over to working on some feature now
    hg qpop
    hg qnew feature
    # ..hack hack..
    hg qrefresh
    

    此时,您的堆栈中的补丁feature 位于bugfix 之前。现在您可以使用守卫来选择一个或另一个,并在两者之间切换:

    hg qpop -a
    hg qguard feature +featureguard
    hg qguard bugfix +bugfixguard
    

    如果你想在feature工作:

    hg qselect featureguard
    hg qpush
    applying feature
    now at: feature
    

    如果你想在bugfix工作:

    hg qpop -a
    hg qselect bugfixguard
    hg qpush
    applying bugfix
    now at: bugfix
    

    请注意,由于您选择了 positive guard bugfixguard,MQ 跳过了 feature(因为它的positive guard 与选择的不同)并应用了补丁bugfix (确实与选定的守卫相匹配)。

    使用保护时的一些有用工具是hg qseries -v,它将显示G,而不是通常的U,用于保护未应用的补丁,以及hg qselect -l,它将显示与每个补丁关联的保护。

    【讨论】:

      【解决方案2】:
      1. 执行hg qpop -a 以从堆栈中删除所有补丁
      2. 执行 hg qpush --move some-patch 以应用“一些补丁”,而不应用补丁堆栈中可能存在的任何其他补丁

      【讨论】:

        【解决方案3】:

        不,你没有错过任何东西。 mq 扩展确实做了一个相当强的假设,即补丁队列是线性的。如果您要创建多补丁功能/修复,那么qqueue 会起作用……但是如果您的功能/修复只是单个补丁,并且您希望能够应用其中一个而不应用其他补丁,那可能会更容易只需重新排列.hg/patches/series(它存储应用补丁的顺序)。

        我这样做(和手工编辑补丁)足够我有一个 shell 别名:

        alias viq='vim $(hg root)/.hg/patches/series'
        

        或者,如果您不介意同时应用多个补丁,您可以使用qgoto

        $ hg qser
        0 U bug-1234
        1 U feature-4321
        $ hg qgoto feature-4321
        $ hg qser
        0 A bug-1234
        1 A feature-4321
        

        【讨论】:

          猜你喜欢
          • 2011-07-06
          • 2013-02-21
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-09-06
          • 1970-01-01
          • 2015-05-04
          相关资源
          最近更新 更多