Clone wiki

hgcfg / Home

hgcfg extension for mercurial

Displays or modifies local, user, and global configuration.



This extension provides command-line access to hg configuration values stored in hgrc files. You can use this extension to view and change configuration values, show which configuration files are used by hg, and edit any of these files from the command-line.

Three commands are provided by this extension:

  • hg listcfgs
  • hg editcfg
  • hg cfg


  • Set or query config values in local, user, or global hg config files
  • List all items in a given config section
  • List all config files for a repository
  • Launch EDITOR to edit local, user, or global config file
  • Delete or comment-out old values when overwriting
  • Colorized when color extension is enabled
  • Backwards compatible with "alu"'s hgconfig extension (through rev 80f98d6)


Check how a configuration key is being set

$ hg cfg ui.username --verbose


values found for ui.username in global/local/user config:
  bmearns   (user)   C:\Users\bmearns\mercurial.ini
* metalark  (local)  C:\Users\bmearns\.hgext\hgconfig\.hg\hgrc

Change a configuration key in the local (repo) config file

$ hg cfg ui.username "kingcobra"


$ hg cfg ui.username --verbose
values found for ui.username in global/local/user config:
  bmearns    (user)   C:\Users\bmearns\mercurial.ini
* kingcobra  (local)  C:\Users\bmearns\.hgext\hgconfig\.hg\hgrc

Edit user config file

$h g editcfg --user
multiple config files to choose from, please select:
[0] C:\Users\bmearns\.hgrc
[1] C:\Users\bmearns\mercurial.ini
which file do you want to edit: [0] 1
editing config file [1]

Uses configured editor to edit the specified file, by way of a temp file, like commit messages.

List available config files

$ hg listcfgs
 ro globalC:\Program Files\TortoiseHg\hgrc.d\EditorTools.rc
 ro globalC:\Program Files\TortoiseHg\hgrc.d\Mercurial.rc
 ro globalC:\Program Files\TortoiseHg\hgrc.d\MergePatterns.rc
 ro globalC:\Program Files\TortoiseHg\hgrc.d\MergeTools.rc
 rw globalC:\Program Files\TortoiseHg\hgrc.d\Paths.rc
 ro globalC:\Program Files\TortoiseHg\hgrc.d\TerminalTools.rc
 rw user  C:\Users\bmearns\mercurial.ini
 !  user  C:\Users\bmearns\.hgrc
 rw local C:\Users\bmearns\.hgext\hgconfig\.hg\hgrc

A ! indicates the file is not present, ro indicates the file is not writeable by the current user, rw indicates that it is writeable.


To install this extension, download the files in the hgext directory to your system and edit your hgrc config file to add the file as an extension:

hgcfg = /path/to/hgcfg/hgext/

You can just as well clone the entire [hgext repository][] and use it the same way, just make sure to point the extension at

It doesn't matter where you place the files, but a common place to put them is under ~/.hgext (on Windows, this would be %HOMEDRIVE%%HOMEPATH%\.hgext, typically C:\Users\USERNAME\.hgext in Windows 7).

Screen Shots

The following shows the results of issuing the hg listcfgs command in conjunction with the built-in color extension.

hg listcfgs

For more screen shots, see ScreenShots.

For information on customizing the colors used by the extension, see Config#Colors.

See Also