突击Mercurial SCM(HG)13---回退到指定版本

来源:互联网 发布:网络对学生的利与弊 编辑:程序博客网 时间:2024/06/05 20:13

团队开发中,版本回退是老生常谈了。通常版本回退的原因是代码中出现重大错误了,要回退到上一个可运行的版本。
这是一个很危险的动作,而我们使用revert命令来做这个危险动作。

$ hg revert --helphg revert [OPTION]... [-r REV] [NAME]...restore files to their checkout state    Note:       To check out earlier revisions, you should use "hg update REV". To       cancel an uncommitted merge (and lose your changes), use "hg update       --clean .".    Returns 0 on success.options ([+] can be repeated): -a --all                 revert all changes when no arguments given -d --date DATE           tipmost revision matching date -r --rev REV             revert to the specified revision -C --no-backup           do not save backup copies of files -I --include PATTERN [+] include names matching the given patterns -X --exclude PATTERN [+] exclude names matching the given patterns -n --dry-run             do not perform actions, just print output(some details hidden, use --verbose to show complete help)

帮助中提到如果check out早期的版本,用hg update REV较好。

这次我们用revert回退到前一个版本,首先看看hg log:

$ hg logchangeset:   16:6b7d0fecb27btag:         tipuser:        zhaoyundate:        Fri Jan 29 14:25:09 2016 +0800summary:     fix some critical bugchangeset:   15:59958f71202auser:        zhugeliangdate:        Wed Jan 27 11:42:40 2016 +0800summary:     add xxx feature

执行revert命令

$ hg revert -r 59958f71202a --allreverting xxx/xxx/xxx.java

版本回退了,再次进行commit+push就可以了。

0 0