views:

74

answers:

3

I'm trying to propose switching from CVS and SVN to Mercurial at work. Before I do, I'd like to have any foreseeable questions answered.

How can I set up a repository to allow push and authenticate users?

I'm more familiar with administering SVN, and in SVN it was just a few lines like:

[users]
userA = passwordA
userB = passwordB

And then for permissions it was like:

[general]
userA = write
userB = read

I would really like something like svnserve that allowed me to circumvent using a full-blown apache, since all I need is a central location for pushing change sets. I know that Mercurial doesn't necessarily require a central location, but I think it would be convenient in my workplace.

Thanks!

+1  A: 

As @nlucaroni mentioned in the comment, one option is using SSH authentication. It allows authenticated pull and push. We use it in our company together with Apache-hosted HTTP access for anonymous pull-only repositories. See the "ssh" solution at the Publishing Mercurial Repositories.

Andrey Vlasovskikh
And you don't need actual user accounts each. The hgssh script linked at Andrey's site lets everyone use the same system account with different private keys.
Ry4an
You may also use only one Unix account, say `hg`, but authenticate users by their public SSH key, not by the `hg` account password.
Andrey Vlasovskikh
If I only use one user account (hg) then will the changes still be associated with different users? For example, if the two users are Alice and Bob, and the user account is hg, then when Alice pushes her changeset, will both Bob and Alice see that that particular changeset came from Alice?
pcd6623
Changesets in Mercurial are labeled with the "Author" text field. This text field is not related to the login one uses to push changesets. Basically, anyone is able to push a changeset of anyone else.
Andrey Vlasovskikh
Yup, Andrey's right. Even with separate accounts the "who pushed" data isn't saved, and only the author field is, so you have the same history either way.
Ry4an
+1  A: 

Mercurial Server is an awesome solution, which I've used on a few occasions.

RyanWilcox
Just to include the other opinion, I've never been impressed with mercurial server. The name is confusing, it's not a part of the mercurial project and certainly isn't the server for it, and it doesn't offer much functionality that mercurial's own 'hg-ssh' doesn't include. It also lags mercurial in feature support, including sub repositories which have been around for six months now.
Ry4an
@Ry4an, it seems as if mercurial-server allows for remote administration via mercurial, meaning I would only have to set up the server once with one user, and then I never have to log in again to add/remove users or change permissions; I would simply push new administrative changes. That seems pretty useful. Is there a compelling reason against using mercurial-server, besides lack of support for sub-repositories?
pcd6623
@pcd6623 There's no compelling reason not to use it, but no compelling reason to use it either. You can always keep your ~/.ssh/authorized_keys file in a mercurial repo that you push-to/update remotely using vanilla hg-ssh. Some people clearly find value in it, but I find I get the same benefits without.
Ry4an
A: 

You can try the textauth extension. Please give it a go and send some feedback to [email protected], then perhaps you will see it integrated into a coming release of Mercurial.

Martin Geisler
Is this your project? It looks interesting. You should provide a description or what the goal of the project will be so that others will know what it's all about.
pcd6623
No, I'm `mg` on Bitbucket, Henrik Stuart (`hstuart`) wrote this. Please fork it on Bitbucket and make him pull your patches if you make any :) You could also start a thread about it on the mailinglist since I guess there must be more users who would like this.
Martin Geisler
As for that this is about, then it's already documented in the README here: http://bitbucket.org/hstuart/hg-textauth/src
Martin Geisler