一直到现在使用的版本控制软件都是Borland的starteam,subversion是一个很有名气的开源版本管理软件,周末正好挺闲的,就是试用了一下。
1:下载安装包
我是在官网下载的“Setup-Subversion-1.5.3.msi”
 
2:安装并配置
我本地安装的apache2.2,所在安装的时候选择的也是biding2.2,配置参考的是Readme.txt
 
3:创建一个版本库
svnadmin create F:\dev\svn\svn_rep2
 
4:导入工程customfields
C:\>svn import F:\dev\eclipse\workspace\hibertest\src\customfields file:///F:/dev/svn/svn_rep2/customfields -m "initial import"
增加                     F:\dev\eclipse\workspace\hibertest\src\customfields\Contact.hbm.xml
增加                     F:\dev\eclipse\workspace\hibertest\src\customfields\HibernateUtil.java
增加                     F:\dev\eclipse\workspace\hibertest\src\customfields\TestCustomEntities.java
增加                     F:\dev\eclipse\workspace\hibertest\src\customfields\MyTest.java
增加                     F:\dev\eclipse\workspace\hibertest\src\customfields\MappingManager.java
增加                     F:\dev\eclipse\workspace\hibertest\src\customfields\TestQueryCustomFields.java
增加                     F:\dev\eclipse\workspace\hibertest\src\customfields\CustomizableEntityManager.java
增加                     F:\dev\eclipse\workspace\hibertest\src\customfields\Contact.java
增加                     F:\dev\eclipse\workspace\hibertest\src\customfields\CustomizableEntityManagerImpl.java
增加                     F:\dev\eclipse\workspace\hibertest\src\customfields\CustomizableEntity.java
增加                     F:\dev\eclipse\workspace\hibertest\src\customfields\XMLUtil.java

提交后的版本为 1。
 
5:Checkout文件
C:\>svn checkout file:///F:/dev/svn/svn_rep2/customfields svn_test
A        svn_test\Contact.hbm.xml
A        svn_test\HibernateUtil.java
A        svn_test\TestCustomEntities.java
A        svn_test\MyTest.java
A        svn_test\MappingManager.java
A        svn_test\TestQueryCustomFields.java
A        svn_test\CustomizableEntityManager.java
A        svn_test\Contact.java
A        svn_test\CustomizableEntityManagerImpl.java
A        svn_test\CustomizableEntity.java
A        svn_test\XMLUtil.java
取出版本 1。
 
6:修改文件
在本地修改Contant.java文件,如在其中添加code属性:
C:\svn_test>svn status
M            Contact.java

C:\svn_test>svn diff Contact.java
Index: Contact.java
===================================================================
--- Contact.java                (版本 3)
+++ Contact.java                (工作副本)
@@ -20,4 +20,8 @@
                public void setName(String name) {
                                this.name = name;
                }
+
+             public void setCode(String s){
+                             this.code = s;
+             }
}

C:\svn_test>svn commit -m "add code"
正在发送             Contact.java
传输文件数据.
提交后的版本为 4。

C:\svn_test>svn log Contact.java
------------------------------------------------------------------------
r4 | kinkding | 2009-04-11 15:37:13 +0800 (星期六, 2009-04-11) | 1 line

add code
------------------------------------------------------------------------
r2 | kinkding | 2009-04-11 15:10:52 +0800 (星期六, 2009-04-11) | 1 line

add code property
------------------------------------------------------------------------
r1 | kinkding | 2009-04-11 15:03:58 +0800 (星期六, 2009-04-11) | 1 line

initial import
------------------------------------------------------------------------
 
7:删除文件
C:\svn_test>svn delete Good.java
D                 Good.java

C:\svn_test>svn commit -m "Delete Good.java"
删除                     Good.java

提交后的版本为 5。
 
8:新增文件
C:\svn_test>svn status
?            svn.txt

C:\svn_test>svn add svn.txt
A                 svn.txt

C:\svn_test>svn commit -m "add svn.txt"
增加                     svn.txt
传输文件数据.
提交后的版本为 6。
 
9:以SVN协议的方式访问
修改配置文件svnserve.conf,我的改动如下:
password-db = kinkpw
kinkjpw文件只有下面两行内容
[users]
kink = kink
如果password-db前有空格,则连接时会出现如下错误:
C:\>svn list svn://localhost/customfields
svn: F:\dev\svn\svn_rep2\conf\svnserve.conf:20: Option expected
 
启动服务器
C:\>svnserve -d -r F:\dev\svn\svn_rep2
 
连接服务器
C:\>svn list svn://localhost/customfields
Contact.hbm.xml
Contact.java
CustomizableEntity.java
CustomizableEntityManager.java
CustomizableEntityManagerImpl.java
HibernateUtil.java
MappingManager.java
TestCustomEntities.java
TestQueryCustomFields.java
XMLUtil.java
svn.txt
 
试验验证
C:\svn_test>svn delete svn.txt
D                 svn.txt

C:\svn_test>svn commit -m "delete file"
认证领域: <svn://localhost:3690> ca4e16ed-1dec-4f47-81da-681e2088f8a5
“kinkding”的密码: ****
认证领域: <svn://localhost:3690> ca4e16ed-1dec-4f47-81da-681e2088f8a5
用户名: kink
“kink”的密码: ****
删除                     svn.txt

提交后的版本为 7。
 
10:采用http协议访问
首先需要进行一些配置:
1. Copy bin/mod_dav_svn.so and bin/mod_authz_svn.so to the Apache modules directory.
2. Add the Subversion/bin directory to the SYSTEM PATH and reboot so all the Subversion
     support dll's are visible to the Apache service.
3. Edit the Apache configuration file (httpd.conf) and make the following changes:

    3a. Uncomment the following two lines:

            #LoadModule dav_fs_module modules/mod_dav_fs.so
            #LoadModule dav_module modules/mod_dav.so

    3b. Add the following two lines to the end of the LoadModule section:

            LoadModule dav_svn_module modules/mod_dav_svn.so
            LoadModule authz_svn_module modules/mod_authz_svn.so

    3c. Add the following to end of the file. Note: This Location directive is a
            minimal example with no authentication directives. For other options,
            especially authentication options, see the Subversion INSTALL file,
            the Subversion Book, or the TortoiseSVN Manual.

            <Location /svn>
                DAV svn
                SVNPath F:/dev/svn/svn_rep2
            </Location>
之后启动apache服务器
接下来就可以通过http协议访问了:
C:\>svn list [url]http://127.0.0.1:8070/svn[/url]
customfields/

C:\>svn list [url]http://127.0.0.1:8070/svn/customfields[/url]
Contact.hbm.xml
Contact.java
CustomizableEntity.java
CustomizableEntityManager.java
CustomizableEntityManagerImpl.java
HibernateUtil.java
MappingManager.java
TestCustomEntities.java
TestQueryCustomFields.java