如何在Mercurial中按存储库设置不同的用户名?

edo*_*aur 10 mercurial repository configuration-files

我正在使用Mercurial作为VCS为不同客户开展项目.我知道如何设置默认用户,但是为每个项目设置不同的用户是否有意义?

ton*_*nfa 15

只需编辑.hg/hgrc每个存储库中的文件.它与您的语法相同,~/.hgrc但只会影响特定的回购.

repo1/.hg/hgrc:

[ui]
username = Foo Bar <foobar@example.com>
Run Code Online (Sandbox Code Playgroud)

并在repo2/.hg/hgrc:

[ui]
username = Something Else <something.else@example.com>
Run Code Online (Sandbox Code Playgroud)


Pio*_*ost 5

或者为每个存储库设置用户名,您可以使用Mercurial动态用户名扩展并为全局中的特定位置设置用户名,~/.hgrc如下所示:

[extensions]
dynamic_username =

[dynamic_username]
work.location = ~/work
work.username = John Smith <john.smith@serious.com>
hobby.location = ~/hobby ~/blogging
hobby.username = Johny <fastjohny@fantasy.net>
Run Code Online (Sandbox Code Playgroud)