1 / 60

淺談版本控制系統

淺談版本控制系統. 觀念介紹與版本控制系統軟體介紹 Jim Huang ( 黃敬群 ) http://jserv.sayya.org/ May 19, 2005. 目標. 理解版本控制系統的重要性與優點,並如何導入開發流程 版本控制系統軟體 Subversion 觀念與快速入門. 為何需要版本控制 (Version Control) ?. 在需要協同開發 / 創作的環境中,確保能夠進行 … 保有所有更動的紀錄 得以快速回復到特定版本的狀態 得知成員的更動與其更動幅度 Code Peer review 鼓勵版本異動文件創作. RELEASE 2.0.

gaius
Download Presentation

淺談版本控制系統

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 淺談版本控制系統 觀念介紹與版本控制系統軟體介紹 Jim Huang (黃敬群) http://jserv.sayya.org/ May 19, 2005

  2. 目標 • 理解版本控制系統的重要性與優點,並如何導入開發流程 • 版本控制系統軟體 • Subversion 觀念與快速入門

  3. 為何需要版本控制 (Version Control) ? • 在需要協同開發 / 創作的環境中,確保能夠進行… • 保有所有更動的紀錄 • 得以快速回復到特定版本的狀態 • 得知成員的更動與其更動幅度 • Code Peer review • 鼓勵版本異動文件創作

  4. RELEASE 2.0 1.7 1.6 1.5 1.5 1.4 1.4 1.4 RELEASE 1.5 1.3 1.3 RELEASE 1.0 1.2 1.2 1.1 1.1 典型的版本變遷 1.3 1.2 1.2 1.1 1.1 1.0 1.0 1.0 1.0 C.I. 1 C.I. 2 C.I. 3 C.I. X

  5. Oracle, Sybase, etc. Tracker (Issue management) 軟體系統化管理 Version Manager (Version control, Release management) Configuration Builder (Build scripting tool)

  6. 版本控制系統是什麼? • 能夠追蹤、比較、回復、提交程式碼或文件更動的系統,同時也要能夠跨越多個環境與群組開發時程的系統 • 維護並時 (concurrent) 的更動與保有每個版本的程式碼與文件狀態資訊

  7. 版本控制系統 (集中化模式) Synchronization A A Central Repository Local Workspace(s)

  8. 詞彙:Repository vs. Workspace • workspace • 一系列透過版本控制系統的程式碼與文件集合,開發者可以在本機上進行維護與修改的動作 • repository • 在集中式版本控制系統的主機上,保存文件與程式碼的資料庫或檔案庫

  9. 版本控制系統軟體 • Commercial • Bitkeeper • Visual SourceSafe • Open Source / Free • SCCS • RCS (Walter F. Tichy, 1982) • CVS (Brian Berliner & Jeff Polk, 1992) • GNU Arch • Subversion (Karl Fogel, 2002) • SVK (clkao, 2004)

  10. CVS (Concurrent Version System) • 歷久彌新 • CVS 伺服器組態設定 • Pserver • relatively easy to configure on the client side, low security • SSH • high security, client & server configuration a bit trickier

  11. CVS 優點 • 歷史悠久 • 在許多現有的軟體專案施行有年,系統穩定,相關工具也豐富 • 設定與操作相對簡易

  12. CVS 缺點 • Security! • 不能移除目錄 • 二進位檔案有可能被修改 • 效率

  13. Subversion • CVS 的替代計畫,與 CVS 具有類似的操作方式與流程 • 多樣的伺服器配置方式: • Apache web server • svnserve • custom server • svnserve & ssh • custom server with encryption layer

  14. Subversion 優點 • 目錄版本控制 • 不可分割的送交 • 網路傳輸快速 • 參數一致 • 更佳的二進制處理 • 高效率的分支與標記

  15. Subversion 缺點 • 仍然是集中式的版本控制系統 • 缺乏獨佔編輯權的設計 • 更動版本號是共用的

  16. SVK -- 非集中式版本控制系統 • 以 Subversion 為基礎,但是同時支援現有 CVS 的 repository • 可取出完整的更動映射 • 大量的合併操作

  17. Subversion • 集中式版本控制系統 (Centralized VCS) • Released Feb. 2004, Open Source • HTTP/WebDAV access • “Better CVS” • Graphical Client Tools • TortoiseSVN,..

  18. Subversion 系統架構 • 概念性的兩端 • 本機端檔案系統 • Typically used for a single developer • Accessed via direct file read/write access • Requires that users have local accounts • Uses filesystem and user/group security • 遠端系統 • Accessed via a HTTP or HTTPS connection • Does not require that users have accounts on the server • Use Apache style authentication

  19. Web - Browser RO WebDAV Mount Repository as webfolder SVN Client tool Local Repository copy 存取 Subversion 的途徑

  20. Repository Resources • 所有被 Subversion 管理的檔案與目錄都有唯一的 URL 表示法 • 支援的 URL protocols • http, https (SSL encryption) http://svn.csie.net/svn/prj/trunk/TopGun protocol host repository directory

  21. 獲得 Subversion 存取權限 • 可透過內建 (svn) 或 WebDAV 的方式認證 • Install/Use Client Software • Browser • Web-Folder Support • TortoiseSVN (TortoiseSVN.tigris.org)

  22. TortoiseSVN • Subversion Client • Windows Explorer Extension

  23. Subversion 核心操作 • Import/Checkout • Update/Commit • Branch/Tag • Switch/Merge

  24. import • 將本地端目錄結構新增至既有的 repository • One time operation. • 在本地端目錄被 import 後,需要再次 check out • 確保其他開發者能夠存取到 import 的目錄

  25. Import before import A Central Repository Local Workspace(s) after in sync A A Central Repository Local Workspace(s)

  26. 場景: work/wort.f77 即將透過 Subversion 管理 Fort.f77

  27. import    

  28. Use Web Browser in System Use Repo-Browser in Tortoise Check Repository

  29. Subversion 指示器 • 在檔案總管的目錄與檔案圖示就會有一個打勾的符號 • ‘.svn’ 目錄保有該版本資訊

  30. checkout • 在本機檔案系統上,從 repository 取出文件與程式碼,並建立一份工作副本 (working copy) • One time operation. • 給予工作副本來源屬性資訊 • 在開始工作的前置動作

  31. Checkout before checkout A Central Repository Local Workspace(s) after in sync A A Central Repository Local Workspace(s)

  32. Checkout    

  33. Local Work on fort.f77 • 場景:取出 fort.f77 並作修改 • 最後將 ‘commit’ 到 repository

  34. commit • 確保 workspace 與 repository 的一致與同步 (sync) • 本地端的修改包含: • 文件與程式碼內容的修改、刪除,以及新增 • 當開發者認為足以公布本地端修改到 repository 時

  35. commit before commit A A’ Central Repository Local Workspace(s) after in sync A’ A’ Central Repository Local Workspace(s)

  36. ‘commit’ 的時機 • 最好能夠一次提交概念性、官能性,或者任務導向性的修改 • 至少確保原始程式碼還能通過編譯 • 更動記錄應該被保存在 commit 訊息中

  37. commit   

  38. Subversion Revision Number • Revision number 代表整個 repository 的更動版本號 • 並非只是本地端修改的版本號 • “HEAD” 表示最新的版本

  39. 追蹤 revisions 版本號 作者 訊息 更動文件與檔案 歷史修改記錄

  40. 版本間的比較 比較特定 revision 與本地端版本的差異  

  41. update • 將 repository 上的版本整合到本地端的工作副本 • 將 workspace 同步於 repository • 有可能會出現衝突 • Subversion 會試圖作有限度的整合與提醒

  42. update before update A’ A Central Repository Local Workspace(s) after in sync A’ A’ Central Repository Local Workspace(s)

  43. Update • 檢驗 repository 相較於本機端的版本是否有修改?  

  44. Check Log again! New revision 5 is there.

  45. Do update!  

  46. What is new ?

  47. 切換到特定Revision • 需要回復到之前的版本   

  48. 哪些檔案應該置放於版本控制系統? • Source Code files • *.C; *.java, *.for, *.txt, … • 程式關連檔案,如: • Build / Configuration files • Documentation • Test code + data sets

  49. What does not go into Subversion? • 可由原始程式碼衍生的檔案 • 暫時性或過渡性檔案 • *.o; *.obj, *.dll, *.exe, *.dvi • 當然,有時候允許例外 • 很少需要重新產生 (regenerated) 的資訊檔 • 不容易透過整合開發環境或現有工具再產生的項目

More Related