Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I set Mercurial config options programmatically?

I'm looking for a way to set .hgrc configuration items without actually editing the text file. I'm trying to standardize the setup of the hgrc across multiple developers and I would like a command like

hg --config ui.username=foo

but which also saves that config change into the hgrc file.

It seems like this should be something that should be supported directly in the vanilla hg command, but I can't find it anywhere.

like image 506
johnkpaul Avatar asked Jan 11 '11 15:01

johnkpaul


People also ask

Where is HGRC file on Windows?

hg/hgrc file. Global configuration like the username setting is typically put into: %USERPROFILE%\mercurial. ini (on Windows)

Where is the mercurial INI file?

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.


1 Answers

Someone -- either you or Mercurial -- will have to edit the configuration file if you want the config change to be saved :-)

And if you can call Mercurial with

hg --config ui.username=foo

then you should also be able to do

echo '[ui]' >> ~/.hgrc
echo 'username = foo' >> ~/.hgrc

which will save the config change, not matter how the ~/.hgrc file happens to look like (it is okay to have multiple [ui] sections).

Mercurial 3.0 and later has the hg config --edit command that opens an editor with the user config file. Still not quite what you're asking for, but at least this makes it easier to edit the file interactively.

like image 73
Martin Geisler Avatar answered Sep 29 '22 08:09

Martin Geisler