Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mercurial 有没有办法检查~/.hgrc文件中的hg版本?_Mercurial - Fatal编程技术网

Mercurial 有没有办法检查~/.hgrc文件中的hg版本?

Mercurial 有没有办法检查~/.hgrc文件中的hg版本?,mercurial,Mercurial,在我的~/.hgrc文件中设置特定设置之前,我可以检查mercurial的版本吗?例如,我想启用一个扩展(比如shelve扩展),但只有当hg版本是一个特定的版本(比如2.8或更高版本)时才启用。当一个人的主目录在安装了各种版本的hg的许多机器上共享(比如nfs)时,这尤其有用。这是一个有趣的问题。hgrc格式中没有条件,但include行中有变量扩展,因此您可以将其放入中。bash\u配置文件中: HG_VERSION=$(python -c 'from mercurial.__version

在我的~/.hgrc文件中设置特定设置之前,我可以检查mercurial的版本吗?例如,我想启用一个扩展(比如shelve扩展),但只有当hg版本是一个特定的版本(比如2.8或更高版本)时才启用。当一个人的主目录在安装了各种版本的hg的许多机器上共享(比如nfs)时,这尤其有用。

这是一个有趣的问题。
hgrc
格式中没有条件,但include行中有变量扩展,因此您可以将其放入
中。bash\u配置文件中

HG_VERSION=$(python -c 'from mercurial.__version__ import version; print version')
然后在你的
~/.hgrc
中有如下内容:

%include ~/.hgrc-$HG_VERSION
其中包括一个类似于,
~/.hgrc-2.6.2

为了避免错误,对于运行的每个版本,您都需要一个可能为空的文件,并且可以使用bash-fu来修剪次要版本,以获得一点灵活性。不过,它仍然无法让您获得比功能更强大的功能

更常见的方法是使用include机制来包含特定于主机或操作系统的hgrc文件,如:

%include ~/.hgrc-$HOST

它允许您添加仅在某些主机上运行的位。

您还可以通过检查hg in.bashrc的版本并相应地设置HGRCPATH变量,让hg读取不同的hgrc文件;看