How to treat a symbolic link as a directory in Mercurial?
Asked Answered
M

4

25

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?

Middlebrooks answered 25/12, 2009 at 11:27 Comment(7)
have you tried hard instead of soft links?Sullins
I'm on a Mac, and I can't get ln to produce hard links. It complains that the the target is a directory.Middlebrooks
From ls(1) on my Linux machine: -d, -F, --directory: allow the superuser to attempt to hard link directories (note: will probably fail due to system restrictions, even for the superuser).Galbraith
@The MYNN: You can't make hardlinks to directories.Between
So did you find a solution or did you just stop using hg? I'm using xmapp at home and have some ISP I pay for my actual website. xmapp uses htdocs, the ISP uses public_html. I wanted to manage this with hg and just add a symbolic link from public_html to htdocs on the isp's server only to find that's apparently impossible because of this stupid hg thing.Trichiasis
Another possible solution is hard link - #1433040Wildeyed
@Celil: Try https://mcmap.net/q/46994/-creating-directory-hard-links-in-mac-os-x-duplicateEndogamy
P
25

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
Puryear answered 10/6, 2010 at 6:3 Comment(1)
I have confirmed that sudo mount --bind sourcepath targetpath as recommended by Rage Steel works for me on Linux (Ubuntu 10.04 with Mercurial 1.4.3).Garrik
L
5

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.

Laconic answered 26/12, 2009 at 4:36 Comment(0)
M
5

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.

Munificent answered 3/4, 2010 at 8:35 Comment(0)
R
2

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.

Raindrop answered 25/12, 2009 at 11:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.