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