Wednesday, August 12, 2009

My SVN Note

================================================================
- Check Out: 好像頭一次時用 (download 整個東西).

- Update: downloading latest files from SVN server.

- Commit: uploading those local modified files to SVN server.

- Repository-Browser: Browsing Files on the SVN server.

- Check-For-Modifications: Browsing local modified files.

- 據說用 BDB repository 不好?會有很多 problems?有些人推薦改用 FSFS?("FSFS" is the name of a Subversion filesystem implementation)

- How do I Update selected files from the repository?
- Use TortoiseSVN → Check for Modifications. and click on Check repository to see what has changed in the repository. Select the files you want to update locally, then use the context menu to update just those files. Note:

- 在 a folder 上按右鍵,和 在 a file 上按右鍵的意思有時候不太一樣喔!

- ignore: 不要把 binary files 放到 repository,所以,可以把一些 file extension 加到 global ignore pattern.

- Update 時,選擇 sub folders (例如 module folder),會比 update 整個 root 快。

- 你在哪按 "update" 就只會 update 那個 file or folder 底下的東西。

- 更新(Update):當你修改自己的工作複本時,當然其他團隊成員也可能正在修改一些檔案,每個人的修改作業都是獨立進行且不會相互影響的,別人修改的結果也不會立即反映在你本機的工作複本上。如果你要看到別人修改的最新版本,你就必須執行更新(update)動作。當你的同僚執行 update 時,他們(通常)也會取得你最近 check in 的版本。

- Check out 和 update 的行為有些相似,二者皆是從檔案庫把檔案拉回本機,但他們的使用時機和目的並不相同。你必須把檔案 check out 至本機,之後才可以對這些工作複本執行 update 動作。

- 以上介紹的是所謂的單一檔案庫的方式
其實也可以共存多個檔案庫
例如 將 D:\SVN設為SVN Server的跟目錄 不過不在這裡建立檔案庫
在 他的子目錄建立檔案庫 例如 D:\SVN\Proj1
在客戶端存取時一樣只要加上路徑Proj1即可
建立多個檔案庫的優點是可以分散風險 避免當檔案庫損毀的危險
另外也可以使的檔案版本編號成長的慢一些 ^^
缺點就是 設定跟權限都要各自維護

- 這是我使用SVN幾年來的一點點心得
不要將一些不該存的檔案放到檔案庫中
以程式設計為例 不要將*.o *.obj *.dll *.exe *.tmp等檔案上傳
這些除了有些是暫存檔外 有些可以利用其他檔案 經由簡單步驟所產生(編譯)
但是 相對的 *.sln *.vcproj (Visual Studio的專案檔)或是其他專案檔 就一定要保留
才能讓其他人也利用檔案庫中有的檔案 快速的產生結果
另外 也不需要將檔案壓縮起來之後 在放入檔案庫
檔案庫會自動幫你做檔案的壓縮
壓縮起來反而不利做版本之間的比對

要大幅度修改文件內容 或是要將原文件修改到另外一個用途
不需要先將原文件複製到另一個文件夾或是加一個.bak做區隔
反而浪費容量 也不易管理
直接使用SVN提供的 分支(branch) 或是 標記(tag) 功能即可

如果有一個文件會有多人要修改 尤其是 Word , Excel 這種文件
(存成二進位檔 非明文 的文件)
在開始修改前 要先將他鎖定 等修改完之後在解除
因為這類檔案 不像程式碼 或是一般txt 存成明文的文件
可以簡易的進行比對 分析差異 當你在修改時 有其他人已經修改並上傳
就會非常麻煩....

修改前最好先進行 更新 (Update)的動作 讓自己要修改的版本是最新的
修改完成後(測試後)也要馬上進行 上傳修改(Commit)的動作

- 專案的目錄結構

這裡補充說明一下 ProjectA 的目錄結構。在 ProjectA 專案的根目錄下建立的 trunk、branches、和 tags 這三個目錄是有特別意義的,它們的作用分別是:

* trunk 目錄用來存份目前專案正在進行開發的程式檔案和文件(又稱為主線,即 mainline);
* branches 用來存放主線的各個仍在發展中的分支;
* tags 則用來存放已經不再變動的分支,也就是其中的檔案不會再修改了。

這是 Subverion 官方手冊建議的目錄結構安排方式,你可以自己決定要不要用這種配置方式,詳細說明請參考官方手冊的第五章,子標題為 "Choosing a Repository Layout"。
================================================================
Questions:

- What's the difference between "SVN update" and "update to revision"?

- Revert: Undo changes. (Keep trying and figuring out)

- how to have multiple repositories.

- restore repository.

- Blame

- Lock

- Issue Tracker.

- WinMerge 似乎是好東西來的?

- CommitMonitor 似乎是好東西來的?

- FreeMind 似乎是好東西來的?

- Folder Permissions.

- 在 production server 上裝個 SVN client? 然後通過 update 去更新資料?
================================================================
- 心得就是,如果兩個人同時在 modifing a file,先完成的人,則去 commit,commit 以後,後完成的人要 commit 時,SVN 會自動的去 check 你的版本是否 outdate,如果是的話,那麼得先 "update" 再 "commit",如果 SVN 能夠自己自動 mergered 的話,它就不會 complain conflict;如果它沒有辦法 (不夠 smart) 自動 mergered 的話,它就會 complain conflict,像這個時候,就得靠人工去審核了。

- show log > select any two versions > compare selected.
=================================================================
Configurations:

- EditPlus 的設定
- use "two spaces" instead of "tab".
- bakcup directory must set to d:\bak
- "Home" key goes to first non-white-character.

- TortoiseSVN 的 設定
- Icon Overlays 取消掉,並 exclude & include paths.

- Server Side Backup Strategy (SVN).
- SVN hotcopy
- SVN dump
- tar entire directory.
- svnsync

- Server Side Restore Strategy (SVN).

- Server Side Backup Strategy (Source code). It's recommened to put big files on separate directory. Do not put big files on the same directory as source code.

- Client Side Backup Strategy. Use the Backup Script to backup the folder.

- Transfer Strategy (From Devlopment Site to Production Site) (Should Image files or other non-source-code files be included in SVN folder?)

-

=================================================================
Rules:

- Only Commit files you meant to be. (create, modify, delete files)

-
================================================================

No comments: