You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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+):

  1. 克隆指定分支:
git clone -b hgext30 https://github.com/frej/fast-export.git
  1. 使用该分支下的脚本重新执行迁移流程。

方案2:移除Mercurial仓库的share-safe特性要求

手动修改仓库配置绕过版本限制:

  1. 打开目标Mercurial仓库目录下的.hg/requires文件;
  2. 删除其中的share-safe行;
  3. 保存文件后重新运行迁移脚本。

方案3:改用Mercurial官方迁移扩展hg-git

如果上述方案无效,可使用官方的hg-git扩展:

  1. 编辑Mercurial配置文件%USERPROFILE%\.hgrc,添加以下内容:
[extensions]
hggit =
  1. 克隆Mercurial仓库并推送到GitLab:
hg clone <你的Mercurial仓库地址> local-hg-repo
cd local-hg-repo
hg push git+ssh://git@gitlab.com/<你的用户名>/<目标仓库名>.git

内容的提问来源于stack exchange,提问作者sandeep

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 08:12:34