我可以通过编程方式设置Mercurial配置选项吗? [英] Can I set Mercurial config options programmatically?

查看:53
本文介绍了我可以通过编程方式设置Mercurial配置选项吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种无需实际编辑文本文件即可设置.hgrc配置项目的方法.我正在尝试在多个开发人员之间标准化hgrc的设置,我想要一个类似

I'm looking for a way to set .hgrc configuration items without actually editing the text file. I'm trying to standardize the setup of the hgrc across multiple developers and I would like a command like

hg --config ui.username=foo

,但这也将配置更改保存到hgrc文件中.

but which also saves that config change into the hgrc file.

似乎应该在vanilla hg命令中直接支持它,但是我在任何地方都找不到它.

It seems like this should be something that should be supported directly in the vanilla hg command, but I can't find it anywhere.

推荐答案

如果您希望保存配置更改,则有人(您或Mercurial)将必须编辑配置文件:-)

Someone -- either you or Mercurial -- will have to edit the configuration file if you want the config change to be saved :-)

如果可以通过以下方式致电Mercurial

And if you can call Mercurial with

hg --config ui.username=foo

那你也应该能够做

echo '[ui]' >> ~/.hgrc
echo 'username = foo' >> ~/.hgrc

这将保存配置更改,而不管~/.hgrc文件的外观如何(可以有多个[ui]节).

which will save the config change, not matter how the ~/.hgrc file happens to look like (it is okay to have multiple [ui] sections).

Mercurial 3.0和更高版本具有打开的hg config --edit命令具有用户配置文件的编辑器.仍然不是您所要的,但这至少可以简化交互式编辑文件的过程.

Mercurial 3.0 and later has the hg config --edit command that opens an editor with the user config file. Still not quite what you're asking for, but at least this makes it easier to edit the file interactively.

这篇关于我可以通过编程方式设置Mercurial配置选项吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆