3

I am using mercurial as part of my workflow process and it is working well. I have one niggling problem though. When I pull from my central repository down to my Linux web server in order to make an upgrade, I'm doing it with the "root" user. That appears to assign the owner and group to "root" for any files that are new or changed.

Unfortunately I run into other difficulties with that, so I'm always having to go through and reset all the files to the proper group and owner (a non-root user on the web server).

Is there some way to get mercurial to do this automatically, or does someone have a fast way of doing it? I am using the shell and having to type

chown -R username /home/username

I try to do something similar with chgrp. The whole thing seems messy, and I suspect there's a simpler way to accomplish what I need. Is there a way to set owner and group when pulling from a repository?

neomech
  • 303
  • 1
  • 5
  • 16

2 Answers2

8

You should be pulling as you not as root and then you wouldn't have that problem. However, if that's infeasible for some reason you can always use an update hook to correct file permissions. In your repository's .hg/hgrc file you'd put:

[hooks]
update = chown -R username:usergroup /home/username

And that command will be automatically run after each hg update (or hg pull -u).

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • That's awesome. The "user" account doesn't have shell access, and I'd kind of like to keep it that way, which is why I was trying to do this with the root. Thanks again! :) – neomech Nov 05 '10 at 13:48
  • how to add 2 hooks? I need to chown thw whole directory and chowning another one for excluding it – Kreker Mar 27 '14 at 09:03
1

You can add multiple hooks by defining each one separately

    [hooks]
    update.command1 = chown -R username:usergroup /home/username
    update.command2 = chown username2:usergroup2 /home/username/excludeme
dandan
  • 1,016
  • 8
  • 16