How to treat a symbolic link as a directory in Mercurial?

谁说胖子不能爱 提交于 2019-11-29 01:50:48

问题


As of 0.9.4, when adding a symbolic link Mercurial keeps track of the link itself, and not the file or directories it points to. However, there are cases when it is desirable to keep track of the files pointed to by the symbolic link.

How can I force Mercurial to treat the symbolic link to a directory as a regular directory?


回答1:


Under linux you can use

mount --bind sourcepath targetpath

instead of symbolic links and mercurial will treat target as usual directory (tested on openSUSE 11.2 with Mercurial 1.3.1, and on RHEL6).

The alternative syntax, amenable for inclusion in /etc/fstab, is

mount -o bind sourcepath targetpath

The fstab entry is, then

sourcepath targetpath none defaults,bind 0 0



回答2:


I don't think there's a way to do this when you're working with directories.

If you're working with mercurial 1.3 or later you could try using the new subrepo support, that will let you have a repo track stuff ourside of it on the local disk, but it's not as seamless as a link would have been.




回答3:


I was surprised when I found this too, but it seems to be a feature that the Mercurial team don't want to change for security reasons.

I'm planning to get around it by using rsync to update the local copy of the directory before committing, from my makefile. This isn't a great solution but my directory is quite small so it should be OK.




回答4:


Just a follow up on Rage Steel's excellent answer (mount --bind):

To make your mount ready on boot (since mounts don't survive reboots), in your /etc/fstabs put:

/paht/to/source /path/to/target bind defaults,bind 0 0

Just make sure to put it after your source is mounted.



来源:https://stackoverflow.com/questions/1961016/how-to-treat-a-symbolic-link-as-a-directory-in-mercurial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!