Mercurial 队列特定命令是否等同于带有 --mq 参数的 Mercurial 命令?

发布于 2024-10-17 03:56:16 字数 122 浏览 9 评论 0原文

我正在尝试学习 Mercurial 队列,但我对一堆“hg q*”命令和许多带有“--mq”参数的普通 hg 命令感到困惑。我认为 --mq 参数是为了替换一些 q* 命令,但我不确定。似乎没有关于(新的?)首选方法的教程或文档。

I'm trying to learn Mercurial Queues and I'm confused by there being both a bunch of "hg q*" commands and also many normal hg commands with the "--mq" parameter. I think that the --mq parameter is meant to replace some of the q* commands, but I'm not sure. There doesn't seem to be a tutorial or documentation on the (new?) preferred methods.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

太傻旳人生 2024-10-24 03:56:16

--mq 选项会影响所有将存储库作为参数的命令 - 它实际上将目标存储库更改为 $(hg root)/.hg/patches,因此,它实际上与运行任何 Mercurial 命令相同:

hg --repository $(hg root)/.hg/patches ....

因此,每个具有 -R/--repository 选项的命令都有一个 --mq 选项,并且不需要修改即可获得一。您之前在 Mercurial 中使用过的任何命令:commit、push、pull、summary、id 等都可以采用 --mq。这是相关的python代码:

def mqcommand(orig, ui, repo, *args, **kwargs):
    """Add --mq option to operate on patch repository instead of main"""

    # some commands do not like getting unknown options
    mq = kwargs.pop('mq', None)

    if not mq:
        return orig(ui, repo, *args, **kwargs)

    q = repo.mq
    r = q.qrepo()
    if not r:
        raise util.Abort(_('no queue repository'))
    return orig(r.ui, r, *args, **kwargs)

The --mq option affects all commands that take a repository as an argument -- it actually changes the targeted repo to be $(hg root)/.hg/patches, so it's effectively the same as running any mercurial command like this:

hg --repository $(hg root)/.hg/patches ....

Resultingly, every command that has a -R/--repository option has a --mq option and didn't need to be modified to get one. Any command you've previously used in mercurial: commit, push, pull, summary, id, etc. can take --mq. Here's the relevant python code:

def mqcommand(orig, ui, repo, *args, **kwargs):
    """Add --mq option to operate on patch repository instead of main"""

    # some commands do not like getting unknown options
    mq = kwargs.pop('mq', None)

    if not mq:
        return orig(ui, repo, *args, **kwargs)

    q = repo.mq
    r = q.qrepo()
    if not r:
        raise util.Abort(_('no queue repository'))
    return orig(r.ui, r, *args, **kwargs)
如歌彻婉言 2024-10-24 03:56:16

--mq 标志使不必要的命令已被标记为弃用,以便它们从 hg help mq 中消失。这就是 qcommitqinit 不再出现的原因。

如果您好奇,您仍然可以执行 hg qcommit 查看该命令的帮助。

就我个人而言,我不喜欢 --mq 标志。相反,我使用 shell 别名:

mq='hg -R $(hg root)/.hg/patches'

然后我可以执行 mq statusmq commitmq Push 等。我发现两者之间的区别hgmq 命令名称与我对操作的看法相符。请注意,这个简单的别名没有考虑多个队列,因此如果您使用 hg qqueue,则必须对其进行一些扩展。

The commands that the --mq flag make unnecessary have been marked deprecated so that they disappear from hg help mq. This is why qcommit and qinit no long show up.

You can still do hg qcommit to see the help for the command if you are curious.

Personally, I don't like the --mq flag. Instead I use a shell alias:

mq='hg -R $(hg root)/.hg/patches'

and then I can do mq status, mq commit, mq push, etc. I find that the distinction between the hg and mq command names match how I think of the operations. Note that this simple alias doesn't take multiple queues into account, so if you use hg qqueue, then you'll have to extend it a bit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文