Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial: no ~/.hgrc file

Tags:

mercurial

I am trying to go though this tutorial that says:


Enable SSH compression for Mercurial

Edit the Mercurial global configuration file (~/.hgrc). Add the following line to the UI section:

ssh = ssh -C


But there is no that file in my system. HG of course is installed.

like image 949
scythargon Avatar asked Oct 07 '12 19:10

scythargon


People also ask

Why is mercurial not responding to my Hg/HGRC file?

See hg help templates for details. Mercurial will not use the settings in the .hg/hgrc file from a repository if it doesn't belong to a trusted user or to a trusted group, as various hgrc features allow arbitrary commands to be run. This issue is often encountered when configuring hooks or extensions for shared repositories or servers.

Where does mercurial look for HGRC?

For example, if installed in /shared/tools/bin/hg, Mercurial will look in /shared/tools/etc/mercurial/hgrc. Options in these files apply to all Mercurial commands executed by any user in any directory.

Where does mercurial read configuration data from?

Mercurial reads configuration data from several files, if they exist. These files do not exist by default and you will have to create the appropriate configuration files yourself: Local configuration is put into the per-repository /.hg/hgrc file.

How to use $hg_ARGs in mercurial?

The contents of the command line are passed as $HG_ARGS. If the hook returns failure, the command doesn't execute and Mercurial returns the failure code. Run before a changegroup is added via push, pull or unbundle. Exit status 0 allows the changegroup to proceed. Non-zero status will cause the push, pull or unbundle to fail.


3 Answers

It is not there by default. You don't need it to exist — it just can exist to customize how you use Mercurial. You just need to create a .hgrc file in your home directory and it should work.

Heres a great intro post: http://hgtip.com/tips/beginner/2009-09-30-configuring-mercurial

like image 117
Patrick Avatar answered Nov 02 '22 12:11

Patrick


Snagged from the manpages at https://www.selenic.com/mercurial/hgrc.5.html.

Files

Mercurial reads configuration data from several files, if they exist. These files do not exist by default and you will have to create the appropriate configuration files yourself:

Local configuration is put into the per-repository /.hg/hgrc file.

Global configuration like the username setting is typically put into:

%USERPROFILE%\mercurial.ini
$HOME/.hgrc

The names of these files depend on the system on which Mercurial is installed. *.rc files from a single directory are read in alphabetical order, later ones overriding earlier ones. Where multiple paths are given below, settings from earlier paths override later ones.

On Unix, the following files are consulted:

  • /.hg/hgrc (per-repository)
  • $HOME/.hgrc (per-user)
  • /etc/mercurial/hgrc (per-installation)
  • /etc/mercurial/hgrc.d/*.rc (per-installation)
  • /etc/mercurial/hgrc (per-system)
  • /etc/mercurial/hgrc.d/*.rc (per-system)
  • /default.d/*.rc (defaults)

On Windows, the following files are consulted:

  • /.hg/hgrc (per-repository)
  • %USERPROFILE%.hgrc (per-user)
  • %USERPROFILE%\Mercurial.ini (per-user)
  • %HOME%.hgrc (per-user)
  • %HOME%\Mercurial.ini (per-user)
  • HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial (per-installation)
  • \hgrc.d*.rc (per-installation)
  • \Mercurial.ini (per-installation)
  • /default.d/*.rc (defaults)
like image 23
Josh Sutterfield Avatar answered Nov 02 '22 11:11

Josh Sutterfield


For up-to-date versions of mercurial, you should use the XDG compatible location. Unless you explicitly set XDG_CONFIG_HOME the settings should go into the file:

~/.config/hg/hgrc

Less clutter in your home directory and ~/.config/hg/ can also be used for files like a common hgignore

like image 21
Anthon Avatar answered Nov 02 '22 13:11

Anthon