tags:

views:

244

answers:

2

Hi there.

I have using Hg for some projects on my google code hosting. For each projects I set in [auth] section of .hgrc the username/password to push without every asking for password. But it is lots of duplication like:

[auth]
proj1.prefix = ... 111
proj1.username = google code username
proj1.password = google code password

proj2.prefix = ... 222
proj2.username = google code username
proj2.password = google code password

Can this somehow be doing with less duplications? Maybe set variable in hgrc and refer to it from all username/password lines?

Thanks in advance for your help

+2  A: 

hgrc files don't seem to support variables as value for properties.

You can have multiple .rc files for your Mercurial config files thoug

*.rc files from a single directory are read in alphabetical order, later ones overriding earlier ones

That means you could have:

  • one main hgrc file
  • one template file for project authentication
  • one script able to generate multiple proj.rc files, one per project.

There is still duplication, but at least it is generated for you.

VonC
where are *rc placed? isn't it easier then simply have a script to generate my .hgrc from a template?
zaharpopov
@zaharpopov: they are the "Per-installation/system configuration files" and are locate where you tell them to be (for Windows), or under `<install-root>/etc/mercurial/hgrc.d/*.rc` for Unix. You can off course generate only your own per-user `.hgrc` file, more appropriate for user informations.
VonC
+1  A: 

from auth section in hgrc:

format: <name>.<argument> = <value> where <name> is used to group arguments into authentication entries.

<name>.prefix: The authentication entry with the longest matching prefix is used

Hence, a single entry for code.google.com should suffice. Also of interest is %include file so you can store common things in seperate files and include them in any hgrc.

vsh