加载多个.hgrc文件 - 即一些具有机器特定的设置?

Dav*_*ver 11 mercurial hgrc

我想保留两个〜/ .hgrc文件:〜/ .hgrc和〜/ .hgrc.local - 一个具有"标准"设置(例如username),另一个具有机器特定设置(例如,设置图形合并工具).

我怎么能用hg做到这一点?

例如,这就是我用Vim做的方式:

# ~/.vimrc
syntax enable
source ~/.vimrc.local
Run Code Online (Sandbox Code Playgroud)

然后:

# ~/.vimrc.local
let work_code = 'code/work/.*'
if expand('%:p:h') =~ work_code ... fi
Run Code Online (Sandbox Code Playgroud)

Ry4*_*ase 20

%include在mercurial 1.3及更高版本中有一个不经常使用的指令:

来自man hgrc:

   A  line  of  the  form %include file will include file into the current
   configuration file.  The  inclusion  is  recursive,  which  means  that
   included  files  can include other files. Filenames are relative to the
   configuration file in which the %include directive is found.
Run Code Online (Sandbox Code Playgroud)

所以请跟:

   %include ~/.hgrc.local
Run Code Online (Sandbox Code Playgroud)

你应该好好去.


vir*_*tor 5

我以类似的方式为所有"点文件"解决了这个问题.在登录时,我的shell检查文件列表(hgrc,vimrc,....)并检查它们中的任何一个是否早于${that_name}.global${that_name}.local.如果是 - cat ${that_name}.{global,local} > ${that_name}.简单,到目前为止工作得很好.虽然有一种"更好"的方式(使用%include),但有时手动处理配置文件具有优势 - 例如它可以使用mercurial pre-1.3.