Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 396
D R Avatar asked Dec 25 '09 11:12

D R


People also ask

Can a symbolic link be a directory?

Symlink, also known as a symbolic link in Linux, creates a link to a file or a directory for easier access. To put it in another way, symlinks are links that points to another file or folder in your system, quite similar to the shortcuts in Windows.

How do I create a directory symbolic link in Linux?

Ln Command to Create Symbolic Links By default, the ln command creates a hard link. Use the -s option to create a soft (symbolic) link. The -f option will force the command to overwrite a file that already exists. Source is the file or directory being linked to.

How do I create a directory symbolic link in Windows?

Once LSE is installed, right-click the target file or folder you want to create a symlink to, then click “Pick Link Source.” Next, go to the folder where you want the symlink to appear, right-click it, then select “Drop As -> Symbolic Link.”

Where are symbolic links stored?

program directory in a file manager, it will appear to contain the files inside /mnt/partition/. program. In addition to “symbolic links”, also known as “soft links”, you can instead create a “hard link”. A symbolic or soft link points to a path in the file system.


4 Answers

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 
like image 167
Rage Steel Avatar answered Nov 03 '22 23:11

Rage Steel


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.

like image 45
Ry4an Brase Avatar answered Nov 03 '22 22:11

Ry4an Brase


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.

like image 21
sparklewhiskers Avatar answered Nov 03 '22 22:11

sparklewhiskers


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.

like image 20
olafure Avatar answered Nov 03 '22 23:11

olafure