您的位置:首页 > 其它

meicurial (hg)安装配置

2014-09-03 13:10 92 查看
序. 之前的写的太简了,今天有空补充一下哈
一、必须安装docutils  

# wget http://prdownloads.sourceforge.net/docutils/docutils-0.7.tar.gz?download # tar -zxf docutils-0.7.tar.gz
# cd docutils-0.7
# python setup.py install


二、安装HG

#. cd /var/local/
#. wget http://mercurial.selenic.com/release/mercurial-3.0.tar.gz #. tar xvzf mercurial-3.0.tar.gz
#. mv mercurial-3.0 mercurial
#. cd mercurial
#. make all
#. make install


三、检测是否安装成功

#hg
显示以下信息表示安装成功
Mercurial Distributed SCM
basic commands:
add           add the specified files on the next commit
annotate      show changeset information by line for each file
clone         make a copy of an existing repository
commit        commit the specified files or all outstanding changes
diff          diff repository (or selected files)
export        dump the header and diffs for one or more changesets
forget        forget the specified files on the next commit
init          create a new repository in the given directory
log           show revision history of entire repository or files
merge         merge working directory with another revision
pull          pull changes from the specified source
push          push changes to the specified destination
remove        remove the specified files on the next commit
serve         start stand-alone webserver
status        show changed files in the working directory
summary       summarize working directory state
update        update working directory (or switch revisions)

use "hg help" for the full list of commands or "hg -v" for details


四、建立代码仓库

#mkdir /alidata/www/hg/repos
#cd /alidata/www/hg/repos
#hg init
#echo "hello world" > readme.txt
#hg add #add
#hg ci #check in
启动http server
#chown momon:hguser -R /alidata/www/hg/repos
#cd /alidata/www/hg/repos
#hg serve -p 8000 &
启动http http://youid:8000 
注:记得给代码仓库文件夹添加777的权限以免出错


五、到这里可以ssh的验证方式克隆代码

    

源地址:ssh://momon@121.22.33.4///alidata/www/hg/repos
密码就是:momon用户名的密码

ssh登录有命令查看hg branches 如果报错
not trusting file /alidata/www/hg/repos/.hg/hgrc from untrusted user momon, group hgusers
解决方法:
#vim $HOME/.hgrc
加入以下代码
[trusted]
users = momon

[trusted]
groups = hgusers


六、补充知识

  

linux用户组和用户管理
用户组的管理涉及用户组的添加、删除和修改。组的增加、删除和修改实际上就是对/etc/group文件的更新。
用户组:
1、增加一个新的用户组使用groupadd命令。 其格式如下:
groupadd 选项 用户组
可以使用的选项有:
代码:
-g GID 指定新用户组的组标识号(GID)。
-o 一般与-g选项同时使用,表示新用户组的GID可以与系统已有用户组的GID相同。

# groupadd group1
#groupadd -g 101 group2
此命令向系统中增加了一个新组group2,同时指定新组的组标识号是101。

2、如果要删除一个已有的用户组,使用groupdel命令, 其格式如下:
groupdel 用户组

3、修改用户组的属性使用groupmod命令。 其语法如下:
groupmod 选项 用户组

常用的选项有:
代码:
-g GID 为用户组指定新的组标识号。
-o 与-g选项同时使用,用户组的新GID可以与系统已有用户组的GID相同。
-n新用户组 将用户组的名字改为新名字
4、如果一个用户同时属于多个用户组,那么用户可以在用户组之间切换,以便具有其他用户组的权限。用户可以在登录后,使用命令newgrp切换到其他用户组,这个命令的参数就是目的用户组。 例如:
newgrp root

用户:
1、增加
1、添加新的用户账号使用useradd命令,其语法如下:
useradd 选项 用户名
其中各选项含义如下:
代码:
-c comment 指定一段注释性描述。
-d 目录 指定用户主目录,如果此目录不存在,则同时使用-m选项,可以创建主目录。
-g 用户组 指定用户所属的用户组。
-G 用户组,用户组 指定用户所属的附加组。
-s Shell文件 指定用户的登录Shell。
-u 用户号 指定用户的用户号,如果同时有-o选项,则可以重复使用其他用户的标识号。
useradd -s /bin/sh -g group -G group2,root users1
此段解释为 创建一个用户为users1的用户登录shell是/bin/sh 属于group用户组,同时又属于group2,root,group是主组

2、删除
userdel 选项 用户名
常用的选项是-r,它的作用是把用户的主目录一起删除。
# userdel sam

3、修改帐号
修改用户账号就是根据实际情况更改用户的有关属性,如用户号、主目录、用户组、登录Shell等。
usermod 选项 用户名

# usermod -s /bin/ksh -d /home/z –g developer sam

4、用户口令的管理
passwd 选项 用户名
可使用的选项:
代码:
-l 锁定口令,即禁用账号。
-u 口令解锁。
-d 使账号无口令。
-f 强迫用户下次登录时修改口令。
如果默认用户名,则修改当前用户的口令。
# passwd sam
#New password:*******
#Re-enter new password:*******

5、
chown命令
通过chown改变文件的拥有者和群组。在更改文件的所有者或所属群组时,可以使用用户名称和用户识别码设置。普通用户不能将自己的文件改变成其他的拥有者。其操作权限一般为管理员。
chown [选项]... [所有者][:[组]] 文件...
必要参数:

    -c 显示更改的部分的信息

    -f 忽略错误信息

    -h 修复符号链接

    -R 处理指定目录以及其子目录下的所有文件

    -v 显示详细的处理信息

    -deference 作用于符号链接的指向,而不是链接文件本身

hg 手册

1. hg log 命令集中

    查看特定版本:hg log -r 2
changeset: 2:e2a9c666c774
branch: momon_init
user: momon
date: Sun May 24 21:52:46 2015 +0800
summary: init

查看多个版本例如查看2,3,4:hg log -r 2:4
changeset: 2:e2a9c666c774
branch: momon_init
user: momon
date: Sun May 24 21:52:46 2015 +0800
summary: init

changeset: 3:7de519bae38b
parent: 0:6cd776ba8d77
parent: 2:e2a9c666c774
user: momon
date: Sun May 24 22:11:22 2015 +0800
summary: init

changeset: 4:567a117191f6
branch: momon_18
user: momon
date: Sun May 24 22:26:17 2015 +0800
summary: add goods
查询分支的操作记录:hg log -v -b cws-name
changeset: 22:b8645a81d7b4
branch: momon_23
user: momon
date: Tue May 26 11:03:07 2015 +0800
files: users/models.py
description:
add user table
列出用户momon的所有提交记录:hg log -u momon
changeset: 1:86822ad96e49
branch: momon_init
user: momon
date: Sun May 24 21:43:31 2015 +0800
summary: project init

changeset: 0:6cd776ba8d77
user: momon
date: Sun May 24 21:30:24 2015 +0800
summary: save
列出在2015-05-24这一天的所有提交记录:hg log -d "2015-05-24"
changeset: 9:fd58190879dd
parent: 7:099cb5964347
parent: 8:f407a225bd34
user: momon
date: Sun May 24 23:38:07 2015 +0800
summary: add order

changeset: 8:f407a225bd34
branch: momon_20
user: momon
date: Sun May 24 23:36:12 2015 +0800
summary: add order
列出包含table这个关键字的所有提交记录(注意hg关键字搜索包含两个地方:提交文件和提交注释):
changeset: 23:9ef8ed922426
tag: tip
parent: 21:aa6f1a4d01ae
parent: 22:b8645a81d7b4
user: momon
date: Tue May 26 11:10:04 2015 +0800
summary: add user table

以上选项-u -d -k 还可以组合使用以提高搜索命中率: hg log -u momon -d "2015-05-21 to 2015-05-24" -k add
changeset: 9:fd58190879dd
parent: 7:099cb5964347
parent: 8:f407a225bd34
user: momon
date: Sun May 24 23:38:07 2015 +0800
summary: add order

changeset: 8:f407a225bd34
branch: momon_20
user: momon
date: Sun May 24 23:36:12 2015 +0800
summary: add order
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: