Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set different username by repository in Mercurial?

I am working on projects for different clients using Mercurial as a VCS. I know how to set a default user, but is there a mean to set a different user for each project ?

like image 748
edomaur Avatar asked Sep 19 '09 11:09

edomaur


People also ask

How do you set a username in Heartgold?

If you specify a -u option to the hg commit command on the command line, followed by a username, this is always given the highest precedence. If you have set the HGUSER environment variable, this is checked next. If you have set the EMAIL environment variable, this will be used next.

Where is mercurial config 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.


2 Answers

Just edit the file .hg/hgrc inside each repository. It's the same syntax as your ~/.hgrc but will only affect a specific repo.

In repo1/.hg/hgrc:

[ui]
username = Foo Bar <[email protected]>

And in repo2/.hg/hgrc:

[ui]
username = Something Else <[email protected]>
like image 166
tonfa Avatar answered Nov 16 '22 03:11

tonfa


Alternatively to setting username for each repository you can use Mercurial Dynamic Username extension and set usernames for specific locations in your global ~/.hgrc like this:

[extensions]
dynamic_username =

[dynamic_username]
work.location = ~/work
work.username = John Smith <[email protected]>
hobby.location = ~/hobby ~/blogging
hobby.username = Johny <[email protected]>
like image 27
Piotr Dobrogost Avatar answered Nov 16 '22 03:11

Piotr Dobrogost