源代码安装mercurial

今天从源代码安装了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

http://www.oschina.net/p/tortoisehg

相关文章
相关标签/搜索