Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
We're now using the commitsigs (bitbucket.org/mg/commitsigs) extensions to sign every commit with a GPG key. The central repository server doesn't accept any push that contains unsigned change sets. That way we can make sure of the correct identities of the authors. –  Sven Feb 11 '11 at 8:03
add comment

2 Answers

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.

share|improve this answer
1  
Can you please provide an example? –  Sven Feb 4 '11 at 12:30
add comment

As djc mentioned, you can use a pretxnchangegroup hook. The documentation for enforcing commit policy on your central repo is found on the EnsureCommitPolicy wiki page in the Mercurial docs.

This may create other problems since the users won't discover the issue until they try to push back up to the "main" repository which has the hook installed. In this case they would have to strip all the revisions from their repo and re-apply them with a new username.

A better option, IMO, would be to just not allow your freelancers to have access to the main repositories. They can send the changesets to your main developers who then massage the patches and put them in the repository themselves.

If you need to just fix an existing problem, see "Can I change the username on a mercurial changeset" on stackoverflow.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.