Mercurial For Linux是一種輕量級(jí)分布式版本控制系統(tǒng),采用Python語言實(shí)現(xiàn),易于學(xué)習(xí)和使用,擴(kuò)展性強(qiáng),其是基于GNU General Public License(GPL)授權(quán)的開源項(xiàng)目。這個(gè)工具在國內(nèi)很少人使用,所以中文資料匱乏.只有官方的website上有一些少得可憐的中文資料了.不過總體上來說,還是比較好用的。
Linux下Mercurial (hg)配置說明
1.建立用戶hgrepo
其它用戶將用這個(gè)賬戶用hg服務(wù)器push代碼。
useradd hgrepo -d /home/hgrepo # add user hgrepo
passwd hgrepo
2.建立hg代碼倉庫
如果代碼倉庫名稱為project.hg,則可用如下命令。
cd /home/hgrepo
mkdir project.hg
cd project.hg
hg init # 初始化代碼倉庫
建立一個(gè)測試文件
echo "hello, mercurial" > sample.txt
hg add # add
hg ci # check in
3. 打開http
打開一個(gè)端口,讓遠(yuǎn)程用戶可以clone倉庫中的代碼.
在打開端口前請(qǐng)確定文件權(quán)限正確。
更改文件權(quán)限
chown hgrepo.hgrepo /home/hgrepo/project.hg -R
chmod og+rw /home/hgrepo/project.hg -R
打開端口
cd /home/hgrepo/project.hg -R
hg serve -p 8002 &
可將上面兩行加入/etc/rc.local這樣就可以在開機(jī)的時(shí)候自動(dòng)運(yùn)行了。
4.使用hg
完成步驟3以后,我們就可以使用了。
clone到本地
例如你的服務(wù)器的名字為test.
hg clone http://test:8002
然后在本地目錄就會(huì)出現(xiàn)一個(gè)project.hg的一個(gè)copy.
修改Client端的配置
更改.hg/hgrc,加上default-push和username
[paths]
default = http://test:8002
default-push = ssh://hgrepo@test//home/hgrepo/project.hg/
[ui]
username=shaohui.zheng
這樣你就可用hg push 向服務(wù)器提交code了。這時(shí)服務(wù)器會(huì)問你passward,這個(gè)password就是用戶hgrepo的password.
Good Luck.