Can I keep a symbolic link in my Subversion repository?
Asked Answered
M

2

10

I'm developing a small app in both PHP and Java. It has a few pics, CSS and JS, that must be shared in both.

I don't want these files duplicated, and the JS and CSS must be the same in both. So I'd like that when I change it in one place, the change be replicated in the other.

In Unix we have symbolic links, so that the same file/folder can "be" in multiple places in File System. In Subversion we have svn copy, but once it's executed both copies become independent. I wanted to keep them together, a commit done in one copy will be applied in the "other" too.

Any idea how to do that?

Macrobiotics answered 2/4, 2013 at 19:40 Comment(1)
Possible duplicate of What happens if I add a symbolic link to subversion?Munniks
P
16

You're referring to symlinks in your post, not "shadow links" (I've edited the post). Subversion can version symlinks, but another way to go about it (as symlinks aren't supported by Subversion on Windows at the moment) is to use Externals.

The difference is that if you use a Subversion external, you'll actually have two copies of the file on your system (which point back to the same place in the repository), whereas the symlink is a single file on the filesystem.

Peursem answered 2/4, 2013 at 20:53 Comment(2)
Thanks again, I'll take a look on Externals. It's been a few years I don't use Unix, I think shadow is Mac's name for it, symbolic for Unix and .lnk for Windows... or not lol!Macrobiotics
LNK files on Windows are shortcuts (data files that point to another file, along with some other data) - they are not symlinks. NTFS (Windows's filesystem) has symlinks as of Win7, and had hard links before that. OS X's Finder has Aliases, which are similar to Windows shortcuts in concept, but different in execution. OS X also supports symlinks on the filesystem. They all have different names because they're different things - don't use them interchangeably, especially since you know you don't understand them!Peursem
R
3

You didn't mention how the projects are laid out in svn, or how your java stuff is being built. These would be good details to add.

You want to look into dependency management - not symlinks. As @alroc points out, that feature of subversion isn't going to work on some platforms.

You really don't want svn:externals. They're a bad deal nearly all the time, and all the time if the external resolves to something in the same repo. This has been covered quite a bit, The accepted answer here is a good place to start.

I'd recommend you have a repo for the java app, a repo for the php stuff and then perhaps a repo for the common.

Your build (java) and deploy (php) can then resolve the appropriate version of the common repos artifact(s) from a repository (I recommend you look into nexus or artifactory)

Redhead answered 2/4, 2013 at 22:32 Comment(1)
It's a few pngs, a js and a css. I'm building a few HTML pages that will be used in PHP and JSP, so I'll keep them all in a single Subversion project, each on its own folder, and I don't wanna duplicate these static files.Macrobiotics

© 2022 - 2024 — McMap. All rights reserved.