Can we set a single file as external in Subversion

2019-01-14 20:29发布

Can we set a single file as external in Subversion?

4条回答
祖国的老花朵
2楼-- · 2019-01-14 20:47

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.

查看更多
Melony?
3楼-- · 2019-01-14 20:53

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.

查看更多
可以哭但决不认输i
4楼-- · 2019-01-14 20:54

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
查看更多
Emotional °昔
5楼-- · 2019-01-14 20:59

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.

查看更多
登录 后发表回答