Force specific usernames for Mercurial commits

mercurialuser-accounts

We're switching from Subversion to Mercurial in our corporate environment. There will be a central repository that is accessible via HTTPS with basic HTTP authentication.

Now I'm curious whether it's possible to force specific usernames for commits? I'm talking about the usernames that can be set in .hgrc like this

[ui]
username = John Doe <john.doe@mycompany.com>

and that are visible in the log messages.

Because this file is placed on each developer's machine it's outside of the administrator's control.

This wouldn't be a problem because we trust our internal developers but externals (freelancers) will also have access to at least some repositories. We definitively don't want them to checkin under different names.

It would be great if the username can be bound/forced to the HTTP username. For example if John pushes his changes to the URL https://john@mycompany.com/hg/project1 then the usernames of all commits will be set to John Doe <john.doe@mycompany.com.

Is this possible?

Best Answer

You can enforce the usernames at the server side, at push time. I.e. for your freelancers it might be feasible to only let them push changes that contain some pre-approved username (this can somewhat restrict other nice features of Mercurial, i.e. that people can share their changes with each other before pushing). You might also just have a complete list of pre-approved usernames on the central server.

All this can be done with a pretxnchangegroup hook.

Related Topic