Question

I have a php webapp controlled by mercurial. It's in /var/www/directory/. The files are owned by user and group 'www-data'. After I pull some changes, the files become owned by root.root.

That's because the hg is run by root? it's a remote server and I have only root access, how to fix this? I don't want to run chown manually and recursively in the directories after every pull, also because there are some subdirs which can't belong to www-data .

Don't know if I'm doing right, tried to modify the hgrc with

[trusted]
users = www-data
groups = www-data

didn't work

Was it helpful?

Solution

A new file created by root when root is running hg are going to be owned by root. You can use the sticky group bit to set the group, but you're stuck with root as the user.

You can probably put a hook in the repo's .hg/hgrc pretty easily. Something like:

[hooks]
post-pull = chown -R user:www-data .hg

You said there are some directories you want to exclude, but you can do that in a hook too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top