Linux下Mercurial (hg)配置说明

本文发布时间: 2019-Mar-22
今天从源代码安装了mercurial,本来可以用命令很简单的安装:sudo apt-get install mercurial,但是安装以后发现版本比较老,所以决定从源代码安装。官方网站:http://mercurial.selenic.com/wiki/下载下来解压缩以后,里面有个README文件,打开以后按照说明来:Basic install:$ make$ make install$ hg debuginstall$ hg安装完成后执行 hg debuginstall 时出现了错误:hg --versionabort: 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 <[email protected]>username = Joe Who <[email protected]>verbose = True### --- Extensions再运行hg debuginstall ,出现这个提示就可以了Checking encoding (UTF-8)...Checking extensions...Checking templates...Checking patch...patching file hg-debuginstall-wCOuEsChecking commit editor...Checking username...No problems detected运行hg,出现分布式软件配置管理工具 - 水银 (版本 1.5.0)版权所有 (C) 2005-2009 Matt Mackall <[email protected]> 和其他人。这是自由软件,具体参见版权条款。这里没有任何担保,甚至没有适合特定目的的隐含的担保。REF:unixinstallhttp://mercurial.selenic.com/wiki/UnixInstallhgrchttp://www.selenic.com/mercurial/hgrc.5.html这个工具在国内很少人使用,所以中文资料匮乏.只有官方的website上有一些少得可怜的中文资料了.不过总体上来说,hg还是比较好用的。 接下来开始 HG 的使用1.建立用户hgrepo其它用户将用这个账户用hg服务器push代码。useradd hgrepo -d /home/hgrepo # add user hgrepopasswd hgrepo2.建立hg代码仓库如果代码仓库名称为project.hg,则可用如下命令。cd /home/hgrepomkdir project.hgcd project.hghg init # 初始化代码仓库建立一个测试文件echo "hello, mercurial" > sample.txthg add # addhg ci # check in3. 打开http打开一个端口,让远程用户可以clone仓库中的代码.在打开端口前请确定文件权限正确。更改文件权限chown hgrepo.hgrepo /home/hgrepo/project.hg -Rchmod og+rw /home/hgrepo/project.hg -R打开端口cd /home/hgrepo/project.hg -Rhg 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:8002default-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 下的客户端与其配合使用TortoiseHghttp://www.oschina.net/p/tortoisehg


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:10pm
栏目列表