Mic*_*oie 7 python mercurial mercurial-extension
我在Python中编写Mercurial扩展,需要使用Mercurial API调用"Pull"命令,但我想使用--quiet标志来抑制其输出.
在Hg术语中,我想执行以下代码,但是在我的扩展中:
hg pull --quiet
Run Code Online (Sandbox Code Playgroud)
鉴于Mercurial API文档,我认为它将如下所示:
commands.pull(ui, repo, quiet=True)
Run Code Online (Sandbox Code Playgroud)
不幸的是,尽管这不会产生错误并且会成功执行"Pull"命令,但是 - 我仍然看到标准输出,因此--quiet标志似乎没有通过.
所有的例子只显示传递非全局标志,所以我有点担心这是不可能的.
我究竟做错了什么?我怎样才能通过--quiet标志?
全局选项通过ui对象受到影响.它允许您控制通常在您(或存储库)hgrc中设置的许多内容.在这种情况下,您要quiet将该ui部分中的选项设置为True.
ui.setconfig('ui', 'quiet', True)
commands.pull(ui, repo)
Run Code Online (Sandbox Code Playgroud)