python - 在 Windows 上使用 git-remote-hg

标签 python git mercurial hg-git

根据这个答案https://stackoverflow.com/a/13354944/867294设置 git 以使用 mercurial “无依赖关系或任何东西”应该相当容易。

在 Windows tough 上,这似乎并不是那么顺利。

我试着遵循这个指南

https://github.com/msysgit/msysgit/wiki/Guide-to-git-remote-hg

修复 makeFile 以在我的系统上运行并构建 git 后,我​​无法调用 git-remote-hg,因为它提示找不到 python 解释器,尽管它配置正确。 所以我用

手动调用它
C:/Python27/python.exe git-remote-hg clone C:/TestMercurialRepo

这现在给我以下错误。

Traceback (most recent call last):
  File "git-remote-hg", line 99, in <module>
    sys.exit(HgRemoteHelper().main(sys.argv))
  File "d:\development\msysgit\git\git_remote_helpers\helper.py", line 196, in m
ain
    repo = self.get_repo(alias, url)
  File "git-remote-hg", line 33, in get_repo
    if repo.capable('branchmap'):
  File "c:\Python27\lib\site-packages\mercurial\repoview.py", line 205, in __get
attr__
    return getattr(self._unfilteredrepo, attr)
AttributeError: 'mqrepo' object has no attribute 'capable'

我该如何解决这个问题?
如果任何地方都有预构建版本,那将是非常棒的,因为我觉得我正在做很多事情来让它工作。

最佳答案

我今天让它在 Windows 上运行。基本上,由于 msysgit 发行版不支持 Python,我使用了 Felipe 的 git-remote-hg.py 文件并使用 py2exe 将其打包为可执行文件。之后,我将所有 py2exe 输出放入我的 Git 安装目录下的“libexec”文件夹中,它就可以运行了。

要使其正常工作,您需要:

  1. python 2.7
  2. Mercurial Python 模块(windows 安装程序 here)
  3. py2exe(windows 安装程序 here)
  4. Felipe 的 git-remote-hg python 脚本(将原始文件保存到文件 here )

创建一个名为 setup.py 的文件,其中包含:

from distutils.core import setup
import py2exe

setup(console=['git-remote-hg.py'])

将文件保存到您的文件系统并运行以下命令:

python setup.py py2exe --include mercurial    

py2exe 将生成一个名为“dist”的文件夹,其中包含输出。将该文件夹的内容复制到主 Git 安装文件夹(例如 C:\Program Files(x86)\Git)下的 libexec\git-core 文件夹中。

现在,您应该能够使用 Git 客户端从 Mercurial 存储库克隆。

(注意:我写这些步骤有点匆忙,所以如果我遗漏了任何内容,请回复)。

关于python - 在 Windows 上使用 git-remote-hg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15601246/

相关文章:

python - python中如何在某些情况下终止进程

Eclipse 导入 > Git 选项不可用

git - 最近更新后在 pycharm 中运行 git 时出错

version-control - 如何列出我创建的所有文件?

python - 如何在 Python 中动态移动嵌套字典

python - 从 16 个内核开始,向 virtualbox 添加更多内核会使应用程序变慢

GitLab 推送错误 : LFS objects are missing

mercurial - 当我在终端(Mercurial)中执行 "hg st"时,我会得到一个不同颜色的更改列表。有谁知道这些颜色是什么意思?

version-control - Mercurial - 插入子 repo 头

python - 权限错误 : [Errno 13] Permission denied: 'ffprobe' (AudioSegment)