reference: http://www.duduwolf.com/post/setting_up_subversion.asp

http://www.subversion.org.cn/svnbook/nightly/svn.basic.in-action.html

 

version: Setup-Subversion-1.6.6.msi

 

創(chuàng)建repository

svnadmin create d:\svnReps

其中d:\svnReps是repository的儲存位置。

repository創(chuàng)建完畢后會在目錄下生成若干個文件和文件夾,dav目錄是提供給Apache與mod_dav_svn使用的目錄,讓它們存儲內部數據;db目錄就是所有版本控制的數據文件;hooks目錄放置hook腳本文件的目錄;locks用來放置Subversion文件庫鎖定數據的目錄,用來追蹤存取文件庫的客戶端;format文件是一個文本文件,里面只放了一個整數,表示當前文件庫配置的版本號;

 

簡單的權限配置

打開/conf/目錄,打開svnserve.conf找到一下兩句:

# [general]
# password-db = passwd

去之每行開頭的#,其中第二行是指定身份驗證的文件名,即passwd文件
同樣打開passwd文件,將

# [users]
# harry = harryssecret
# sally = sallyssecret

這是設置用戶,一行一個,存儲格式為“用戶名 = 密碼”,如可插入一行:admin = admin888,即為系統(tǒng)添加一個用戶名為admin,密碼為admin888的用戶

 

運行SVN服務

方式一,run svnserve as daemon:

svnserve –d -r d:\svnReps

使用-r可以有效地改變文件系統(tǒng)的根位置,客戶端可以使用去掉前半部分的路徑,留下的要短一些的(更加有提示性)URL:

比如:$ svn checkout svn://host.example.com/project1

方式二:run svnserver as a service:

1.使用svnserve通過inetd(for *nix)

2.Run svnserve as a Microsoft Windows service.

C:\> sc create svn
binpath= "\"C:\Program Files\Subversion\bin\svnserve.exe\" --service -r d:\svnReps"
displayname= "Subversion Server"
depend= Tcpip
start= auto
這段命令注冊了一個service,會自動啟動subversion svnserver
Be careful about spaces in your commandline to be invoked. If a directory name contains spaces (or other characters that need escaping),
place the entire inner value of binpath in double-quotes, by escaping them。
 
然后啟動服務:
C:\> net start svn
可以通過刪除其定義刪除服務:sc delete svn,只需要確定首先停止服務

 

權限配置

svnserve.conf有兩個或多個參數需要設置:它們確定未認證(匿名)和認證用戶可以做的事情,參數anon-accessauth-access可以設置為noneread或者write,設置為none會限制所有方式的訪問,read允許只讀訪問,而write允許對版本庫完全的讀/寫權限

簡單配置的信息如下:

anon-access = none
auth-access = write

password-db = passwd

realm = my first responsity

 

到此,svn 已經可以很好的工作了,下面的內容主要是與eclipse相關的。 訪問svn可以使用svn://hostname

 

 

 

 

 

附錄:

理解Subversion的混合修訂版本機制

作為一個普遍原理,Subversion努力做到盡可能的靈活,一個特殊的靈活特性就是讓工作拷貝包含不同工作修訂版本的文件和目錄,不幸的是,這個靈活性會讓許多新用戶感到迷惑。如果上一個混合修訂版本的例子讓你感到困惑,這里是一個為何有這種特性和如何利用這個特性的基礎介紹。

Updates and commits are separate

One of the fundamental rules of Subversion is that a “push” action does not cause a “pull,” nor the other way around. Just because you're ready to submit new changes to the repository doesn't mean you're ready to receive changes from other people. And if you have new changes still in progress, then svn update should gracefully merge repository changes into your own, rather than forcing you to publish them.

The main side effect of this rule is that it means a working copy has to do extra bookkeeping to track mixed revisions as well as be tolerant of the mixture. It's made more complicated by the fact that directories themselves are versioned.

For example, suppose you have a working copy entirely at revision 10. You edit the file foo.html and then perform an svn commit, which creates revision 15 in the repository. After the commit succeeds, many new users would expect the working copy to be entirely at revision 15, but that's not the case! Any number of changes might have happened in the repository between revisions 10 and 15. The client knows nothing of those changes in the repository, since you haven't yet run svn update, and svn commit doesn't pull down new changes. If, on the other hand, svn commit were to automatically download the newest changes, then it would be possible to set the entire working copy to revision 15—but then we'd be breaking the fundamental rule of “push” and “pull” remaining separate actions. Therefore, the only safe thing the Subversion client can do is mark the one file—foo.html—as being at revision 15. The rest of the working copy remains at revision 10. Only by running svn update can the latest changes be downloaded and the whole working copy be marked as revision 15.

 

混合版本的限制

無論你如何在工作拷貝中利用混合修訂版本,這種靈活性還是有限制的。

First, you cannot commit the deletion of a file or directory that isn't fully up to date. If a newer version of the item exists in the repository, your attempt to delete will be rejected in order to prevent you from accidentally destroying changes you've not yet seen.

Second, you cannot commit a metadata change to a directory unless it's fully up to date. You'll learn about attaching “properties” to items in 第 3 章 高級主題. A directory's working revision defines a specific set of entries and properties, and thus committing a property change to an out-of-date directory may destroy properties you've not yet seen.