Can I check the version of mercurial before setting a particular setting in my ~/.hgrc file? For example, I'd like to enable an extension (say the shelve extension), but only if the hg version is a particular version (say 2.8 or later). This is particularly useful when one's home directory is shared (think nfs) over many machines that have various versions of hg installed.
hg/hgrc will be created on the remote side. If the source repository has a bookmark called '@' set, that revision will be checked out in the new repository by default. To check out a particular version, use -u/--update, or -U/--noupdate to create a clone with no working directory.
Mercurial on Windows has a three-tier configuration system. A site-wide configuration file in C:\Program Files\TortoiseHg\Mercurial. ini This file is read first and thus has the lowest priority. A per-user configuration file in C:\Documents and Settings\username\Mercurial.
%USERPROFILE%\Mercurial. ini (per-user) %HOME%\. hgrc (per-user)
That's an interesting one. There are no conditionals in the hgrc
format, but there are variable expansions in include lines, so you could put this in your .bash_profile
:
HG_VERSION=$(python -c 'from mercurial.__version__ import version; print version')
and then in your ~/.hgrc
have something like:
%include ~/.hgrc-$HG_VERSION
which would include a file like, ~/.hgrc-2.6.2
To avoid errors you need a possibly empty file for each version you run, and you could use bash-fu to trim off the minor version for a little flexibility. It still won't get you greater-than functionality, though.
The more normal way to do this is to use the include mechanism to include host or OS specific hgrc files like:
%include ~/.hgrc-$HOST
which lets you add in bits that are run only on certain hosts.
You could also have hg read a different hgrc file by checking the version of hg in .bashrc and setting the HGRCPATH Variable accordingly; See Mercurial .hgrc file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With