Windows下用hg-fast-export迁移Mercurial至GitLab遇share-safe错误求助
问题
在Windows环境下使用hg-fast-export迁移Mercurial仓库到GitLab时触发以下错误:
"C:\Projects\Git\test_repo\hg2git.py", line 47, in setup repo File "C:\Python27\lib\site-packages\mercurial\scmutil.py", line 1031, in readrequires hint=_("see https://mercurial-scm.org/wiki/MissingRequirement" mercurial.error.RequirementError: repository requires features unknown to this Mercurial: share-safe fast-import statistics:
当前环境:Python 2.7.16、Mercurial 4.6.1,使用的导出工具仓库为https://github.com/frej/fast-export.git,已尝试版本更新但无效。
解决方法
方案1:切换到兼容旧Mercurial的hg-fast-export分支
原仓库master分支已不再适配Mercurial 4.x版本,需切换到hgext30分支(支持Mercurial 3.0+):
- 克隆指定分支:
git clone -b hgext30 https://github.com/frej/fast-export.git
- 使用该分支下的脚本重新执行迁移流程。
方案2:移除Mercurial仓库的share-safe特性要求
手动修改仓库配置绕过版本限制:
- 打开目标Mercurial仓库目录下的
.hg/requires文件; - 删除其中的
share-safe行; - 保存文件后重新运行迁移脚本。
方案3:改用Mercurial官方迁移扩展hg-git
如果上述方案无效,可使用官方的hg-git扩展:
- 编辑Mercurial配置文件
%USERPROFILE%\.hgrc,添加以下内容:
[extensions] hggit =
- 克隆Mercurial仓库并推送到GitLab:
hg clone <你的Mercurial仓库地址> local-hg-repo cd local-hg-repo hg push git+ssh://git@gitlab.com/<你的用户名>/<目标仓库名>.git
内容的提问来源于stack exchange,提问作者sandeep
相关产品推荐
相关产品推荐

