linux下hg无法运行_linux下hg无法运行_Linux下Mercurial (hg)配置说明

今天从源代码安装了mercurial,本来可以用命令很简单的安装:

sudo apt-get install mercurial,但是安装以后发现版本比较老,所以决定从源代码安装。

官方网站:http://mercurial.selenic.com/wiki/

下载下来解压缩以后,里面有个README文件,打开以后按照说明来:

Basic install:

$ make

$ make install

$ hg debuginstall

$ hg

安装完成后执行 hg debuginstall 时出现了错误:

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。然后就可以正常使用了。

添加配置文件

此时再运行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

username = Joe Who

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 和其他人。

这是自由软件,具体参见版权条款。这里没有任何担保,甚至没有适合

特定目的的隐含的担保。

REF:

unixinstall

hgrc

这个工具在国内很少人使用,所以中文资料匮乏.只有官方的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.

官方网站

另外还有个 Windows 下的客户端与其配合使用

TortoiseHg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值