views:

34

answers:

1

I'm new mercurial user. I setup the acl extension adding this into my hgrc file:

[hooks]
pretxnchangegroup.acl = python:hgext.acl.hook

[acl]
sources = serve pull push

[acl.deny]
** = mercurial

So with this code above I deny access to all files to user "mercurial". I successfully tested the acl extension and it works perfectly when I try to push to my central repository on which I put the code above. As expected I receive message that the access for the user "mercurial" is denied.

Now the problem is when I'm start pulling from central repository I don't have any restriction so I can pull anything without any restriction. What I want is to deny pull access for some files like I can do when I tried push comand. Is there any way I can do this?

A: 

Mercurial, unlike Subversion, doesn't allow controls on individual files, and for good reason. The DVCS model puts the entire repo on every developer's machine, so even if you restrict files on push and pull, the user could still just hg cat the file to get its contents.

Instead of trying to do this on the client side, I would instead break your repos based on who needs what and set permissions to individual repos. See my answer on the Kiln stack exchange Should I use more than one repository?. You can set permissions via http(s) or SSH, or if you happen to be using Kiln, through our permissions interface.

tghw
Thanks for the replay but now I don't know what to do. I have one project and I want to restrict access to specific users for some files on that project. Is there any different way to do this and keep that project in one peace?
Danilo
What sorts of files are you restricting access to? And how are you going to enforce their use of your hook?
tghw
Thanks again for the answer. I want to restrict access to some php scripts. But there is one question that is the same as your second. How to enforce use of my hook and how to design that hook in order to be able recognize those files that I want to restrict?
Danilo
Is there mercurial variable that I can use in my custom hook that can recognize pull command?
Danilo
To the best of my knowledge, there is no way to prevent only certain files from being pulled, while allowing others. That would represent a different history, which would mean a different changeset ID, etc. It does look like a `preoutgoing` hook might get the hook in there, but I'd be surprised if you could block certain files. Do you mind posting the source for your hook?
tghw