tags:

views:

831

answers:

2

I have main mercurial repository (A) with 2 folders "depot1" and "depot2" in Windows Machine

Following configuration is done in .hg/hgrc file of A repo.

[ui]
username = praveen

[extensions]
hgext.acl=

[hooks]
changegroup.update = hg update
pretxnchangegroup.acl = python:hgext.acl.hook

[acl]
sources = serve push pull commit

Then I created 2 clones of mercurial A repository. X and Y on windows machines

X .hg/hgrc file is:

[ui]
username = clone1

Y .hg/hgrc file is:

[ui]
username = clone2

My Question: 
1- Restrict all push operations from user="clone2".
2- user="clone1" will be able to perform push on only "depot1".

Please suggest me how this configuration is possible.

Thanks,

Praveen

+3  A: 

Unfortunately, you're misunderstanding what the username in the [ui] section does. It's strictly a client-side setting that says "If a server asks me for a username for authentication here's what I want to send", so what you have in the ui.username in repos A, X, and Y will have no affect on what remote users can to to/with those repositories.

Instead, you need to use the [acl.allow] and [acl.deny] sections in the Y and X repositories' .hg/hgrc files to specify access controls for them.

The usernames that you use in those section, ('clone1' and 'clone2') in your examples need to be backed by a real authentication system too. The built-in hg-serve doesn't provide one, so you need to be using either ssh or Apache/ISS with a hgweb or hgwebdir. See the publishing repositories wiki page for a great overview.

Ry4an
Can you please refer any good documentation on how to configure [acl.allow]/[acl.deny] and [allow_push] in mercurial repositories.
praveen
The AclExtension wiki page http://mercurial.selenic.com/wiki/AclExtension explains [acl.allow] and [acl.deny].However, what you need to understand is that mercurial does not have a user database of its own. It uses the user system of either your (1) operating system, (2) ssh authorized_keys, or (3) HTTP web server authentication realm. The one it uses depends on how you're accessing mercurial (ssh or http).are you using ssh: URLs or http: URLs? Where are you creating your user accounts?
Ry4an
I have mercurial setup on windows machine and currently using hg serve for publishing my single mercurial repository.clone repositories (each user have one clone in their local windows machine)
praveen
You're not going to be able to do the permissions stuff you want using 'hg serve'. 'hg serve' is a built-in tool for letting people quickly grab you changes or see what you're doing. It doesn't have user-authentication or credentials. You need to look at the publishing repositories link in my initial answer and set up something more formal to restrict certain users to certain repos. You'll probably want to elect one machine to serve up all 3 repos through ssh, apache, or IIS and let the users keep their local clones X and Y in sync with clones on that server which only they can access.
Ry4an
A: 

Is there any option to restrict user to use "hg push -f"? Because it will removed intermediete commits by other users. send reply to my mail id [email protected]

Muralidharan