今天從源代碼安裝了mercurial,原本能夠用命令很簡單的安裝:
sudo apt-get install mercurial,可是安裝之後發現版本比較老,因此決定從源代碼安裝。html
官方網站:http://mercurial.selenic.com/wiki/
下載下來解壓縮之後,裏面有個README文件,打開之後按照說明來:python
Basic install:linux
$ make
$ make install
$ hg debuginstall
$ hg web
/**************************我安裝的過程當中沒有出現錯誤******************************************/
vim
安裝完成後執行 hg debuginstall 時出現了錯誤:bash
hg --version
abort: couldn't find mercurial libraries in [/usr/local/bin /usr/lib/python2.6 /usr/lib/python2.6/plat-linux2 /usr/lib/python2.6/lib-tk /usr/lib/python2.6/lib-old /usr/lib/python2.6/lib-dynload /usr/lib/python2.6/dist-packages /usr/lib/python2.6/dist-packages/PIL /usr/lib/python2.6/dist-packages/gst-0.10 /var/lib/python-support/python2.6 /usr/lib/python2.6/dist-packages/gtk-2.0 /var/lib/python-support/python2.6/gtk-2.0 /usr/local/lib/python2.6/dist-packages]
(check your install and PYTHONPATH)服務器
解決方法:
export PYTHONPATH=/usr/local/lib/python2.4/site-packages
或者:
把上面的加到這兩個文件中的一個: .bashrc、/etc/profile。而後就能夠正常使用了。
app
添加配置文件ssh
/********************************************************************/分佈式
此時再運行hg debuginstall ,會出現
Checking username...
no username supplied (see "hg help config")
(specify a username in your .hgrc file)
1 problems detected, please check your install!
這是因爲配置文件的緣由
經過man hgrc會看到一些說明。默認是去一些位置找配置文件的。若是沒有,就建立。源碼中contrib文件夾下提供了一個sample.hgrc,能夠拷貝過來修改
# cp sample.hgrc /root/.hgrc
# vim /root/.hgrc
這裏改一下:
### show changed files and be a bit more verbose if True
# verbose = True
### username data to appear in comits
### it usually takes the form: Joe User <joe.user@host.com>
username = Joe Who <j.user@example.com>
verbose = True
### --- Extensions
再運行hg debuginstall ,出現這個提示就能夠了
Checking encoding (UTF-8)...
Checking extensions...
Checking templates...
Checking patch...
patching file hg-debuginstall-wCOuEs
Checking commit editor...
Checking username...
No problems detected
運行hg,出現
分佈式軟件配置管理工具 - 水銀 (版本 1.5.0)
版權全部 (C) 2005-2009 Matt Mackall <mpm@selenic.com> 和其餘人。
這是自由軟件,具體參見版權條款。這裏沒有任何擔保,甚至沒有適合
特定目的的隱含的擔保。
REF:
unixinstall
http://mercurial.selenic.com/wiki/UnixInstall
hgrc
http://www.selenic.com/mercurial/hgrc.5.html
這個工具在國內不多人使用,因此中文資料匱乏.只有官方的website上有一些少得可憐的中文資料了.不過整體上來講,hg仍是比較好用的。
接下來開始 HG 的使用
1.創建用戶hgrepo
其它用戶將用這個帳戶用hg服務器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 # 初始化代碼倉庫
創建一個測試文件
echo "hello, mercurial" > sample.txt
hg add # add
hg ci # check in
3. 打開http
打開一個端口,讓遠程用戶能夠clone倉庫中的代碼.
在打開端口前請肯定文件權限正確。
更改文件權限
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這樣就能夠在開機的時候自動運行了。
4.使用hg
完成步驟3之後,咱們就可使用了。
clone到本地
例如你的服務器的名字爲test.
hg clone http://test:8002
而後在本地目錄就會出現一個project.hg的一個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 向服務器提交code了。這時服務器會問你passward,這個password就是用戶hgrepo的password.
Good Luck.
官方網站
http://www.selenic.com/mercurial/
另外還有個 Windows 下的客戶端與其配合使用
TortoiseHg