Mercurial 簡介

75
Mercurial A Distributed Source Management System

description

 

Transcript of Mercurial 簡介

Page 1: Mercurial 簡介

Mercurial

A Distributed Source Management

System

Page 2: Mercurial 簡介

資工人:

Page 3: Mercurial 簡介

寫程式,

Page 4: Mercurial 簡介

改程式...

Page 5: Mercurial 簡介

改錯了?!

本來會動,現在不會動。

Page 6: Mercurial 簡介
Page 7: Mercurial 簡介

備份!

Page 8: Mercurial 簡介

COPY…

改之前 copy 一份起來

Page 9: Mercurial 簡介

COPY…

改錯了 copy 回來

Page 10: Mercurial 簡介

COPY?!

錯的蓋掉對的!

Page 11: Mercurial 簡介
Page 12: Mercurial 簡介

更慘的..

Page 13: Mercurial 簡介

專案

Page 14: Mercurial 簡介

大家一起寫

Page 15: Mercurial 簡介

共用程式碼

Page 16: Mercurial 簡介

一起寫?

Pair Programming

Page 17: Mercurial 簡介

不可能

Page 18: Mercurial 簡介

COPY

ZIP / RAR

網芳 / E-mail

Page 19: Mercurial 簡介

網芳 / E-mail

UnZIP / UnRAR

COPY

Page 20: Mercurial 簡介

噩夢

Page 21: Mercurial 簡介

你改,

Page 22: Mercurial 簡介

他也改…

Page 23: Mercurial 簡介

改了哪裡?

沒人知道…:P

Page 24: Mercurial 簡介

還是噩夢

Page 25: Mercurial 簡介

救星:

Page 26: Mercurial 簡介

版本控制

Page 27: Mercurial 簡介

誤刪?

Page 28: Mercurial 簡介

歷史紀錄

Page 29: Mercurial 簡介

程式碼整合?

Page 30: Mercurial 簡介

自動合併

Page 31: Mercurial 簡介

標示衝突

Page 32: Mercurial 簡介

</噩夢>

Page 33: Mercurial 簡介

有名的:

Page 34: Mercurial 簡介

CVS

有人用過嗎?

Page 35: Mercurial 簡介

Subversion

(SVN)應該有用過吧?

Page 36: Mercurial 簡介

美好世界?

Page 37: Mercurial 簡介

Client-Server

Centralized

Page 38: Mercurial 簡介

Client:

Page 39: Mercurial 簡介

專用Client

(GUI)

WinCVS

Page 40: Mercurial 簡介

開發環境整合

Eclipse, NetBeans, Vim, …

Page 41: Mercurial 簡介

作業系統整合

TotoriseSVN

Page 42: Mercurial 簡介

Server:

Page 43: Mercurial 簡介

http://

svn://

svn+ssh://眼花撩亂…

Page 44: Mercurial 簡介

權限控管

麻煩

Page 45: Mercurial 簡介

又是噩夢

Page 46: Mercurial 簡介

沒網路…

Page 47: Mercurial 簡介

Page 48: Mercurial 簡介

一人專案

Page 49: Mercurial 簡介

Server?

多此一舉…

Page 50: Mercurial 簡介

Local

Repository獨立的目錄

Page 51: Mercurial 簡介

仍然是噩夢

Page 52: Mercurial 簡介

救星:

似曾相識…

Page 53: Mercurial 簡介

分散式版本控制

後 subversion 時代

Page 54: Mercurial 簡介

自掃門前雪

Page 55: Mercurial 簡介
Page 56: Mercurial 簡介

熱門的

• SVK– Based on Subversion

• Mercurial (Hg)– Python

– Mozilla, NetBeans, OpenJDK

• Git– C

– Linux kernel, Ruby / Rails

• Bazzar (bzr)– Python

Page 57: Mercurial 簡介

Mercurial

回歸主題

Page 58: Mercurial 簡介

汞 Hg

執行檔就叫 “hg”

Page 59: Mercurial 簡介

第一步

• 建立新專案

– cd project/

– hg init

– [hg add]

• 目錄

– 工作目錄: project/

– 檔案庫位置: project/.hg

Page 60: Mercurial 簡介

基本指令

檔案管理

• 加入新的檔案– hg add [FILE …]

• 移除檔案– hg remove [FILE …]

• 改名– hg rename OLD NEW

檢視修改狀況

• 顯示更動狀態– hg status [FILE …]

• 查看檔案內容變更– hg diff [-r REV] [FILE …]

• 檢視更新紀錄– hg log

– hg glog (樹狀圖)

Page 61: Mercurial 簡介

送交修改

• 送交修改

– hg commit [FILE …]

• 放棄修改 (工作目錄)

– hg revert [FILE …]

• 還原最近一次修改 (檔案庫)

– hg rollback

Page 62: Mercurial 簡介

分支 (Branch)

• 建立新的分支– hg branch BRANCH_NAME

• 在分支中切換– hg update -r BRANCH_NAME

– 預設分支: “default”

• 列出所有分支– hg branches

Page 63: Mercurial 簡介

標記、標籤 (Tag)

• 建立新的標記

– hg tag TAG_NAME

• 在分支中切換

– hg update -r TAG_NAME

• 列出分支

– hg tags

Page 64: Mercurial 簡介

版本概念

Page 65: Mercurial 簡介

多人合作

• 公開檔案庫 (HTTP)

– hg serve

• 抓取已經存在的檔案庫內容– hg clone EXIST_REP project/

• EXIST_REP 格式:

– http[s]://server/project

– svn://server/path/to/project

– [file://]path/to/project

Page 66: Mercurial 簡介

多人合作

• 送出你的 (檔案庫) 修改– hg push REMOTE

• 抓取後續的 (檔案庫) 變更– hg pull REMOTE

• 更新工作目錄 (與檔案庫同步)– hg update [-r REV]

• 合併更動 (到工作目錄)– hg merge [-r REV]

Page 67: Mercurial 簡介

分散式架構

Page 68: Mercurial 簡介

檔案庫合併 (前)

Page 69: Mercurial 簡介

檔案庫合併 (中)

Page 70: Mercurial 簡介

檔案庫合併 (後)

Page 71: Mercurial 簡介

工具

• Mercurial Windows Installer

– http://mercurial.berkwood.com/

• Mercurial Eclipse

– http://www.vectrace.com/mercurialeclipse/

• TotoriseHg

– http://www.selenic.com/mercurial/wiki/index.c

gi/Mercurial

Page 72: Mercurial 簡介

TotoriseHg (1)

Page 73: Mercurial 簡介

TotoriseHg (2)

Page 74: Mercurial 簡介

更多資料

• 官方網站

– http://www.selenic.com/mercurial/

• Cheat Sheet (小抄)

– http://www.ivy.fr/mercurial/ref/v1.0/

Page 75: Mercurial 簡介

The End

Any Question?