gpt4 book ai didi

mercurial - 使用扩展修改核心 Mercurial 命令的行为?

转载 作者:行者123 更新时间:2023-12-02 22:46:38 25 4
gpt4 key购买 nike

是否可以通过创建扩展来修改核心 Mercurial 命令的行为(例如 hg commithg status)?

例如,是否可以修改 hg commit 以要求用户输入问题跟踪 ID?

我知道可以使用 Hook 脚本,但此类脚本不是通过 hg pull 分发的,需要为每个使用的存储库进行配置。

最佳答案

回答我自己的问题

Mercurial API 提供 extensions.wrapcommand(table, command, wrapper)方法似乎提供了所需的功能。

来自源代码:

Wrap the command named `command' in table.

Replace command in the command table with wrapper. The wrapped command will be inserted into the command table specified by the table argument. The wrapper will be called like wrapper(orig, *args, **kwargs) where orig is the original (wrapped) function, and *args, **kwargs are the arguments passed to it.

几个例子:

关于mercurial - 使用扩展修改核心 Mercurial 命令的行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3527415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com