Can Mercurial be made to preserve file permissions?
Solution 1:
It looks like it can be done using hooks and an auxiliary tool (and a little chewing gum and baling wire):
Get David Hardeman's Metastore, which saves and restores file metadata.
Alter the sources so it will ignore directory
.hg
as well as.git
.-
Use the following Mercurial hooks:
precommit.meta = metastore -s changegroup.update = hg update update.meta = /usr/unsup/nr/bin/metastore -a
You have to add the .metadata
file to the repo.
This lashup will work most of the time, but if you change only permissions and want to propagate it, you'll have to run metastore -s
in order to push those changes into the .metadata file where hg will see the change; otherwise the commit thinks nothing is new.
Solution 2:
What about using this solution from the Mercurial FAQ:
If you're using Mercurial for config file management, you might want to track file properties (ownership and permissions) too. Mercurial only tracks the executable bit of each file.
Here is an example of how to save the properties along with the files (works on Linux if you've the acl package installed):
# cd /etc && getfacl -R . >/tmp/acl.$$ && mv /tmp/acl.$$ .acl # hg commit
This is far from perfect, but you get the idea. For a more sophisticated solution, check out etckeeper.
Solution 3:
For the specific case of the /etc directory, etckeeper looks interesting.