问题描述
(/etc/mercurial
和<install-root>/etc/mercurial
中的)系统级hgrc文件显然是平台相关的,但是如何在每个用户的基础上使用平台相关的hgrc?
System-level hgrc files (in /etc/mercurial
and <install-root>/etc/mercurial
) are obviously platform-dependent, but how I can use platform-dependent hgrc on a per user basis?
用例是在特定平台上覆盖系统配置.例如,我们在Linux和solaris上具有使用不同合并工具的hg.当hgrc不允许任何控制逻辑(例如if os.uname()[0] == 'SunOS'
)时,如何仅覆盖solaris合并工具?
The use case is to override a system config on a specific platform. For example, we have hg on linux and solaris with different merge tools. How do I override just the solaris merge tool, when hgrc doesn't allow any control logic (like if os.uname()[0] == 'SunOS'
)?
推荐答案
- 保留一组
.<platform>.hgrc
文件以及每个文件中要覆盖的内容. -
在
.bashrc
中设置环境变量:
- Keep a set of
.<platform>.hgrc
files with whatever you want to override in each one. Set an environment variable in your
.bashrc
:
export PLATFORM=`python -c 'import os; print os.uname()[0],'`
在您的~/.hgrc
文件中,最后使用%include
包括正确的文件:
In your ~/.hgrc
file, use %include
at the end to include the right file:
%include ~/$PLATFORM.hgrc
这篇关于实际上,如何设置和使用基于用户平台的hgrc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!