开发者

Using the --quiet tag when extending Mercurial

开发者 https://www.devze.com 2023-01-23 09:14 出处:网络
I\'m writing a Mercurial extension in Python and need to call the \"Pull\" command using the Mercurial API, but I want to suppress its output using the --quiet flag.

I'm writing a Mercurial extension in Python and need to call the "Pull" command using the Mercurial API, but I want to suppress its output using the --quiet flag.

In Hg terms, I want to execute the following code, but from within my extension:

hg pull --quiet

Given the Mercurial API documentation, I thought it would be as simple as:

commands.pull(ui, repo, quiet=True)

Unfortunately, although 开发者_StackOverflow中文版this doesn't generate errors and will successfully execute the "Pull" command, the --quiet flag doesn't seem to be getting through as I still see the standard output.

All the examples only show passing non-global flags, so I'm a bit worried that this isn't possible.

What am I doing wrong? How can I pass the --quiet flag?


Global options are affected through the ui object. It allows you to control many of the things you would normally set in your (or the repository's) hgrc. In this case, you want to set the quiet option in the ui section to True.

ui.setconfig('ui', 'quiet', True)
commands.pull(ui, repo)
0

精彩评论

暂无评论...
验证码 换一张
取 消