这个叫水银的源代码管理工具尽管默默无闻,但还是得到了非常多团队的使用。

为了迎合某些团队的须要,我们也要用它来管理我们的代码。

今天的任务是先袭击学习。磨刀不误砍柴工。

对工具的掌握越快。工作的效率就会越高。

1.安装

首先从官网下载最新的版本号,我这次做个实验,下载了3.2-rc。

解压到你指定的文件夹下:

[linc@localhost mercurial]$ ls
mercurial-3.2-rc.tar.gz
[linc@localhost mercurial]$ tar xzvf mercurial-3.2-rc.tar.gz

安装之前要检查一下是否已经安装了python-dev,这在fedora下叫作python-devel, 假设没有,编译时会出现错误:

mercurial/base85.c:13:20: fatal error: Python.h: No such file or directory

仅仅要看看/usr/include/python2.7/下有没有上述的头文件就知晓了。
安装也好办。ubuntu下使用:

sudo apt-get install python-dev

fedora下使用:

[linc@localhost etc]$ sudo yum install python-devel

来到mercurial-3.2-rc路径下。运行:

[linc@localhost mercurial-3.2-rc]$ make install-home
python setup.py build
running build
running build_mo
running build_ext
building 'mercurial.base85' extension
...
make[1]: *** [hg.1] Error 255
make[1]: Leaving directory `/home/linc/dev/mercurial/mercurial-3.2-rc/doc'
make: *** [doc] Error 2

最后的错误是关于文档的。这里被我无视了,尝试运行hg。得到了反馈。说明基本功能是安装完毕了。

[linc@localhost mercurial-3.2-rc]$ 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)

2.简单的使用

以下就要试着创建一个项目并提交代码。

创建init文件夹:

[linc@localhost testHG]$ hg init testMercurial
[linc@localhost testHG]$ ls
testMercurial
[linc@localhost testHG]$ cd testMercurial/

加入我的小项目,将其它文件夹下的源代码拷到这里:

[linc@localhost testMercurial]$ cp -r ../../hello/* .
[linc@localhost testMercurial]$ ls
Debug Release src

查看当前状态:

[linc@localhost testMercurial]$ hg status
? Debug/makefile
? Debug/objects.mk
? Debug/sources.mk
? Debug/src/subdir.mk
? Release/makefile
? Release/objects.mk
? Release/sources.mk
? Release/src/subdir.mk
? src/hello.c

问号表示还没有纳入版本号管理。以下就给它们加入进来:

[linc@localhost testMercurial]$ hg add
adding Debug/makefile
adding Debug/objects.mk
adding Debug/sources.mk
adding Debug/src/subdir.mk
adding Release/makefile
adding Release/objects.mk
adding Release/sources.mk
adding Release/src/subdir.mk
adding src/hello.c
[linc@localhost testMercurial]$ hg status
A Debug/makefile
A Debug/objects.mk
A Debug/sources.mk
A Debug/src/subdir.mk
A Release/makefile
A Release/objects.mk
A Release/sources.mk
A Release/src/subdir.mk
A src/hello.c

A就是add的标识了。以下我们提交这些代码吧。

[linc@localhost testMercurial]$ hg commit -m 'initial commit'
abort: no username supplied
(use "hg config --edit" to set your username)
[linc@localhost testMercurial]$ hg config --edit

可惜由于我没有编辑好我的名称在配置文件里,先去加入一下。然后继续提交代码:

[linc@localhost testMercurial]$ hg commit -m 'initial commit'
[linc@localhost testMercurial]$ hg status
[linc@localhost testMercurial]$ hg log
changeset: 0:23ac3f5bfc59
tag: tip
user: Lincoln <linc@xxx.com>
date: Mon Oct 27 21:05:10 2014 +0800
summary: initial commit

上面的changeset就是git中的commit id,冒号前面的0就是你的changeset id。越靠前表示它的资历越老。

tag中的tip,一般出如今最新的changeset中,这个小技巧你要记住了哦。

最后我们要将提交推到远程库中才算大功告成。

与git相似。也是用push命令:

hg push /the remote repository

我想要看看这一版都改动了那些地方怎么查?记得git中用show命令。hg呢?export就好了:

[linc@localhost testMercurial]$ hg export 0:23ac3f5bfc59
# HG changeset patch
# User Lincoln <linc@xxx.com>
# Date 1414415110 -28800
# Mon Oct 27 21:05:10 2014 +0800
# Node ID 23ac3f5bfc592c7bd2b293e8ace0f42b9e541ece
# Parent 0000000000000000000000000000000000000000
initial commit diff -r 000000000000 -r 23ac3f5bfc59 Debug/makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Debug/makefile Mon Oct 27 21:05:10 2014 +0800
@@ -0,0 +1,44 @@

这主要的功能就是这样了,后面还会继续merge、conflict等功能。

后记:

2015.1.29

ubuntu上安装:

上述报错是由于doc安装须要python-docutils工具,我们须要安装它:

/opt/mercurial-3.3-rc$ sudo apt-get install python-docutils
这次再编译就没有问题了:

/opt/mercurial-3.3-rc$ sudo make install

參考:

http://mercurial.selenic.com/guide

袭击Mercurial SCM(HG)的更多相关文章

  1. Mercurial (hg)

    附上两个站点: http://z42.readthedocs.org/zh/latest/devtools/hg.html http://bucunzai.net/hginit/ Mercurial( ...

  2. Mercurial

    Contributing Changes http://nginx.org/en/docs/contributing_changes.html Mercurial is used to store s ...

  3. Mercurial 安装及使用

      版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/moonspiritacm/articl ...

  4. 部署搭建 Saltstack(centos6.6)

    SaltStack介绍 官网:https://docs.saltstack.com/en/latest/ 中国saltstack用户组http://www.saltstack.cn/ 下图是它的子系统 ...

  5. 发布构件到Maven中央仓库

    一.注册jira账号 访问如下网址: https://issues.sonatype.org/secure/Signup.jspa 记住邮箱,用户名,密码以备以后使用,一定牢记. 二.创建一个issu ...

  6. Ubuntu使用总结

    错误 鼠标闪烁解决 系统设置->显示—>未知显示器->关闭->应用->选择当前配置 提示sudo: unable to resolve host ,亦即无法解析主机. 原 ...

  7. How to install Pygame for Python 3.4 on Ubuntu 14.04(转)

    First run this to install dependencies: sudo apt-get install mercurial python3-dev python3-numpy \ l ...

  8. go语言初体验

    go下载地址: http://code.google.com/p/go/downloads/list go官方安装地址: http://golang.org/doc/install 另外收集一些关于g ...

  9. cvs vss svn和git比较

    cvs vss svn和git比较 特征 CVS Git Mercurial Subversion 是否原子提交 CVS: 没有. CVS提交不是原子的 Git: 是的. 提交都是原子的 Mercur ...

随机推荐

  1. 20151009 C# 第一篇 基础知识

    20151009 C#:优点: 1. 语法简洁:不直接操作内存,去掉了指针操作 2. 面向对象:具有封装.继承.多态特性 3. 支持Web标准:支持HTML.XML.SOAP 4. 兼容性:遵循.Ne ...

  2. jquery_easyui 相关问题

    1. datagrid点击title,无法进行客户端排序. 增加属性 data-options="singleSelect:true,collapsible:true,url:'/ViewS ...

  3. 1.1 Activity

    1.概念 Application:由多个相关的松散的与用户进行交互Activity组成,通常被打包成apk后缀文件中: Activity:就是被用来进行与用户交互和用来与android内部特性交互的组 ...

  4. 解决修改密码报错‘passwd:Authentication token’

     1.修改密码时报错: 错误信息:'passwd: Authentication token manipulation error' [root@localhost test]# ' | passwd ...

  5. 使用javamail发送邮件错误:550 5.7.1 Unable to relay

    这两天由于客户的邮件服务器迁移,使用了NTLM的验证方式.系统使用javamailAPI进行发送邮件时,发现只能对内部邮箱进行发送,对外部邮箱进行发送的时候,报下图错误: 后面发现是由于系统的java ...

  6. Magcodes.WeiChat——通过CsvFileResult以及DataAnnotations实现导出CSV文件

    我们先来看看效果图: 从上图中可以看出,导出的文件中列名与表格名称保持一致,并且忽略了某些字段. 相关代码实现 我们来看相关代码: 页面代码: @using (Html.BeginForm(" ...

  7. Spring Mobile 1.1.0.RC1 和 1.0.2 发布

    Spring Mobile 1.1.0.RC1 发布了,该版本包含: 支持 Firefox OS 设备的检测 修复了使用 LiteDeviceDelegatingViewResolver 处理重定向和 ...

  8. .NET Socket TCP 50W在线连接交互测试

    在平常的交流中经常有人问.net socket能支持多少在线?和C++或linux下比起来应该差很远吧?其实产生这样问题的主要原因是.net很少人去做这方面的测试,而在linux下则经常听到什么100 ...

  9. 基于 IdentityServer3 实现 OAuth 2.0 授权服务【客户端模式(Client Credentials Grant)】

    github:https://github.com/IdentityServer/IdentityServer3/ documentation:https://identityserver.githu ...

  10. [转]js动态获取图片长宽尺寸

    http://blog.phpdr.net/js-get-image-size.html lightbox类效果为了让图片居中显示而使用预加载,需要等待完全加载完毕才能显示,体验不佳(如filick相 ...