Can we set a single file as external in Subversion?
Asked Answered
F

4

32

Can we set a single file as external in Subversion?

Forwhy answered 31/8, 2009 at 5:40 Comment(0)
J
24

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.

Jevon answered 31/8, 2009 at 6:51 Comment(7)
the issue with binary files (subversion.tigris.org/issues/show_bug.cgi?id=3368) is fixedQuadrilateral
still one should note, that external files can only be included from the same repository as the folder that holds the externals-definitionKenny
Janosch: that's not true. file-externals can come from any repository.Jevon
Stefan, according to the documentation to which you linked, Janosch is correct. Quoting from the documentation: "File externals cannot refer to files from other repositories." That's further confirmed by the error messages I get when I try to external files in another repo: 'http://my.repo.server/src/external_repo/file1.html' is not in repository 'http://my.repo.server/src/current_repo' Can you elaborate on how to get files from other repositories to be externals?Derm
@Jevon Same here - does not seem to be possible from another repository in 1.6Napoli
@Derm just tried it with 1.8 and it is still a limitation. The definitive answer then is to external a directory instead and ignore the other files in there.Knout
Any news about this? Is there a feature request for this, which i dont find?Kenny
W
6

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.

Whenas answered 2/8, 2017 at 7:9 Comment(1)
Actually, your workaround is kinda brilliant, because in all of my cases, I am the one controlling both repos. This is a great way to (for instance) pluck an ESP32 custom library out of a base project and drop it into a target application project.Saddlebow
R
4

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.

Reimburse answered 22/6, 2015 at 8:26 Comment(2)
Strange, the SVN docs claim file externals are not possible across repositories.Ogletree
Nikita Bosik's answer blelow is preferred as it allows relative paths.Diapophysis
C
1

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
Crannog answered 9/6, 2016 at 19:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.