Our ClearCase repository make heavy use of ClearCase symbolic links. We began an initiative to get rid of them, since they cause lots of problems – from snapshot view size, to tools not supporting them (e.g. WebPack), and Git migration efforts. See also my previous post on this matter.
The first step, of course, is to find all of them. One may think that cleartool find command will provide this functionality, but it’s lackcing. So we came up with this simple command-line:
cleartool ls -l -r <folder> | findstr /C:"symbolic link"
Folder must be a VOB, or a folder inside a VOB. To iterate on all VOBs, you can run:
for /d %i in (<view root>\*) do @cleartool ls -l -r %i | findstr /C:"symbolic link"
Now, we just need to figure out what to do with all of them…
Python, like many other popular OSS (Git anyone?), does not support symbolic links on Windows platforms , although they have been around since Windows Vista. Note, I am referring to actual symbolic links, not NTFS directory junctions or shortcuts.
I’m not really sure why is that. Maybe because they do not distinguish between different Windows revisions?
My current approach is to use the OS commands to create/delete symlinks. It’s not very elegant but it works without compatibility issues, unlike other solutions (calling win32 api through DLLs, manipulating file attributes, and other stuff you find in StackOverflow or tech blogs)
For example, to create a symbolic link of directories, one can use:
child = subprocess.Popen(['MKLINK', '/D', link, target], stdout = subprocess.PIPE, stderr = subprocess.STDOUT, shell = True)
streamdata = child.communicate()
And check child.returncode for the result (and the output – stdout and stderr combined – available in the streamdata variable)
To remove a symbolic link to a directory, use the windows RMDIR command (os.rmdir or os.unlink won’t work)
NTFS support for Symbolic Links was added when Windows Vista was released (2007). 7 years later, and the only major VCS which added ‘native’ support for source-controlling NTFS symbolic links is Perforce.
Most multi-platform VCS (svn, git, etc.) support UNIX-style symbolic links. Why is it so hard to add support for NTFS ones?
Even more confusing is why Microsoft’s own TFS doesn’t support NTFS symbolic links?
Why would I want to use symbolic links, you ask? There are many use cases for that – I’ll provide examples in a separate post, if people would be interested.
So, what do you do if your developers rely on symbolic links in their workspace? To be honest, not much. The alternatives are: Continue reading