#眉標=Project management #副標=版本控制系統(2) #大標=Concurrent Versions System管理 #作者=文/歐宣修 =========<box>================ [程式1] public class Hello { public static void main(String args[]) { System.out.println("Hello~"); } } 增加一列程式碼,並將它Commit上Server: import java.sql.Timestamp; public class Hello { public static void main(String args[]) { System.out.println("Hello~"); } } ================================= ============================ [程式2] public class Hello { public static void main(String args[]) { System.out.println("Hello~"); System.out.println("Now:"+new Timestamp(System.currentTimeMillis())); } } =============================== 存檔後執行Checkout動作,會發現在log console,CVS幫我們檢查兩支程式不同處,並執行Merging功能,訊息如下: ========================= RCS file: /y6/src/Hello.java,v retrieving revision 1.8 retrieving revision 1.9 Merging differences between 1.8 and 1.9 into Hello.java M src/Hello.java *****CVS exited normally with code 0***** =============================== 最後我們會得到最完整的程式碼,再將最後結果也Commit上去,如此所有專案成員都會享受到最完整的版本: ============================ [程式3] import java.sql.Timestamp; public class Hello { public static void main(String args[]) { System.out.println("Hello~"); System.out.println("Now:"+new Timestamp(System.currentTimeMillis())); } } ========================== 接下來看看什麼是Conflict情形,請將d:\y6\src\Hello.java System.out.println("Hello~"); 改成 System.out.println("Hello Senshaw"); 並Commit上CVS,接著切換至d:\y6_2\src\Hello.java,請改成 System.out.println("Hello Nana"); 執行Update後會發現CVS嘗試Merging,但發生衝突,圖示會顯示「C」,訊息如下: =============================== cvs update Hello.java (in directory D:\y6_2\src\) RCS file: /y6/src/Hello.java,v retrieving revision 1.10 retrieving revision 1.11 Merging differences between 1.10 and 1.11 into Hello.java rcsmerge: warning: conflicts during merge cvs server: conflicts found in Hello.java C Hello.java *****CVS exited normally with code 0***** ================================== 開啟Hello.java程式碼,可以清楚辨別衝突的部份,此時只有靠我們自行去修正,再Commit回Server。(程式4) ================================= [程式4] import java.sql.Timestamp; public class Hello { public static void main(String args[]) { <<<<<<< Hello.java System.out.println("Hello Nana"); ======= System.out.println("Hello Senshaw"); >>>>>>> 1.11 System.out.println("Now:"+new Timestamp(System.currentTimeMillis())); } } ============================= ===============<end>==================