32
votes

Can we set a single file as external in Subversion?

4

4 Answers

24
votes

Yes, it's possible with svn 1.6. It's documented in the nightly build version of the svn book.

But even though file externals are working, you should only do it with text files (for now) because binary files won't work correctly as file externals.

5
votes

As mentioned in the first answer, SVN Externals are documented in Chapter 3 of the SVN Book, and quite a few syntax examples are given there.

In addition, this note is given:

"Because the svn:externals property has a multiline value, we strongly recommend that you use svn propedit instead of svn propset."

In my experience testing Tortoise SVN v1.9.6 and svn.exe v1.9.5, the results are as-documented.

  • Bringing in an external folder with all its files works.
  • Bringing in a single file from the same repo works.
  • Bringing in a single file from a different repo fails and this limitation is documented in the SVN book.

This leads to a clumsy workaround. If you control both repos, you can clone an individual file into its own folder in the source repo (by Externals of a single file WITHIN a repo), and then Externals it across repo borders into the target repo by bringing in its entire folder, which contains only a single file.

Docs for doing this with the Tortoise SVN client are on tortoisesvn.net.

4
votes

I couldn't find a good example about how to create a svn file external. So I am providing an example here so it can be useful for others.

The format is

svn propset svn:externals "<local file> <remote svn file>" <local dir>

For e.g. following command

svn propset svn:externals "my.cfg https://myserver/my/svn/location/my_sample_file.cfg.template" my_folder

will create the file https://myserver/my/svn/location/my_sample_file.cfg.template under my_folder as my.cfg. Here obviously, I assume you already have the folder my_folder under your current directory which is under svn.

1
votes

For SVN 1.9.4 the syntax is like folder's one:

svn propset svn:externals <remote file> <local file>

E.g., this will create file local.txt in the current directory referencing to file.txt:

svn propset svn:externals ^/trunk/path/to/file.txt local.txt