Reputation: 8269
I am following the instructions on this blog post, to convert from Mercurial to Git
When I run the script as such:
hg-fast-export.sh -r c:\projects\demoapp
Then it fails with the following error:
Traceback (most recent call last):
File "./hg-fast-export.py", line 11, in <module>
from mercurial import node
ImportError: cannot import name node
And the begining of my hg-fast-export.py looks like this
#!/usr/bin/env python
# Copyright (c) 2007, 2008 Rocco Rutte <[email protected]> and others.
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
import sys
# import mercurial libraries from zip:
sys.path.append(r'C:\Program Files (x86)\Mercurial\library.zip')
from mercurial import node
from hg2git import setup_repo,fixup_user,get_branch,get_changeset
from hg2git import load_cache,save_cache,get_git_sha1,set_default_branch,set_origin_name
from optparse import OptionParser
import re
import os
I checked the library.zip
file (which is located in C:\Program Files (x86)\Mercurial\
, and it contains the following folder structure (in addition to many other files/folders insize library.zip
library.zip
|
---------mercurial
|
----------node.pyc
I am really stumped. I do not know what to do. I have been stuck on this for two days. It maybe something very simple that I am overlooking, but I have not idea what it is. Is it a caching issue? Is it a setup issue? Is it an environment issue?
Please helpl, and thanks :)
Upvotes: 0
Views: 269
Reputation: 4998
If this is a package, have you tried placing an __init__.py
file? This would make sure that files from your subdirectories can be found. While you would have to change a little bit of code (especially in your import statements), this seems like it should be the way to go.
Upvotes: 0
Reputation: 1124738
You almost certainly have another mercurial
package or module in your path somewhere. Since you use sys.path.append()
the library.zip
file is searched last for the module.
Your best bet is to add library zipfile to the Python module search path at the start:
sys.path.insert(0, r'C:\Program Files (x86)\Mercurial\library.zip')
Upvotes: 1