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

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

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

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

1.安装

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

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

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

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

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

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

  1. sudo apt-get install python-dev

fedora下使用:

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

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

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

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

  1. [linc@localhost mercurial-3.2-rc]$ hg
  2. Mercurial Distributed SCM
  3.  
  4. basic commands:
  5.  
  6. add add the specified files on the next commit
  7. annotate show changeset information by line for each file
  8. clone make a copy of an existing repository
  9. commit commit the specified files or all outstanding changes
  10. diff diff repository (or selected files)
  11. export dump the header and diffs for one or more changesets
  12. forget forget the specified files on the next commit
  13. init create a new repository in the given directory
  14. log show revision history of entire repository or files
  15. merge merge working directory with another revision
  16. pull pull changes from the specified source
  17. push push changes to the specified destination
  18. remove remove the specified files on the next commit
  19. serve start stand-alone webserver
  20. status show changed files in the working directory
  21. summary summarize working directory state
  22. update update working directory (or switch revisions)
  23.  
  24. (use "hg help" for the full list of commands or "hg -v" for details)

2.简单的使用

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

创建init文件夹:

  1. [linc@localhost testHG]$ hg init testMercurial
  2. [linc@localhost testHG]$ ls
  3. testMercurial
  4. [linc@localhost testHG]$ cd testMercurial/

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

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

查看当前状态:

  1. [linc@localhost testMercurial]$ hg status
  2. ?
  3.  
  4. Debug/makefile
  5. ? Debug/objects.mk
  6. ?
  7.  
  8. Debug/sources.mk
  9. ? Debug/src/subdir.mk
  10. ?
  11.  
  12. Release/makefile
  13. ?
  14.  
  15. Release/objects.mk
  16. ? Release/sources.mk
  17. ? Release/src/subdir.mk
  18. ?
  19.  
  20. src/hello.c

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

  1. [linc@localhost testMercurial]$ hg add
  2. adding Debug/makefile
  3. adding Debug/objects.mk
  4. adding Debug/sources.mk
  5. adding Debug/src/subdir.mk
  6. adding Release/makefile
  7. adding Release/objects.mk
  8. adding Release/sources.mk
  9. adding Release/src/subdir.mk
  10. adding src/hello.c
  11. [linc@localhost testMercurial]$ hg status
  12. A Debug/makefile
  13. A Debug/objects.mk
  14. A Debug/sources.mk
  15. A Debug/src/subdir.mk
  16. A Release/makefile
  17. A Release/objects.mk
  18. A Release/sources.mk
  19. A Release/src/subdir.mk
  20. A src/hello.c

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

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

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

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

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

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

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

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

  1. hg push /the remote repository

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

  1. [linc@localhost testMercurial]$ hg export 0:23ac3f5bfc59
  2. # HG changeset patch
  3. # User Lincoln <linc@xxx.com>
  4. # Date 1414415110 -28800
  5. # Mon Oct 27 21:05:10 2014 +0800
  6. # Node ID 23ac3f5bfc592c7bd2b293e8ace0f42b9e541ece
  7. # Parent 0000000000000000000000000000000000000000
  8. initial commit
  9.  
  10. diff -r 000000000000 -r 23ac3f5bfc59 Debug/makefile
  11. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  12. +++ b/Debug/makefile Mon Oct 27 21:05:10 2014 +0800
  13. @@ -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. java线程详解(三)

    java线程间通信 首先看一段代码 class Res { String name; String sex; } class Input implements Runnable { private R ...

  2. Form居中显示

    (1)居中显示 Form1->Position = poScreenCenter; (2)无边框显示 Form1->BorderStyle = bsNone; (3)显示透明性 Form1 ...

  3. 第五天:内置对象(7.Javascript内置对象)

    1)中所术是内置对象,2)中为自定义对象 代码说明如下 2.1.1 定义并创建对象实例方式1,代码如下: <!DOCTYPE html><html lang="en&quo ...

  4. Magicodes.WeiChat——媒体资源选择组件之media-choice(开源)

    media-choice为媒体资源选择组件,基于KnockoutJs.支持图片.语音.视频.图文的选择以及预览,支持默认选择类型,支持是否禁用选择类型的更改. 使用示例: <script id= ...

  5. C#过滤Html标签及空格

    public static string FilterHTML(string HTMLStr) { if (!string.IsNullOrEmpty(HTMLStr)) return System. ...

  6. 【Win10】解决 模拟器调试手机 错误-> 引导阶段... 无法找到指定路径......\2052\msdbgui.dll

    去弄几天的Web服务,又弄了几天的CefSharp,都是给其它组的同学做了一下支持,终于又可以回来玩下Win10啦. 今天想试一下UWP在手机上的效果,就找了台WP手机开始升级,结果下载速度遥遥无期, ...

  7. 在Github上注册账户

    首先打开网址:https://github.com/ 进行注册     注册完成后进入邮箱验证     在右上角创建一个简单的项目仓库 创建完成

  8. SQL Server转发记录指针的坏味道

    什么是转发记录指针? 转发记录指针是堆表中特有的数据存储机制. 当你修改了某个数据页中的一行时,如果该行所在的数据页已经无法存放其修改后的行, SQL Server会把这行数据移动到一个新的数据页上面 ...

  9. [ACM_搜索] ZOJ 1103 || POJ 2415 Hike on a Graph (带条件移动3盘子到同一位置的最少步数 广搜)

    Description "Hike on a Graph" is a game that is played on a board on which an undirected g ...

  10. [ACM_图论] Fire Net (ZOJ 1002 带障碍棋盘布炮,互不攻击最大数量)

    Suppose that we have a square city with straight streets.  A map of a city is a square board with n ...