views:

496

answers:

3

How can I modify the mercurial.ini file to include an environment variable such as %userprofile%.

Specific situation:

I am learning to use Mercurial. I have modified the [ui] section of Mercurial.ini (in my home path) to include:

ignore = c:\users\user\.hgignore

Where user is my username literal. The .hgignore file includes filters that that ignore the filenames correctly at commit time. But how can I alter it from being the a literal user to an environment variable $user?

+4  A: 

It won't interpolate environment variables in the hgrc, but I do believe that tilda expands to your home/profile directory correctly even on windows.

So:

ignore = ~/.hgignore

should work on windows and elsewhere (even the slashes get spun the wrong way automatically for you).

For other variables you'd need to get a little tricker and write a batch/cmd file that does the interpolation in advance and then hands the result off to mercurial for processing.

Ry4an
Thanks exactly what I wanted to do.
Coda
+4  A: 

The mercurial.ini parses the environment variables just fine. From my mercurial.ini:

[ui]
ignore = %USERPROFILE%/.hgignore

Works like a charm. Windows 7 Ultimate x64, Mercurial 1.5 (binary installation). The hgignore file is honored both my the command line hg.exe, and tortoiseHG.

Samuel Meacham
A: 

Yes, I know this is not an answer. I will change it to a comment when I have the Rep points to add comments...

Also using Windows. I would like the following to work but it doesn't. I have even tried $USERNAME.

[ui]
username = %USERNAME%
Nathan Hartley