开发者

mercurial: less duplication in hgrc file

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 = ..开发者_如何学C. 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


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.


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.


Just

[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 :)


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

But you can do it in a different way. Write a ~/.hgrc like this:

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

And then for each project, make a 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 name of the entry (gc in this case) is the same between the .hgrc and the project hgrc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜