Mercurial: less duplication in hgrc file

I have Hg for some projects on my google host. For each project, I set the username / password in the [auth] .hgrc section to click without asking for a password. But this is a lot 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 

Could it somehow be with less duplication? Maybe set a variable in hgrc and refer to it from all lines of username / password?

Thank you in advance for your help.

+4
source share
4 answers

from auth section to hgrc:

format: <name>.<argument> = <value> where <name> used to group the arguments in an authentication record.

<name>.prefix : uses an authentication entry with the longest matching prefix

Therefore, one entry is enough for code.google.com. %include file also interesting, so you can store common things in separate files and include them in any hgrc.

+4
source

hgrc files do not seem to support variables as a value for properties.

You may have multiple .rc files for your Mercurial youg configuration files

*.rc files from one directory are read in alphabetical order, and later - earlier

This means that you could:

  • one main hgrc file
  • one template file for project authentication
  • one script capable of generating multiple proj.rc files, one per project.

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

+2
source

Simply

 [ui] username = Ivan Pupkin < ivan.pupkin@gmail.com > verbose = True [auth] googlecode.prefix = https://code.google.com/ googlecode.username = username googlecode.password = password 

I check it on hg 2.3.2 :)

+1
source

Different Google Code projects for the same user do not have the same prefix, so you cannot use the prefix attribute in the auth hgrc section.

But you can do it differently. Write ~ / .hgrc as follows:

 [auth] gc.username = google code username gc.password = google code password 

And then for each project, create PROJECTDIR / hgrc / .hgrc that looks like this:

 [paths] default = https://PROJECTNAME.googlecode.com/hg/ [auth] gc.username = https://PROJECTNAME.googlecode.com/hg/ 

It is important that the entry name (gc in this case) be the same between the project .hgrc and hgrc.

0
source

Source: https://habr.com/ru/post/1310451/


All Articles