6

According to this answer https://stackoverflow.com/a/13354944/867294 it should be fairly easy to set up git to work with mercurial "no dependencies or anything".

This doesn't seem to work all that smooth on Windows tough.

I tried to follow this guide

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

After fixing the makeFile to work on my system and building git i couldn't call git-remote-hg because it complained it couldn't find the python interpreter, all tough it's configured correctly. So i manually called it with

C:/Python27/python.exe git-remote-hg clone C:/TestMercurialRepo

This is now giving me the following error.

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'

How can i fix this ?
If there is a pre build version anywhere then that would be super awesome because i feel like i'm doing way to much to get this to work.

Community
  • 1
  • 1
Willem D'Haeseleer
  • 19,661
  • 9
  • 66
  • 99
  • 1
    Why do you want to interact via `git` with a remote mercurial repository, and on Windows? `hg` has much better support on Windows, and non-native interactions will have their quirks. – vonbrand Mar 24 '13 at 17:13
  • @vonbrand - While I question the wisdom of his choice too, the fact remains he wishes to do it that way and should be able to. – Omnifarious Mar 24 '13 at 17:23
  • @Omnifarious, my point is that there are less painful ways of doing what (I presume) is wanted here. Check out [X Y problems](http://www.perlmonks.org/index.pl?node_id=542341). – vonbrand Mar 24 '13 at 17:27
  • 1
    @vonbrand - That's applicable if the person has problem X, chosen solution Y and hasn't even considered solution Z. But I presume the solution of 'just use Mercurial' has indeed occurred to the OP. – Omnifarious Mar 24 '13 at 17:37

2 Answers2

8

I got this to work today on Windows. Basically, since the msysgit distributions have no Python support, I took Felipe's git-remote-hg.py file and used py2exe to package it up as an executable. Afterwards, I put all of the py2exe output into the 'libexec' folder under my Git installation directory, and it works.

For it to work, you need:

  1. Python 2.7
  2. The Mercurial Python module (windows installers here)
  3. py2exe (windows installers here)
  4. Felipe's git-remote-hg python script (save raw to file here)

Create a file named setup.py that contains:

from distutils.core import setup
import py2exe

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

Save the file to your file system and run the following command:

python setup.py py2exe --include mercurial    

py2exe will produce a folder called 'dist' that contains the output. Copy the contents of that folder into the libexec\git-core folder under your main Git installation folder (e.g., C:\Program Files(x86)\Git).

Now, you should be able to clone from a Mercurial repo using the Git client.

(Note: I wrote these steps in a bit of a hurry, so please post back if I've left out anything).

claytond
  • 1,061
  • 9
  • 22
integragreg
  • 175
  • 2
  • 9
0

I will have to investigate a bit further, but this looks like git-remote-hg might depend on a particular version of Mercurial being installed. In particular one in which the repo object supports the capable method.

This looks like a bug in git-remote-hg code. Any version of Mercurial new enough to have repoview is also new enough that every kind of repo object should support the capable method. So I'm guessing the object that has the problem is one being created by git-remote-hg.

Anyway, it's quite apparent that git-remote-hg uses the Mercurial Python code to do it's work. So there is a dependency between them.

Also, your backtrace does not match the code at https://github.com/felipec/git/blob/fc/remote/hg/contrib/remote-helpers/git-remote-hg, and so it's difficult to debug your setup.

Omnifarious
  • 54,333
  • 19
  • 131
  • 194
  • My file is a generated file that is generated during the build, that is based on this file: https://github.com/msysgit/git/blob/694fb7247b0bb3a3f9810f1350f997ebdb6008ae/git-remote-hg.py Except for the first two lines which are deleted in my git-remote-hg file I'm not sure what the relation is between these files – Willem D'Haeseleer Mar 24 '13 at 19:57