zoukankan      html  css  js  c++  java
  • [SCM]源码管理 mercurial

    一 分布式的源码管理工具Mercurial

    mercurial 作为3大主流的分布式源码管理工具,已经被广泛的使用。 例如 googlecode.com 和 codeplex.com 都支持mercurial作为源码管理工具。

    主页:http://mercurial.selenic.com/

    更多的帮助:http://hgbook.red-bean.com/ 和 TortoiseHg.chm 

    超级超级好的ppt:http://www.slideshare.net/tednaleid/distributed-version-control-dvcs-with-mercurial

    windows下安装非常的方便,只需要双击msi(例如mercurial-1.9.1-x64.msi 或者 tortoisehg-2.1.2-hg-1.9.1-x64.msi)即可。 同时mercurial也支持Linux和MacOS。

    命令行下载: http://mercurial.selenic.com/downloads/

    shell集成的TortoiseHG的下载:http://mercurial.selenic.com/downloads/

     

    二 命令行入门

    本文使用的测试的 mercurial server为https://code.google.com/p/mercurial001, 如果读者需要测试的话,可以留下你的googlecode的username,我可以加你为committer,你可以测试所有的功能。
    1)从远程的repository克隆project到本地,然后修改和提交到远程的repository

     

    解释如下:
    # 将mercurial001 repository 克隆到本地。
    $ hg clone https://code.google.com/p/mercurial001
    # 切换到mercurial目录
    $ cd mercurial001
    #在当前目录mercurial001下增加新的文件 t2.txt 。
    # 标记t2.txt为add状态
    $ hg add
    # 在commit和push前要配置自己的user信息,如果没有配置user,commit时默认使用本机的登录用户,此时配置文件中default server的值默认为刚才clone的源
    https://code.google.com/p/mercurial001,如果没有配置default的server,则对push命令需要指定server的值。
    # 将刚才的修改提交到本地的repository。
    $ hg commit  -m 'add t2.txt'  [ -u AAA ]
    # 将本地的repository 跟新到远程的mercurial001 repository。
    $ hg push [ http://selenic.com/repo/hello ]
    # 如果是push到googlecode,需要使用googlecode的用户名和密码。
     

    2)配置:.hg/hgrc配置文件

     

     解释如下:

    [paths]

    # default为要push的目标地址,同时也是pull的源地址。
    default =https://code.google.com/p/mercurial001
    [ui]
    # username为本地commit的用户名。可以不同于提交到googlecode的用户名。
    username = AAA <AAA@gmail.com>

    3)其他常用的功能

    解释如下:

    # 将远程的mercurial repository的跟新同步到本地的repository。
    $ hg pull
    # 将本地的repository的跟新同步到working copy。
    $ hg update
    # 将文件t4.txt标记为删除状态 。
    $ hg remove t4.txt
    # 查看当前的working copy的修改状态
    $ hg status
    # 将修改应用到本地的repository
    $ hg commit -m "remove t4.txt"
    # 查看本地的repository的修改历史
    $ hg log
    # 将本地的repository 跟新到远程的mercurial001 repository。
    $ hg push [ http://selenic.com/repo/hello ]
    # 如果是push到googlecode,需要使用googlecode的用户名和密码。

    4)创建新的repository和project,然后提交修改
    # 创建新的repository。
    $ hg init (project-directory)
    # 进入repository目录。
    $ cd (project-directory)
    # 增加新的文件。
    $ (add some files)
    # 将新加的文件标记为新加状态。
    $ hg add
    # 将前面的改动应用到repository。
    $ hg commit -m 'Initial commit'

    5)使repository可以通过http被其他的用户访问
    # 为当前的repository启动http的访问方式。
    $ hg serve
    # 通过http来访问repository。
    $ hg clone http://ip:8000/

     

    三 其他的比较好的分布式源码管理工具还有:git和bazaar,但是在windows上mecurial安装最方便。

    完!
  • 相关阅读:
    PAT 甲级 1132 Cut Integer (20 分)
    AcWing 7.混合背包问题
    AcWing 9. 分组背包问题
    AcWing 5. 多重背包问题 II
    AcWing 3. 完全背包问题
    AcWing 4. 多重背包问题
    AcWing 2. 01背包问题
    AcWing 875. 快速幂
    AcWing 874. 筛法求欧拉函数
    AcWing 873. 欧拉函数
  • 原文地址:https://www.cnblogs.com/itech/p/2126116.html
Copyright © 2011-2022 走看看