A very good feature is provided in svn called external definition, which simply means that an external svn repository can be mapped to a directory. This is a very simple function in itself, but it can bring a lot of changeable functions to the use and management of svn.

First, let's explain the function of external definition in detail. Let's illustrate with a user's usage scenario. Said as detailed as possible, so more verbose :).
Suppose there are two teams, one is the development team (dev-team) and the other is the documentation team (doc-team), working together to develop a product. These two groups have their own management and other reasons,
so it is better to use svn separately, so there are two svn repository, dev-svn and doc-svn. We assume that both repositories use a standard organizational structure (for a detailed discussion of the organizational structure,
please see future articles), and the current development is carried out in trunk. For the development group, the directories under trunk are organized as src, lib, build, etc.
For the development, testing, management, and separate use of the two teams, there is no problem, and it will not affect each other. However, when the final product is released, to do the installation program, at this time, two
projects . And obviously a common organizational structure is the documentation developed by the doc-team as part of the programs developed by the dev-team, etc. Then under the trunk of dev-svn, there
should be a directory called doc, and the content of the directory is the content of the trunk of doc-svn.
At this point, we can use the external definition function of svn to complete this task. The external definition of svn is actually an attribute added to the (parent) directory ( svn properties , which will be described later in detail). This attribute defines which external repository to reference and which (child) under the (parent) directory is to be referenced. ) directory.
Add an attribute called svn:externals to the parent directory. The content of the attribute is doc-name svn-url, svn-url indicates which svn connection to refer to, and doc-name indicates which directory the reference is placed in.
In the above scenario , we have to set an attribute sv:externals to the trunk directory of dev-svn, and the value of the attribute is doc

http://doc-svn/trunk,这样当你设置完之后,update一下本地工作区,biu的一下,doc就过来了,这时候从dev-svn的

trunk的角度看,就有了完整的内容,包括doc。
完整的命令是,在chechout下来的dev-svn的trunk目录下
#svn propset svn:externals “doc http://doc-svn/trunk” .
propset,表示使用propset命令,添加属性
svn:externals,表示要添加svn:externals属性
“doc http://doc-svn/trunk”,表示要给这个属性添加的值,因为这个属性包含空格,所以要用双引号括起来
之后的点,表示要把这个属性添加在本目录上

啰嗦了一通,想必大家看的也是云山雾罩的,自己做个试验就可以了。

一些高级的外部定义的用法,我们对一个目录不但可以定义一个外部定义,还可以定义多个。比如doc来自doc-svn,website来自web-svn等等。这时候我们需要把这些东西都作为svn:externals的属性值。
doc http://doc-svn/trunk
website http://web-svn/trunk
注意!这里是需要换行的,这个对于命令行来说,是非常痛苦的,而且外部定义这种值里面还包含空格的需要用双引号括起来的值来说,就是痛苦死了。好吧,我承认我到现在也没有成功的设置过。怎么办?好吧,我们可以用另外的方法来搞定。
svn propset这个命令可以使用一个外部文件的文件内容作为给属性添加的值。命令如下
svn propset svn:externals -F filename .
所以,一般的,凡是需要用到这类用法的地方,我都会生成一个文件叫做LINKS,放到svn上管理。LINKS的内容如下
doc http://doc-svn/trunk
website http://web-svn/trunk
这样我们就可以使用svn propset svn:externals -F LINKS . 这个命令来设置了。

对属性的替换,直接set一个其他的值就好了。可是,如果我们不想要这个外部定义了怎么办?注意!这里千万不能使用svn del命令(比如在dev-svn的trunk目录下执行svn del doc),这样你删除的不是这个外部定义,而是你引用的svn版本库的内容。如果很幸运的,你是在另外的项目有写入的权限,好了,恭喜你,你已经把那个项目咔嚓掉了。
正确的做法是使用svn propdel命令来删除掉svn:externals这个属性
svn propdel svn:externals

最后还要提醒一点,这个属性是放在这个目录上的,对于svn来说,目录也是受到管理的,目录和目录内的文件之类的是不同的。所以你如果只想对这个目
录进行操作,而不像对它下面的文件进行操作,使用svn的时候,记得加上-N参数。比如类似svn:externals这样的属性就是针对目录的。

其实外部定义,还有很多的高级的使用功能,具体的我就不详述了,请参阅svn的帮助或者阅读文档,http://svndoc.iusesvn.com/svnbook/1.2/svn.advanced.externals.html。 最新的文档(针对1.4,1.5的)是英文的,嘿嘿。

外部定义还有一些玩法,更多的还是在使用在基于svn管理的项目组织上,这个我会在以后的文章进行说明。