hg(Mercurial)版本库迁移到git版本库
来源:互联网 发布:excel如何删除一列数据 编辑:程序博客网 时间:2024/06/05 17:37
原文地址:http://www.cnblogs.com/rangeon/p/3673224.html
这几天没事干净搞迁移了,迁移完MVC又迁移版本库,还把工作电脑迁移了一下,开始用Win8.1了。这个迁移主要是因为实在不想在工作电脑上又装git又装hg了,点个右键出来一大堆菜单,况且现在git已经成为名符其实的“最高大上的分布式版本控制系统,没有之一”了,关键还是感觉git好用、用的顺手,就做了一个痛苦的决定:把hg干掉!XD
废话不多说,言归正传。
这个迁移其实很简单,就是使用fast-export迁移工具,在 Git Bash 中进行操作:
1 git clone git://repo.or.cz/fast-export.git2 mkdir to_git3 cd to_git4 git init5 ../fast-export/hg-fast-export.sh -r /path/to/old/hg_repo_folder6 git checkout HEAD
说明:
必须安装 hg 和 git,转换过程中需要用到。
环境变量的 Path 中要包含 Python 的目录。
必须执行 hg-fast-export.sh,不能直接执行 hg-fast-export.py,
直接执行 hg-fast-export.py 问题一大堆,也可能是我的 python 内力不足。
下面说说我遇到的一些问题(郁闷,怎么问题都让我遇上了)。
问题一
Error: Branch [master] modified outside hg-fast-export:
f8b24a1a35786cfcbb911592f4ad002ff76d4fae (repo) != None (cache)
解决:目标目录的git版本库不纯净,必须是空目录直接 git init 之后的。
问题二
repository has at least one unnamed head: hg r49
解决:加 --force 处理之
问题三 - 日志乱码
解决:修改hg-fast-export.py,对日志进行编码转换(170行左右)
(revnode,_,user,(time,timezone),files,desc,branch,_)=get_changeset(ui,repo,revision,authors)
desc = desc.decode('gbk').encode('utf-8')
branch=get_branchname(branch)
问题四 - 中文文件名乱码
解决:修改hg-fast-export.py,对文件名进行编码转换(134行左右)
开头加入:
reload(sys)
sys.setdefaultencoding('cp936')
找到:
wr('M %s inline %s' % (gitmode(manifest.flags(file)),file))
改为
wr('M %s inline %s' % (gitmode(manifest.flags(file)),file.encode('utf-8')))
分享一个我修改过的 hg-fast-export.py 文件:点击下载
- hg(Mercurial)版本库迁移到git版本库
- Mercurial(hg) 代码库迁移到 Git
- Hg Mercurial 邮件更新版本库
- Mercurial (HG)分布式版本控制系统
- 学习hg(mercurial)版本控制
- 版本控制mercurial(hg)常用命令
- CVS版本库到Git的迁移
- 火速配置完成mercurial(Hg)中心版本库,支持push/pull
- 【转】版本控制軟體hg (Mercurial)
- HG,GIT,SVN版本控制系统
- Mercurial(Hg)分布式版本控制的快速入门
- 突击Mercurial SCM(HG)13---回退到指定版本
- 让hg版本库自动化测试
- 分布式版本控制工具:git与Mercurial
- 分布式版本控制工具:git & mercurial
- vss2005版本库迁移
- SVN版本库迁移
- SVN版本库迁移
- python 连接mysql
- 缓冲区溢出漏洞(二):堆栈和溢出.
- 大臣的旅费 蓝桥
- poj 3617 Best Cow Line(贪心)
- 蓝桥杯 JAVA 表达式计算
- hg(Mercurial)版本库迁移到git版本库
- Android5.x:RecycleView(三):上下拖动和左右滑动删除
- i++和++i的线程安全性问题
- 第五单元总结
- 线程安全和线程不安全的区别
- 详解Struts2的类型转换(3)
- JUnit单元测试使用java详解
- linux基本概念及操作
- 在用例图中,应该如何区分《include》和《extend》这两个原型?