Can Mercurial create its own symbolic link format from Windows?

Go To StackoverFlow.com

3

I know that Mercurial doesn't support symbolic links in repos on Windows; I can live with that, though an implementation using NTFS symlinks would be nice for those who can enable the privilege on their Windows boxes for non-admins.

What I'm wondering is about the way that Mercurial treats actual links from a Unix repository when the repo is seen on a Windows machine. If I update from a repo with a symlink in on my Windows development machine, I see that the link is changed into an actual file with the target of the link in it as text.

Somehow, Mercurial knows even on Windows that the file was originally a symlink, even when it is stored as a real file. If I edit the contents of the file in Windows, I can change the target of the symlink, because it's still recorded as being a symlink by Mercurial - when I push back to Unix, the symlink is pointing to the new location.

So. How do I mark a file that I've created in Windows as a symlink? It's clear that Mercurial could push such a symlink into the Unix filesystem, but I don't know how to mark it as such without creating the link first under Unix.

Is there a flag that can be set?

2012-04-04 18:30
by Iain Hallam


1

I'm afraid there is no work-around on Windows. You could write an extension that would let you set the symlink bit for a file on Windows, though. This extension will probably have to override dirstate.flagfunc, which is the function used when asking for the "flags" (execute and symlink bit) for a file.

See also Issue 1825 for the overall feature of making Mercurial create Windows symlinks in a checkout. It's marked "done, could-be-better" so it's unlikely to change any time soon.

2012-04-12 16:14
by Martin Geisler
Just to clarify, I don't want to create a Windows symlink; I just want to create a one-line text file that has a target as its content that will get turned into a symlink when I push to Unix. Files that are already known as symlinks by Mercurial go back as proper symlinks - can I tell Mercurial that a particular text file I create should to the same thing? Is that the bit I could write an extension for, and if so, do you have any pointers for where I should start looking at code in Mercurial? Thanks - Iain Hallam 2012-04-12 16:50
@IainHallam: sure, I've updated the answer with a pointer to what I think will be the relevant function to override - Martin Geisler 2012-04-13 06:45
Ads