1. clone
    1. hg clone http://hg.serpentine.com/tutorial/hello
    2. hg clone hello hello-pull
      1. 必须在与hello同一目录的路径下执行才能找到repository
      2. hello是之前的版本,hello-pull是clone的目的地
  2. log
    1. hg log
    2. hg log -r 3
    3. hg log -r 1 -r 4
    4. hg log -r 2:4
    5. hg log -v -r 3
    6. hg log -q -r 2
    7. hg log -v -p -r 2
      1. hg log -vpr 4
    8. hg log -p
  3. status
    1. hg status
    2. hg status directory
  4. diff
    1. hg diff
    2. hg diff -g
  5. commit
    1. User机制
      1. -u 指定用户名
      2. 使用HGUSER的变量值
      3. 使用.hgrc里面的username
      4. 使用EMAIL的变量值
      5. 使用系统的用户名和host name
    2. hg ci
    3. hg commit -A
  6. tip
    1. hg tip
    2. hg tip -vp
      1. -v
      2. -p
  7. update
    1. hg update tip
      1. 只是工作目录里的文件变了,但版本号没变
    2. hg update
  8. pull
    1. hg pull ../my-hello
    2. hg incoming ../my-hello
    3. hg pull -r 7e95bb
    4. pull 默认不会自动更新工作目录
  9. parents
    1. hg parents
  10. push
    1. push outgoing ../my-hello
    2. push没有-u选项来更新他人的工作目录
    3. hg push http://hg.serpentine.com/tutorial/hello
  11. 配置文件
    1. .hg目录下的.hgrc
      1. default = D:\Backup\JEE\Output
      2. default-push = http://hg.example.com/hg
      3. default-pull = http://hg.example.com/hg
  12. init
    1. hg init newproject
    2. 通常是在创建项目后,转向改项目目录,hg init
  13. add
    1. hg add
    2. hg add .
    3. hg add -n
  14. help
    1. hg help init
    2. hg help export
  15. 合并
    1. hg heads
      1. hg update -c
      2. hg merge
        1. after commit
    2. hg pull newProject
    3. hg parents
    4. hg resolve
  16. version
    1. hg version
  17. 命令扩展
    1. hg fetch
      1. 在.hgrc里面配置
        1. [extensions] fetch =
      2. hg pull -u
      3. hg merge
      4. hg commit
      5. 三个命令的结合
  18. remove
    1. hg reomve Hello.class
      1. 直接命令删除,后显示R
    2. hg reomve --after Hello.class
      1. 处理手工删除文件status显示!
    3. hg revert
      1. 使R消失
  19. addremove
    1. hg addremove
    2. hg commit -A -m 'Commit with addremove'
  20. copy
    1. hg copy file1 newfile
    2. hg status -C
    3. hg copy directory1 directory2
    4. hg copy --after a n
  21. rename
    1. hg rename a b
  22. 备份
    1. hg clone -U myrepo myrepo.bak
  23. tag
    1. hg tag v1.0
      1. hg tag -r 1 V1.1
      2. hg tag -f -r 2 v1.1
    2. hg tags
    3. hg update v1.0
    4. hg tag --remove v1.0
  24. serve
    1. hg serve
  25. 过滤
    1. include
      1. hg status -I '*.in'
    2. exclude
      1. hg status -X '**.py' src
        1. hg status -I "**.java"
        2. hg status 'glob:*.py'
    3. 忽略文件
      1. 在repository目录下新建, .hgignore
      2. syntax: glob *.class
  26. branch
    1. hg branches
    2. hg branch
    3. hg branch foo
      1. 提交之后可以看到效果
  27. 撤销
    1. revert
      1. hg revert file1.txt
        1. A-->?
        2. M-->返回到修改之前的内容
      2. 几种使用revert后的情况
        1. If you modify a file, it will restore the file to its unmodified state.
        2. If you hg add or hg copy a file, it will undo the “added” state of the file, but leave the file itself untouched.
        3. If you delete a file without telling Mercurial, it will restore the file to its unmodified contents.
        4. If you use the hg remove command to remove a file, it will undo the “removed” state of the file,
    2. rollback
      1. hg rollback
      2. 只能回滚一次
      3. 当push之后无法回滚
    3. backout
      1. hg backout
      2. hg backout tip
        1. hg log --style compact
      3. hg backout 非tip版本
        1. 会先创建一个新的head
        2. 使用hg backout --merge
        3. hg commit
      4. 撤销合并
        1. hg backout --rev=4 --parent=2
        2. hg backout --rev=4 --parent=3.
        3. 最后merge这2个新的head